babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082
  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/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * 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".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vector3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * 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)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * 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
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. 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;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. 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;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * 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"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * 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".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * 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"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * 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".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * 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.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * 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.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * 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).
  4352. * 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.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @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.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** 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 */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** 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 */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** 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 */
  4523. static readonly GEQUAL: number;
  4524. /** 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 */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * 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.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * 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.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5297. /** @hidden */
  5298. export interface IShaderProcessor {
  5299. attributeProcessor?: (attribute: string) => string;
  5300. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5301. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5302. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5303. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5304. lineProcessor?: (line: string, isFragment: boolean) => string;
  5305. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5306. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. }
  5308. }
  5309. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5310. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5329. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5330. /** @hidden */
  5331. export class ShaderCodeNode {
  5332. line: string;
  5333. children: ShaderCodeNode[];
  5334. additionalDefineKey?: string;
  5335. additionalDefineValue?: string;
  5336. isValid(preprocessors: {
  5337. [key: string]: string;
  5338. }): boolean;
  5339. process(preprocessors: {
  5340. [key: string]: string;
  5341. }, options: ProcessingOptions): string;
  5342. }
  5343. }
  5344. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5345. /** @hidden */
  5346. export class ShaderCodeCursor {
  5347. private _lines;
  5348. lineIndex: number;
  5349. readonly currentLine: string;
  5350. readonly canRead: boolean;
  5351. lines: string[];
  5352. }
  5353. }
  5354. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5355. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5356. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5357. /** @hidden */
  5358. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5359. process(preprocessors: {
  5360. [key: string]: string;
  5361. }, options: ProcessingOptions): string;
  5362. }
  5363. }
  5364. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5365. /** @hidden */
  5366. export class ShaderDefineExpression {
  5367. isTrue(preprocessors: {
  5368. [key: string]: string;
  5369. }): boolean;
  5370. }
  5371. }
  5372. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5373. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5374. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5375. /** @hidden */
  5376. export class ShaderCodeTestNode extends ShaderCodeNode {
  5377. testExpression: ShaderDefineExpression;
  5378. isValid(preprocessors: {
  5379. [key: string]: string;
  5380. }): boolean;
  5381. }
  5382. }
  5383. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5384. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5385. /** @hidden */
  5386. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5387. define: string;
  5388. not: boolean;
  5389. constructor(define: string, not?: boolean);
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5396. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5397. /** @hidden */
  5398. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5399. leftOperand: ShaderDefineExpression;
  5400. rightOperand: ShaderDefineExpression;
  5401. isTrue(preprocessors: {
  5402. [key: string]: string;
  5403. }): boolean;
  5404. }
  5405. }
  5406. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5407. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5408. /** @hidden */
  5409. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5410. leftOperand: ShaderDefineExpression;
  5411. rightOperand: ShaderDefineExpression;
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5418. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5419. /** @hidden */
  5420. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5421. define: string;
  5422. operand: string;
  5423. testValue: string;
  5424. constructor(define: string, operand: string, testValue: string);
  5425. isTrue(preprocessors: {
  5426. [key: string]: string;
  5427. }): boolean;
  5428. }
  5429. }
  5430. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5431. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5432. /** @hidden */
  5433. export class ShaderProcessor {
  5434. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5435. private static _ProcessPrecision;
  5436. private static _ExtractOperation;
  5437. private static _BuildSubExpression;
  5438. private static _BuildExpression;
  5439. private static _MoveCursorWithinIf;
  5440. private static _MoveCursor;
  5441. private static _EvaluatePreProcessors;
  5442. private static _PreparePreProcessors;
  5443. private static _ProcessShaderConversion;
  5444. private static _ProcessIncludes;
  5445. }
  5446. }
  5447. declare module "babylonjs/Misc/performanceMonitor" {
  5448. /**
  5449. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5450. */
  5451. export class PerformanceMonitor {
  5452. private _enabled;
  5453. private _rollingFrameTime;
  5454. private _lastFrameTimeMs;
  5455. /**
  5456. * constructor
  5457. * @param frameSampleSize The number of samples required to saturate the sliding window
  5458. */
  5459. constructor(frameSampleSize?: number);
  5460. /**
  5461. * Samples current frame
  5462. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5463. */
  5464. sampleFrame(timeMs?: number): void;
  5465. /**
  5466. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5467. */
  5468. readonly averageFrameTime: number;
  5469. /**
  5470. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTimeVariance: number;
  5473. /**
  5474. * Returns the frame time of the most recent frame
  5475. */
  5476. readonly instantaneousFrameTime: number;
  5477. /**
  5478. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5479. */
  5480. readonly averageFPS: number;
  5481. /**
  5482. * Returns the average framerate in frames per second using the most recent frame time
  5483. */
  5484. readonly instantaneousFPS: number;
  5485. /**
  5486. * Returns true if enough samples have been taken to completely fill the sliding window
  5487. */
  5488. readonly isSaturated: boolean;
  5489. /**
  5490. * Enables contributions to the sliding window sample set
  5491. */
  5492. enable(): void;
  5493. /**
  5494. * Disables contributions to the sliding window sample set
  5495. * Samples will not be interpolated over the disabled period
  5496. */
  5497. disable(): void;
  5498. /**
  5499. * Returns true if sampling is enabled
  5500. */
  5501. readonly isEnabled: boolean;
  5502. /**
  5503. * Resets performance monitor
  5504. */
  5505. reset(): void;
  5506. }
  5507. /**
  5508. * RollingAverage
  5509. *
  5510. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5511. */
  5512. export class RollingAverage {
  5513. /**
  5514. * Current average
  5515. */
  5516. average: number;
  5517. /**
  5518. * Current variance
  5519. */
  5520. variance: number;
  5521. protected _samples: Array<number>;
  5522. protected _sampleCount: number;
  5523. protected _pos: number;
  5524. protected _m2: number;
  5525. /**
  5526. * constructor
  5527. * @param length The number of samples required to saturate the sliding window
  5528. */
  5529. constructor(length: number);
  5530. /**
  5531. * Adds a sample to the sample set
  5532. * @param v The sample value
  5533. */
  5534. add(v: number): void;
  5535. /**
  5536. * Returns previously added values or null if outside of history or outside the sliding window domain
  5537. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5538. * @return Value previously recorded with add() or null if outside of range
  5539. */
  5540. history(i: number): number;
  5541. /**
  5542. * Returns true if enough samples have been taken to completely fill the sliding window
  5543. * @return true if sample-set saturated
  5544. */
  5545. isSaturated(): boolean;
  5546. /**
  5547. * Resets the rolling average (equivalent to 0 samples taken so far)
  5548. */
  5549. reset(): void;
  5550. /**
  5551. * Wraps a value around the sample range boundaries
  5552. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5553. * @return Wrapped position in sample range
  5554. */
  5555. protected _wrapPosition(i: number): number;
  5556. }
  5557. }
  5558. declare module "babylonjs/Misc/stringDictionary" {
  5559. import { Nullable } from "babylonjs/types";
  5560. /**
  5561. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5562. * The underlying implementation relies on an associative array to ensure the best performances.
  5563. * The value can be anything including 'null' but except 'undefined'
  5564. */
  5565. export class StringDictionary<T> {
  5566. /**
  5567. * This will clear this dictionary and copy the content from the 'source' one.
  5568. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5569. * @param source the dictionary to take the content from and copy to this dictionary
  5570. */
  5571. copyFrom(source: StringDictionary<T>): void;
  5572. /**
  5573. * Get a value based from its key
  5574. * @param key the given key to get the matching value from
  5575. * @return the value if found, otherwise undefined is returned
  5576. */
  5577. get(key: string): T | undefined;
  5578. /**
  5579. * Get a value from its key or add it if it doesn't exist.
  5580. * This method will ensure you that a given key/data will be present in the dictionary.
  5581. * @param key the given key to get the matching value from
  5582. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5583. * The factory will only be invoked if there's no data for the given key.
  5584. * @return the value corresponding to the key.
  5585. */
  5586. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5587. /**
  5588. * Get a value from its key if present in the dictionary otherwise add it
  5589. * @param key the key to get the value from
  5590. * @param val if there's no such key/value pair in the dictionary add it with this value
  5591. * @return the value corresponding to the key
  5592. */
  5593. getOrAdd(key: string, val: T): T;
  5594. /**
  5595. * Check if there's a given key in the dictionary
  5596. * @param key the key to check for
  5597. * @return true if the key is present, false otherwise
  5598. */
  5599. contains(key: string): boolean;
  5600. /**
  5601. * Add a new key and its corresponding value
  5602. * @param key the key to add
  5603. * @param value the value corresponding to the key
  5604. * @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
  5605. */
  5606. add(key: string, value: T): boolean;
  5607. /**
  5608. * Update a specific value associated to a key
  5609. * @param key defines the key to use
  5610. * @param value defines the value to store
  5611. * @returns true if the value was updated (or false if the key was not found)
  5612. */
  5613. set(key: string, value: T): boolean;
  5614. /**
  5615. * Get the element of the given key and remove it from the dictionary
  5616. * @param key defines the key to search
  5617. * @returns the value associated with the key or null if not found
  5618. */
  5619. getAndRemove(key: string): Nullable<T>;
  5620. /**
  5621. * Remove a key/value from the dictionary.
  5622. * @param key the key to remove
  5623. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5624. */
  5625. remove(key: string): boolean;
  5626. /**
  5627. * Clear the whole content of the dictionary
  5628. */
  5629. clear(): void;
  5630. /**
  5631. * Gets the current count
  5632. */
  5633. readonly count: number;
  5634. /**
  5635. * Execute a callback on each key/val of the dictionary.
  5636. * Note that you can remove any element in this dictionary in the callback implementation
  5637. * @param callback the callback to execute on a given key/value pair
  5638. */
  5639. forEach(callback: (key: string, val: T) => void): void;
  5640. /**
  5641. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5642. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5643. * Note that you can remove any element in this dictionary in the callback implementation
  5644. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5645. * @returns the first item
  5646. */
  5647. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5648. private _count;
  5649. private _data;
  5650. }
  5651. }
  5652. declare module "babylonjs/Misc/promise" {
  5653. /**
  5654. * Helper class that provides a small promise polyfill
  5655. */
  5656. export class PromisePolyfill {
  5657. /**
  5658. * Static function used to check if the polyfill is required
  5659. * If this is the case then the function will inject the polyfill to window.Promise
  5660. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5661. */
  5662. static Apply(force?: boolean): void;
  5663. }
  5664. }
  5665. declare module "babylonjs/Meshes/buffer" {
  5666. import { Nullable, DataArray } from "babylonjs/types";
  5667. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5668. /**
  5669. * Class used to store data that will be store in GPU memory
  5670. */
  5671. export class Buffer {
  5672. private _engine;
  5673. private _buffer;
  5674. /** @hidden */
  5675. _data: Nullable<DataArray>;
  5676. private _updatable;
  5677. private _instanced;
  5678. /**
  5679. * Gets the byte stride.
  5680. */
  5681. readonly byteStride: number;
  5682. /**
  5683. * Constructor
  5684. * @param engine the engine
  5685. * @param data the data to use for this buffer
  5686. * @param updatable whether the data is updatable
  5687. * @param stride the stride (optional)
  5688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5689. * @param instanced whether the buffer is instanced (optional)
  5690. * @param useBytes set to true if the stride in in bytes (optional)
  5691. */
  5692. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5693. /**
  5694. * Create a new VertexBuffer based on the current buffer
  5695. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5696. * @param offset defines offset in the buffer (0 by default)
  5697. * @param size defines the size in floats of attributes (position is 3 for instance)
  5698. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5699. * @param instanced defines if the vertex buffer contains indexed data
  5700. * @param useBytes defines if the offset and stride are in bytes
  5701. * @returns the new vertex buffer
  5702. */
  5703. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5704. /**
  5705. * Gets a boolean indicating if the Buffer is updatable?
  5706. * @returns true if the buffer is updatable
  5707. */
  5708. isUpdatable(): boolean;
  5709. /**
  5710. * Gets current buffer's data
  5711. * @returns a DataArray or null
  5712. */
  5713. getData(): Nullable<DataArray>;
  5714. /**
  5715. * Gets underlying native buffer
  5716. * @returns underlying native buffer
  5717. */
  5718. getBuffer(): Nullable<DataBuffer>;
  5719. /**
  5720. * Gets the stride in float32 units (i.e. byte stride / 4).
  5721. * May not be an integer if the byte stride is not divisible by 4.
  5722. * DEPRECATED. Use byteStride instead.
  5723. * @returns the stride in float32 units
  5724. */
  5725. getStrideSize(): number;
  5726. /**
  5727. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5728. * @param data defines the data to store
  5729. */
  5730. create(data?: Nullable<DataArray>): void;
  5731. /** @hidden */
  5732. _rebuild(): void;
  5733. /**
  5734. * Update current buffer data
  5735. * @param data defines the data to store
  5736. */
  5737. update(data: DataArray): void;
  5738. /**
  5739. * Updates the data directly.
  5740. * @param data the new data
  5741. * @param offset the new offset
  5742. * @param vertexCount the vertex count (optional)
  5743. * @param useBytes set to true if the offset is in bytes
  5744. */
  5745. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5746. /**
  5747. * Release all resources
  5748. */
  5749. dispose(): void;
  5750. }
  5751. /**
  5752. * Specialized buffer used to store vertex data
  5753. */
  5754. export class VertexBuffer {
  5755. /** @hidden */
  5756. _buffer: Buffer;
  5757. private _kind;
  5758. private _size;
  5759. private _ownsBuffer;
  5760. private _instanced;
  5761. private _instanceDivisor;
  5762. /**
  5763. * The byte type.
  5764. */
  5765. static readonly BYTE: number;
  5766. /**
  5767. * The unsigned byte type.
  5768. */
  5769. static readonly UNSIGNED_BYTE: number;
  5770. /**
  5771. * The short type.
  5772. */
  5773. static readonly SHORT: number;
  5774. /**
  5775. * The unsigned short type.
  5776. */
  5777. static readonly UNSIGNED_SHORT: number;
  5778. /**
  5779. * The integer type.
  5780. */
  5781. static readonly INT: number;
  5782. /**
  5783. * The unsigned integer type.
  5784. */
  5785. static readonly UNSIGNED_INT: number;
  5786. /**
  5787. * The float type.
  5788. */
  5789. static readonly FLOAT: number;
  5790. /**
  5791. * Gets or sets the instance divisor when in instanced mode
  5792. */
  5793. instanceDivisor: number;
  5794. /**
  5795. * Gets the byte stride.
  5796. */
  5797. readonly byteStride: number;
  5798. /**
  5799. * Gets the byte offset.
  5800. */
  5801. readonly byteOffset: number;
  5802. /**
  5803. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5804. */
  5805. readonly normalized: boolean;
  5806. /**
  5807. * Gets the data type of each component in the array.
  5808. */
  5809. readonly type: number;
  5810. /**
  5811. * Constructor
  5812. * @param engine the engine
  5813. * @param data the data to use for this vertex buffer
  5814. * @param kind the vertex buffer kind
  5815. * @param updatable whether the data is updatable
  5816. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5817. * @param stride the stride (optional)
  5818. * @param instanced whether the buffer is instanced (optional)
  5819. * @param offset the offset of the data (optional)
  5820. * @param size the number of components (optional)
  5821. * @param type the type of the component (optional)
  5822. * @param normalized whether the data contains normalized data (optional)
  5823. * @param useBytes set to true if stride and offset are in bytes (optional)
  5824. */
  5825. 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);
  5826. /** @hidden */
  5827. _rebuild(): void;
  5828. /**
  5829. * Returns the kind of the VertexBuffer (string)
  5830. * @returns a string
  5831. */
  5832. getKind(): string;
  5833. /**
  5834. * Gets a boolean indicating if the VertexBuffer is updatable?
  5835. * @returns true if the buffer is updatable
  5836. */
  5837. isUpdatable(): boolean;
  5838. /**
  5839. * Gets current buffer's data
  5840. * @returns a DataArray or null
  5841. */
  5842. getData(): Nullable<DataArray>;
  5843. /**
  5844. * Gets underlying native buffer
  5845. * @returns underlying native buffer
  5846. */
  5847. getBuffer(): Nullable<DataBuffer>;
  5848. /**
  5849. * Gets the stride in float32 units (i.e. byte stride / 4).
  5850. * May not be an integer if the byte stride is not divisible by 4.
  5851. * DEPRECATED. Use byteStride instead.
  5852. * @returns the stride in float32 units
  5853. */
  5854. getStrideSize(): number;
  5855. /**
  5856. * Returns the offset as a multiple of the type byte length.
  5857. * DEPRECATED. Use byteOffset instead.
  5858. * @returns the offset in bytes
  5859. */
  5860. getOffset(): number;
  5861. /**
  5862. * Returns the number of components per vertex attribute (integer)
  5863. * @returns the size in float
  5864. */
  5865. getSize(): number;
  5866. /**
  5867. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5868. * @returns true if this buffer is instanced
  5869. */
  5870. getIsInstanced(): boolean;
  5871. /**
  5872. * Returns the instancing divisor, zero for non-instanced (integer).
  5873. * @returns a number
  5874. */
  5875. getInstanceDivisor(): number;
  5876. /**
  5877. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5878. * @param data defines the data to store
  5879. */
  5880. create(data?: DataArray): void;
  5881. /**
  5882. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5883. * This function will create a new buffer if the current one is not updatable
  5884. * @param data defines the data to store
  5885. */
  5886. update(data: DataArray): void;
  5887. /**
  5888. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5889. * Returns the directly updated WebGLBuffer.
  5890. * @param data the new data
  5891. * @param offset the new offset
  5892. * @param useBytes set to true if the offset is in bytes
  5893. */
  5894. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5895. /**
  5896. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5897. */
  5898. dispose(): void;
  5899. /**
  5900. * Enumerates each value of this vertex buffer as numbers.
  5901. * @param count the number of values to enumerate
  5902. * @param callback the callback function called for each value
  5903. */
  5904. forEach(count: number, callback: (value: number, index: number) => void): void;
  5905. /**
  5906. * Positions
  5907. */
  5908. static readonly PositionKind: string;
  5909. /**
  5910. * Normals
  5911. */
  5912. static readonly NormalKind: string;
  5913. /**
  5914. * Tangents
  5915. */
  5916. static readonly TangentKind: string;
  5917. /**
  5918. * Texture coordinates
  5919. */
  5920. static readonly UVKind: string;
  5921. /**
  5922. * Texture coordinates 2
  5923. */
  5924. static readonly UV2Kind: string;
  5925. /**
  5926. * Texture coordinates 3
  5927. */
  5928. static readonly UV3Kind: string;
  5929. /**
  5930. * Texture coordinates 4
  5931. */
  5932. static readonly UV4Kind: string;
  5933. /**
  5934. * Texture coordinates 5
  5935. */
  5936. static readonly UV5Kind: string;
  5937. /**
  5938. * Texture coordinates 6
  5939. */
  5940. static readonly UV6Kind: string;
  5941. /**
  5942. * Colors
  5943. */
  5944. static readonly ColorKind: string;
  5945. /**
  5946. * Matrix indices (for bones)
  5947. */
  5948. static readonly MatricesIndicesKind: string;
  5949. /**
  5950. * Matrix weights (for bones)
  5951. */
  5952. static readonly MatricesWeightsKind: string;
  5953. /**
  5954. * Additional matrix indices (for bones)
  5955. */
  5956. static readonly MatricesIndicesExtraKind: string;
  5957. /**
  5958. * Additional matrix weights (for bones)
  5959. */
  5960. static readonly MatricesWeightsExtraKind: string;
  5961. /**
  5962. * Deduces the stride given a kind.
  5963. * @param kind The kind string to deduce
  5964. * @returns The deduced stride
  5965. */
  5966. static DeduceStride(kind: string): number;
  5967. /**
  5968. * Gets the byte length of the given type.
  5969. * @param type the type
  5970. * @returns the number of bytes
  5971. */
  5972. static GetTypeByteLength(type: number): number;
  5973. /**
  5974. * Enumerates each value of the given parameters as numbers.
  5975. * @param data the data to enumerate
  5976. * @param byteOffset the byte offset of the data
  5977. * @param byteStride the byte stride of the data
  5978. * @param componentCount the number of components per element
  5979. * @param componentType the type of the component
  5980. * @param count the total number of components
  5981. * @param normalized whether the data is normalized
  5982. * @param callback the callback function called for each value
  5983. */
  5984. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5985. private static _GetFloatValue;
  5986. }
  5987. }
  5988. declare module "babylonjs/Maths/sphericalPolynomial" {
  5989. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5990. /**
  5991. * Class representing spherical harmonics coefficients to the 3rd degree
  5992. */
  5993. export class SphericalHarmonics {
  5994. /**
  5995. * Defines whether or not the harmonics have been prescaled for rendering.
  5996. */
  5997. preScaled: boolean;
  5998. /**
  5999. * The l0,0 coefficients of the spherical harmonics
  6000. */
  6001. l00: Vector3;
  6002. /**
  6003. * The l1,-1 coefficients of the spherical harmonics
  6004. */
  6005. l1_1: Vector3;
  6006. /**
  6007. * The l1,0 coefficients of the spherical harmonics
  6008. */
  6009. l10: Vector3;
  6010. /**
  6011. * The l1,1 coefficients of the spherical harmonics
  6012. */
  6013. l11: Vector3;
  6014. /**
  6015. * The l2,-2 coefficients of the spherical harmonics
  6016. */
  6017. l2_2: Vector3;
  6018. /**
  6019. * The l2,-1 coefficients of the spherical harmonics
  6020. */
  6021. l2_1: Vector3;
  6022. /**
  6023. * The l2,0 coefficients of the spherical harmonics
  6024. */
  6025. l20: Vector3;
  6026. /**
  6027. * The l2,1 coefficients of the spherical harmonics
  6028. */
  6029. l21: Vector3;
  6030. /**
  6031. * The l2,2 coefficients of the spherical harmonics
  6032. */
  6033. l22: Vector3;
  6034. /**
  6035. * Adds a light to the spherical harmonics
  6036. * @param direction the direction of the light
  6037. * @param color the color of the light
  6038. * @param deltaSolidAngle the delta solid angle of the light
  6039. */
  6040. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6041. /**
  6042. * Scales the spherical harmonics by the given amount
  6043. * @param scale the amount to scale
  6044. */
  6045. scaleInPlace(scale: number): void;
  6046. /**
  6047. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6048. *
  6049. * ```
  6050. * E_lm = A_l * L_lm
  6051. * ```
  6052. *
  6053. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6054. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6055. * the scaling factors are given in equation 9.
  6056. */
  6057. convertIncidentRadianceToIrradiance(): void;
  6058. /**
  6059. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6060. *
  6061. * ```
  6062. * L = (1/pi) * E * rho
  6063. * ```
  6064. *
  6065. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6066. */
  6067. convertIrradianceToLambertianRadiance(): void;
  6068. /**
  6069. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6070. * required operations at run time.
  6071. *
  6072. * This is simply done by scaling back the SH with Ylm constants parameter.
  6073. * The trigonometric part being applied by the shader at run time.
  6074. */
  6075. preScaleForRendering(): void;
  6076. /**
  6077. * Constructs a spherical harmonics from an array.
  6078. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6079. * @returns the spherical harmonics
  6080. */
  6081. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6082. /**
  6083. * Gets the spherical harmonics from polynomial
  6084. * @param polynomial the spherical polynomial
  6085. * @returns the spherical harmonics
  6086. */
  6087. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6088. }
  6089. /**
  6090. * Class representing spherical polynomial coefficients to the 3rd degree
  6091. */
  6092. export class SphericalPolynomial {
  6093. private _harmonics;
  6094. /**
  6095. * The spherical harmonics used to create the polynomials.
  6096. */
  6097. readonly preScaledHarmonics: SphericalHarmonics;
  6098. /**
  6099. * The x coefficients of the spherical polynomial
  6100. */
  6101. x: Vector3;
  6102. /**
  6103. * The y coefficients of the spherical polynomial
  6104. */
  6105. y: Vector3;
  6106. /**
  6107. * The z coefficients of the spherical polynomial
  6108. */
  6109. z: Vector3;
  6110. /**
  6111. * The xx coefficients of the spherical polynomial
  6112. */
  6113. xx: Vector3;
  6114. /**
  6115. * The yy coefficients of the spherical polynomial
  6116. */
  6117. yy: Vector3;
  6118. /**
  6119. * The zz coefficients of the spherical polynomial
  6120. */
  6121. zz: Vector3;
  6122. /**
  6123. * The xy coefficients of the spherical polynomial
  6124. */
  6125. xy: Vector3;
  6126. /**
  6127. * The yz coefficients of the spherical polynomial
  6128. */
  6129. yz: Vector3;
  6130. /**
  6131. * The zx coefficients of the spherical polynomial
  6132. */
  6133. zx: Vector3;
  6134. /**
  6135. * Adds an ambient color to the spherical polynomial
  6136. * @param color the color to add
  6137. */
  6138. addAmbient(color: Color3): void;
  6139. /**
  6140. * Scales the spherical polynomial by the given amount
  6141. * @param scale the amount to scale
  6142. */
  6143. scaleInPlace(scale: number): void;
  6144. /**
  6145. * Gets the spherical polynomial from harmonics
  6146. * @param harmonics the spherical harmonics
  6147. * @returns the spherical polynomial
  6148. */
  6149. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6150. /**
  6151. * Constructs a spherical polynomial from an array.
  6152. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6153. * @returns the spherical polynomial
  6154. */
  6155. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6156. }
  6157. }
  6158. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6159. import { Nullable } from "babylonjs/types";
  6160. /**
  6161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6162. */
  6163. export interface CubeMapInfo {
  6164. /**
  6165. * The pixel array for the front face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. front: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the back face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. back: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the left face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. left: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The pixel array for the right face.
  6181. * This is stored in format, left to right, up to down format.
  6182. */
  6183. right: Nullable<ArrayBufferView>;
  6184. /**
  6185. * The pixel array for the up face.
  6186. * This is stored in format, left to right, up to down format.
  6187. */
  6188. up: Nullable<ArrayBufferView>;
  6189. /**
  6190. * The pixel array for the down face.
  6191. * This is stored in format, left to right, up to down format.
  6192. */
  6193. down: Nullable<ArrayBufferView>;
  6194. /**
  6195. * The size of the cubemap stored.
  6196. *
  6197. * Each faces will be size * size pixels.
  6198. */
  6199. size: number;
  6200. /**
  6201. * The format of the texture.
  6202. *
  6203. * RGBA, RGB.
  6204. */
  6205. format: number;
  6206. /**
  6207. * The type of the texture data.
  6208. *
  6209. * UNSIGNED_INT, FLOAT.
  6210. */
  6211. type: number;
  6212. /**
  6213. * Specifies whether the texture is in gamma space.
  6214. */
  6215. gammaSpace: boolean;
  6216. }
  6217. /**
  6218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6219. */
  6220. export class PanoramaToCubeMapTools {
  6221. private static FACE_FRONT;
  6222. private static FACE_BACK;
  6223. private static FACE_RIGHT;
  6224. private static FACE_LEFT;
  6225. private static FACE_DOWN;
  6226. private static FACE_UP;
  6227. /**
  6228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6229. *
  6230. * @param float32Array The source data.
  6231. * @param inputWidth The width of the input panorama.
  6232. * @param inputHeight The height of the input panorama.
  6233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6234. * @return The cubemap data
  6235. */
  6236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6237. private static CreateCubemapTexture;
  6238. private static CalcProjectionSpherical;
  6239. }
  6240. }
  6241. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6244. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6245. /**
  6246. * Helper class dealing with the extraction of spherical polynomial dataArray
  6247. * from a cube map.
  6248. */
  6249. export class CubeMapToSphericalPolynomialTools {
  6250. private static FileFaces;
  6251. /**
  6252. * Converts a texture to the according Spherical Polynomial data.
  6253. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6254. *
  6255. * @param texture The texture to extract the information from.
  6256. * @return The Spherical Polynomial data.
  6257. */
  6258. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6259. /**
  6260. * Converts a cubemap to the according Spherical Polynomial data.
  6261. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6262. *
  6263. * @param cubeInfo The Cube map to extract the information from.
  6264. * @return The Spherical Polynomial data.
  6265. */
  6266. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6267. }
  6268. }
  6269. declare module "babylonjs/Engines/engineStore" {
  6270. import { Nullable } from "babylonjs/types";
  6271. import { Engine } from "babylonjs/Engines/engine";
  6272. import { Scene } from "babylonjs/scene";
  6273. /**
  6274. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6275. * during the life time of the application.
  6276. */
  6277. export class EngineStore {
  6278. /** Gets the list of created engines */
  6279. static Instances: import("babylonjs/Engines/engine").Engine[];
  6280. /** @hidden */
  6281. static _LastCreatedScene: Nullable<Scene>;
  6282. /**
  6283. * Gets the latest created engine
  6284. */
  6285. static readonly LastCreatedEngine: Nullable<Engine>;
  6286. /**
  6287. * Gets the latest created scene
  6288. */
  6289. static readonly LastCreatedScene: Nullable<Scene>;
  6290. }
  6291. }
  6292. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6293. /**
  6294. * Define options used to create a render target texture
  6295. */
  6296. export class RenderTargetCreationOptions {
  6297. /**
  6298. * Specifies is mipmaps must be generated
  6299. */
  6300. generateMipMaps?: boolean;
  6301. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6302. generateDepthBuffer?: boolean;
  6303. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6304. generateStencilBuffer?: boolean;
  6305. /** Defines texture type (int by default) */
  6306. type?: number;
  6307. /** Defines sampling mode (trilinear by default) */
  6308. samplingMode?: number;
  6309. /** Defines format (RGBA by default) */
  6310. format?: number;
  6311. }
  6312. }
  6313. declare module "babylonjs/States/alphaCullingState" {
  6314. /**
  6315. * @hidden
  6316. **/
  6317. export class _AlphaState {
  6318. private _isAlphaBlendDirty;
  6319. private _isBlendFunctionParametersDirty;
  6320. private _isBlendEquationParametersDirty;
  6321. private _isBlendConstantsDirty;
  6322. private _alphaBlend;
  6323. private _blendFunctionParameters;
  6324. private _blendEquationParameters;
  6325. private _blendConstants;
  6326. /**
  6327. * Initializes the state.
  6328. */
  6329. constructor();
  6330. readonly isDirty: boolean;
  6331. alphaBlend: boolean;
  6332. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6333. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6334. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6335. reset(): void;
  6336. apply(gl: WebGLRenderingContext): void;
  6337. }
  6338. }
  6339. declare module "babylonjs/States/depthCullingState" {
  6340. import { Nullable } from "babylonjs/types";
  6341. /**
  6342. * @hidden
  6343. **/
  6344. export class _DepthCullingState {
  6345. private _isDepthTestDirty;
  6346. private _isDepthMaskDirty;
  6347. private _isDepthFuncDirty;
  6348. private _isCullFaceDirty;
  6349. private _isCullDirty;
  6350. private _isZOffsetDirty;
  6351. private _isFrontFaceDirty;
  6352. private _depthTest;
  6353. private _depthMask;
  6354. private _depthFunc;
  6355. private _cull;
  6356. private _cullFace;
  6357. private _zOffset;
  6358. private _frontFace;
  6359. /**
  6360. * Initializes the state.
  6361. */
  6362. constructor();
  6363. readonly isDirty: boolean;
  6364. zOffset: number;
  6365. cullFace: Nullable<number>;
  6366. cull: Nullable<boolean>;
  6367. depthFunc: Nullable<number>;
  6368. depthMask: boolean;
  6369. depthTest: boolean;
  6370. frontFace: Nullable<number>;
  6371. reset(): void;
  6372. apply(gl: WebGLRenderingContext): void;
  6373. }
  6374. }
  6375. declare module "babylonjs/States/stencilState" {
  6376. /**
  6377. * @hidden
  6378. **/
  6379. export class _StencilState {
  6380. /** 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 */
  6381. static readonly ALWAYS: number;
  6382. /** Passed to stencilOperation to specify that stencil value must be kept */
  6383. static readonly KEEP: number;
  6384. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6385. static readonly REPLACE: number;
  6386. private _isStencilTestDirty;
  6387. private _isStencilMaskDirty;
  6388. private _isStencilFuncDirty;
  6389. private _isStencilOpDirty;
  6390. private _stencilTest;
  6391. private _stencilMask;
  6392. private _stencilFunc;
  6393. private _stencilFuncRef;
  6394. private _stencilFuncMask;
  6395. private _stencilOpStencilFail;
  6396. private _stencilOpDepthFail;
  6397. private _stencilOpStencilDepthPass;
  6398. readonly isDirty: boolean;
  6399. stencilFunc: number;
  6400. stencilFuncRef: number;
  6401. stencilFuncMask: number;
  6402. stencilOpStencilFail: number;
  6403. stencilOpDepthFail: number;
  6404. stencilOpStencilDepthPass: number;
  6405. stencilMask: number;
  6406. stencilTest: boolean;
  6407. constructor();
  6408. reset(): void;
  6409. apply(gl: WebGLRenderingContext): void;
  6410. }
  6411. }
  6412. declare module "babylonjs/States/index" {
  6413. export * from "babylonjs/States/alphaCullingState";
  6414. export * from "babylonjs/States/depthCullingState";
  6415. export * from "babylonjs/States/stencilState";
  6416. }
  6417. declare module "babylonjs/Instrumentation/timeToken" {
  6418. import { Nullable } from "babylonjs/types";
  6419. /**
  6420. * @hidden
  6421. **/
  6422. export class _TimeToken {
  6423. _startTimeQuery: Nullable<WebGLQuery>;
  6424. _endTimeQuery: Nullable<WebGLQuery>;
  6425. _timeElapsedQuery: Nullable<WebGLQuery>;
  6426. _timeElapsedQueryEnded: boolean;
  6427. }
  6428. }
  6429. declare module "babylonjs/Materials/Textures/internalTexture" {
  6430. import { Observable } from "babylonjs/Misc/observable";
  6431. import { Nullable, int } from "babylonjs/types";
  6432. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6433. import { Engine } from "babylonjs/Engines/engine";
  6434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6435. /**
  6436. * Class used to store data associated with WebGL texture data for the engine
  6437. * This class should not be used directly
  6438. */
  6439. export class InternalTexture {
  6440. /** @hidden */
  6441. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6442. /**
  6443. * The source of the texture data is unknown
  6444. */
  6445. static DATASOURCE_UNKNOWN: number;
  6446. /**
  6447. * Texture data comes from an URL
  6448. */
  6449. static DATASOURCE_URL: number;
  6450. /**
  6451. * Texture data is only used for temporary storage
  6452. */
  6453. static DATASOURCE_TEMP: number;
  6454. /**
  6455. * Texture data comes from raw data (ArrayBuffer)
  6456. */
  6457. static DATASOURCE_RAW: number;
  6458. /**
  6459. * Texture content is dynamic (video or dynamic texture)
  6460. */
  6461. static DATASOURCE_DYNAMIC: number;
  6462. /**
  6463. * Texture content is generated by rendering to it
  6464. */
  6465. static DATASOURCE_RENDERTARGET: number;
  6466. /**
  6467. * Texture content is part of a multi render target process
  6468. */
  6469. static DATASOURCE_MULTIRENDERTARGET: number;
  6470. /**
  6471. * Texture data comes from a cube data file
  6472. */
  6473. static DATASOURCE_CUBE: number;
  6474. /**
  6475. * Texture data comes from a raw cube data
  6476. */
  6477. static DATASOURCE_CUBERAW: number;
  6478. /**
  6479. * Texture data come from a prefiltered cube data file
  6480. */
  6481. static DATASOURCE_CUBEPREFILTERED: number;
  6482. /**
  6483. * Texture content is raw 3D data
  6484. */
  6485. static DATASOURCE_RAW3D: number;
  6486. /**
  6487. * Texture content is a depth texture
  6488. */
  6489. static DATASOURCE_DEPTHTEXTURE: number;
  6490. /**
  6491. * Texture data comes from a raw cube data encoded with RGBD
  6492. */
  6493. static DATASOURCE_CUBERAW_RGBD: number;
  6494. /**
  6495. * Defines if the texture is ready
  6496. */
  6497. isReady: boolean;
  6498. /**
  6499. * Defines if the texture is a cube texture
  6500. */
  6501. isCube: boolean;
  6502. /**
  6503. * Defines if the texture contains 3D data
  6504. */
  6505. is3D: boolean;
  6506. /**
  6507. * Defines if the texture contains multiview data
  6508. */
  6509. isMultiview: boolean;
  6510. /**
  6511. * Gets the URL used to load this texture
  6512. */
  6513. url: string;
  6514. /**
  6515. * Gets the sampling mode of the texture
  6516. */
  6517. samplingMode: number;
  6518. /**
  6519. * Gets a boolean indicating if the texture needs mipmaps generation
  6520. */
  6521. generateMipMaps: boolean;
  6522. /**
  6523. * Gets the number of samples used by the texture (WebGL2+ only)
  6524. */
  6525. samples: number;
  6526. /**
  6527. * Gets the type of the texture (int, float...)
  6528. */
  6529. type: number;
  6530. /**
  6531. * Gets the format of the texture (RGB, RGBA...)
  6532. */
  6533. format: number;
  6534. /**
  6535. * Observable called when the texture is loaded
  6536. */
  6537. onLoadedObservable: Observable<InternalTexture>;
  6538. /**
  6539. * Gets the width of the texture
  6540. */
  6541. width: number;
  6542. /**
  6543. * Gets the height of the texture
  6544. */
  6545. height: number;
  6546. /**
  6547. * Gets the depth of the texture
  6548. */
  6549. depth: number;
  6550. /**
  6551. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6552. */
  6553. baseWidth: number;
  6554. /**
  6555. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseHeight: number;
  6558. /**
  6559. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseDepth: number;
  6562. /**
  6563. * Gets a boolean indicating if the texture is inverted on Y axis
  6564. */
  6565. invertY: boolean;
  6566. /** @hidden */
  6567. _invertVScale: boolean;
  6568. /** @hidden */
  6569. _associatedChannel: number;
  6570. /** @hidden */
  6571. _dataSource: number;
  6572. /** @hidden */
  6573. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6574. /** @hidden */
  6575. _bufferView: Nullable<ArrayBufferView>;
  6576. /** @hidden */
  6577. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6578. /** @hidden */
  6579. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6580. /** @hidden */
  6581. _size: number;
  6582. /** @hidden */
  6583. _extension: string;
  6584. /** @hidden */
  6585. _files: Nullable<string[]>;
  6586. /** @hidden */
  6587. _workingCanvas: Nullable<HTMLCanvasElement>;
  6588. /** @hidden */
  6589. _workingContext: Nullable<CanvasRenderingContext2D>;
  6590. /** @hidden */
  6591. _framebuffer: Nullable<WebGLFramebuffer>;
  6592. /** @hidden */
  6593. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6594. /** @hidden */
  6595. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _attachments: Nullable<number[]>;
  6600. /** @hidden */
  6601. _cachedCoordinatesMode: Nullable<number>;
  6602. /** @hidden */
  6603. _cachedWrapU: Nullable<number>;
  6604. /** @hidden */
  6605. _cachedWrapV: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapR: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6610. /** @hidden */
  6611. _isDisabled: boolean;
  6612. /** @hidden */
  6613. _compression: Nullable<string>;
  6614. /** @hidden */
  6615. _generateStencilBuffer: boolean;
  6616. /** @hidden */
  6617. _generateDepthBuffer: boolean;
  6618. /** @hidden */
  6619. _comparisonFunction: number;
  6620. /** @hidden */
  6621. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6622. /** @hidden */
  6623. _lodGenerationScale: number;
  6624. /** @hidden */
  6625. _lodGenerationOffset: number;
  6626. /** @hidden */
  6627. _colorTextureArray: Nullable<WebGLTexture>;
  6628. /** @hidden */
  6629. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6630. /** @hidden */
  6631. _lodTextureHigh: Nullable<BaseTexture>;
  6632. /** @hidden */
  6633. _lodTextureMid: Nullable<BaseTexture>;
  6634. /** @hidden */
  6635. _lodTextureLow: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _isRGBD: boolean;
  6638. /** @hidden */
  6639. _linearSpecularLOD: boolean;
  6640. /** @hidden */
  6641. _irradianceTexture: Nullable<BaseTexture>;
  6642. /** @hidden */
  6643. _webGLTexture: Nullable<WebGLTexture>;
  6644. /** @hidden */
  6645. _references: number;
  6646. private _engine;
  6647. /**
  6648. * Gets the Engine the texture belongs to.
  6649. * @returns The babylon engine
  6650. */
  6651. getEngine(): Engine;
  6652. /**
  6653. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6654. */
  6655. readonly dataSource: number;
  6656. /**
  6657. * Creates a new InternalTexture
  6658. * @param engine defines the engine to use
  6659. * @param dataSource defines the type of data that will be used
  6660. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6661. */
  6662. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6663. /**
  6664. * Increments the number of references (ie. the number of Texture that point to it)
  6665. */
  6666. incrementReferences(): void;
  6667. /**
  6668. * Change the size of the texture (not the size of the content)
  6669. * @param width defines the new width
  6670. * @param height defines the new height
  6671. * @param depth defines the new depth (1 by default)
  6672. */
  6673. updateSize(width: int, height: int, depth?: int): void;
  6674. /** @hidden */
  6675. _rebuild(): void;
  6676. /** @hidden */
  6677. _swapAndDie(target: InternalTexture): void;
  6678. /**
  6679. * Dispose the current allocated resources
  6680. */
  6681. dispose(): void;
  6682. }
  6683. }
  6684. declare module "babylonjs/Animations/easing" {
  6685. /**
  6686. * This represents the main contract an easing function should follow.
  6687. * Easing functions are used throughout the animation system.
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export interface IEasingFunction {
  6691. /**
  6692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6693. * of the easing function.
  6694. * The link below provides some of the most common examples of easing functions.
  6695. * @see https://easings.net/
  6696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6697. * @returns the corresponding value on the curve defined by the easing function
  6698. */
  6699. ease(gradient: number): number;
  6700. }
  6701. /**
  6702. * Base class used for every default easing function.
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class EasingFunction implements IEasingFunction {
  6706. /**
  6707. * Interpolation follows the mathematical formula associated with the easing function.
  6708. */
  6709. static readonly EASINGMODE_EASEIN: number;
  6710. /**
  6711. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEOUT: number;
  6714. /**
  6715. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6716. */
  6717. static readonly EASINGMODE_EASEINOUT: number;
  6718. private _easingMode;
  6719. /**
  6720. * Sets the easing mode of the current function.
  6721. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6722. */
  6723. setEasingMode(easingMode: number): void;
  6724. /**
  6725. * Gets the current easing mode.
  6726. * @returns the easing mode
  6727. */
  6728. getEasingMode(): number;
  6729. /**
  6730. * @hidden
  6731. */
  6732. easeInCore(gradient: number): number;
  6733. /**
  6734. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6735. * of the easing function.
  6736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6737. * @returns the corresponding value on the curve defined by the easing function
  6738. */
  6739. ease(gradient: number): number;
  6740. }
  6741. /**
  6742. * Easing function with a circle shape (see link below).
  6743. * @see https://easings.net/#easeInCirc
  6744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6745. */
  6746. export class CircleEase extends EasingFunction implements IEasingFunction {
  6747. /** @hidden */
  6748. easeInCore(gradient: number): number;
  6749. }
  6750. /**
  6751. * Easing function with a ease back shape (see link below).
  6752. * @see https://easings.net/#easeInBack
  6753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6754. */
  6755. export class BackEase extends EasingFunction implements IEasingFunction {
  6756. /** Defines the amplitude of the function */
  6757. amplitude: number;
  6758. /**
  6759. * Instantiates a back ease easing
  6760. * @see https://easings.net/#easeInBack
  6761. * @param amplitude Defines the amplitude of the function
  6762. */
  6763. constructor(
  6764. /** Defines the amplitude of the function */
  6765. amplitude?: number);
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with a bouncing shape (see link below).
  6771. * @see https://easings.net/#easeInBounce
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class BounceEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of bounces */
  6776. bounces: number;
  6777. /** Defines the amplitude of the bounce */
  6778. bounciness: number;
  6779. /**
  6780. * Instantiates a bounce easing
  6781. * @see https://easings.net/#easeInBounce
  6782. * @param bounces Defines the number of bounces
  6783. * @param bounciness Defines the amplitude of the bounce
  6784. */
  6785. constructor(
  6786. /** Defines the number of bounces */
  6787. bounces?: number,
  6788. /** Defines the amplitude of the bounce */
  6789. bounciness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with a power of 3 shape (see link below).
  6795. * @see https://easings.net/#easeInCubic
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class CubicEase extends EasingFunction implements IEasingFunction {
  6799. /** @hidden */
  6800. easeInCore(gradient: number): number;
  6801. }
  6802. /**
  6803. * Easing function with an elastic shape (see link below).
  6804. * @see https://easings.net/#easeInElastic
  6805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6806. */
  6807. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6808. /** Defines the number of oscillations*/
  6809. oscillations: number;
  6810. /** Defines the amplitude of the oscillations*/
  6811. springiness: number;
  6812. /**
  6813. * Instantiates an elastic easing function
  6814. * @see https://easings.net/#easeInElastic
  6815. * @param oscillations Defines the number of oscillations
  6816. * @param springiness Defines the amplitude of the oscillations
  6817. */
  6818. constructor(
  6819. /** Defines the number of oscillations*/
  6820. oscillations?: number,
  6821. /** Defines the amplitude of the oscillations*/
  6822. springiness?: number);
  6823. /** @hidden */
  6824. easeInCore(gradient: number): number;
  6825. }
  6826. /**
  6827. * Easing function with an exponential shape (see link below).
  6828. * @see https://easings.net/#easeInExpo
  6829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6830. */
  6831. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6832. /** Defines the exponent of the function */
  6833. exponent: number;
  6834. /**
  6835. * Instantiates an exponential easing function
  6836. * @see https://easings.net/#easeInExpo
  6837. * @param exponent Defines the exponent of the function
  6838. */
  6839. constructor(
  6840. /** Defines the exponent of the function */
  6841. exponent?: number);
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power shape (see link below).
  6847. * @see https://easings.net/#easeInQuad
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class PowerEase extends EasingFunction implements IEasingFunction {
  6851. /** Defines the power of the function */
  6852. power: number;
  6853. /**
  6854. * Instantiates an power base easing function
  6855. * @see https://easings.net/#easeInQuad
  6856. * @param power Defines the power of the function
  6857. */
  6858. constructor(
  6859. /** Defines the power of the function */
  6860. power?: number);
  6861. /** @hidden */
  6862. easeInCore(gradient: number): number;
  6863. }
  6864. /**
  6865. * Easing function with a power of 2 shape (see link below).
  6866. * @see https://easings.net/#easeInQuad
  6867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6868. */
  6869. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6870. /** @hidden */
  6871. easeInCore(gradient: number): number;
  6872. }
  6873. /**
  6874. * Easing function with a power of 4 shape (see link below).
  6875. * @see https://easings.net/#easeInQuart
  6876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6877. */
  6878. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6879. /** @hidden */
  6880. easeInCore(gradient: number): number;
  6881. }
  6882. /**
  6883. * Easing function with a power of 5 shape (see link below).
  6884. * @see https://easings.net/#easeInQuint
  6885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6886. */
  6887. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6888. /** @hidden */
  6889. easeInCore(gradient: number): number;
  6890. }
  6891. /**
  6892. * Easing function with a sin shape (see link below).
  6893. * @see https://easings.net/#easeInSine
  6894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6895. */
  6896. export class SineEase extends EasingFunction implements IEasingFunction {
  6897. /** @hidden */
  6898. easeInCore(gradient: number): number;
  6899. }
  6900. /**
  6901. * Easing function with a bezier shape (see link below).
  6902. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6904. */
  6905. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6906. /** Defines the x component of the start tangent in the bezier curve */
  6907. x1: number;
  6908. /** Defines the y component of the start tangent in the bezier curve */
  6909. y1: number;
  6910. /** Defines the x component of the end tangent in the bezier curve */
  6911. x2: number;
  6912. /** Defines the y component of the end tangent in the bezier curve */
  6913. y2: number;
  6914. /**
  6915. * Instantiates a bezier function
  6916. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6917. * @param x1 Defines the x component of the start tangent in the bezier curve
  6918. * @param y1 Defines the y component of the start tangent in the bezier curve
  6919. * @param x2 Defines the x component of the end tangent in the bezier curve
  6920. * @param y2 Defines the y component of the end tangent in the bezier curve
  6921. */
  6922. constructor(
  6923. /** Defines the x component of the start tangent in the bezier curve */
  6924. x1?: number,
  6925. /** Defines the y component of the start tangent in the bezier curve */
  6926. y1?: number,
  6927. /** Defines the x component of the end tangent in the bezier curve */
  6928. x2?: number,
  6929. /** Defines the y component of the end tangent in the bezier curve */
  6930. y2?: number);
  6931. /** @hidden */
  6932. easeInCore(gradient: number): number;
  6933. }
  6934. }
  6935. declare module "babylonjs/Animations/animationKey" {
  6936. /**
  6937. * Defines an interface which represents an animation key frame
  6938. */
  6939. export interface IAnimationKey {
  6940. /**
  6941. * Frame of the key frame
  6942. */
  6943. frame: number;
  6944. /**
  6945. * Value at the specifies key frame
  6946. */
  6947. value: any;
  6948. /**
  6949. * The input tangent for the cubic hermite spline
  6950. */
  6951. inTangent?: any;
  6952. /**
  6953. * The output tangent for the cubic hermite spline
  6954. */
  6955. outTangent?: any;
  6956. /**
  6957. * The animation interpolation type
  6958. */
  6959. interpolation?: AnimationKeyInterpolation;
  6960. }
  6961. /**
  6962. * Enum for the animation key frame interpolation type
  6963. */
  6964. export enum AnimationKeyInterpolation {
  6965. /**
  6966. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6967. */
  6968. STEP = 1
  6969. }
  6970. }
  6971. declare module "babylonjs/Animations/animationRange" {
  6972. /**
  6973. * Represents the range of an animation
  6974. */
  6975. export class AnimationRange {
  6976. /**The name of the animation range**/
  6977. name: string;
  6978. /**The starting frame of the animation */
  6979. from: number;
  6980. /**The ending frame of the animation*/
  6981. to: number;
  6982. /**
  6983. * Initializes the range of an animation
  6984. * @param name The name of the animation range
  6985. * @param from The starting frame of the animation
  6986. * @param to The ending frame of the animation
  6987. */
  6988. constructor(
  6989. /**The name of the animation range**/
  6990. name: string,
  6991. /**The starting frame of the animation */
  6992. from: number,
  6993. /**The ending frame of the animation*/
  6994. to: number);
  6995. /**
  6996. * Makes a copy of the animation range
  6997. * @returns A copy of the animation range
  6998. */
  6999. clone(): AnimationRange;
  7000. }
  7001. }
  7002. declare module "babylonjs/Animations/animationEvent" {
  7003. /**
  7004. * Composed of a frame, and an action function
  7005. */
  7006. export class AnimationEvent {
  7007. /** The frame for which the event is triggered **/
  7008. frame: number;
  7009. /** The event to perform when triggered **/
  7010. action: (currentFrame: number) => void;
  7011. /** Specifies if the event should be triggered only once**/
  7012. onlyOnce?: boolean | undefined;
  7013. /**
  7014. * Specifies if the animation event is done
  7015. */
  7016. isDone: boolean;
  7017. /**
  7018. * Initializes the animation event
  7019. * @param frame The frame for which the event is triggered
  7020. * @param action The event to perform when triggered
  7021. * @param onlyOnce Specifies if the event should be triggered only once
  7022. */
  7023. constructor(
  7024. /** The frame for which the event is triggered **/
  7025. frame: number,
  7026. /** The event to perform when triggered **/
  7027. action: (currentFrame: number) => void,
  7028. /** Specifies if the event should be triggered only once**/
  7029. onlyOnce?: boolean | undefined);
  7030. /** @hidden */
  7031. _clone(): AnimationEvent;
  7032. }
  7033. }
  7034. declare module "babylonjs/Behaviors/behavior" {
  7035. import { Nullable } from "babylonjs/types";
  7036. /**
  7037. * Interface used to define a behavior
  7038. */
  7039. export interface Behavior<T> {
  7040. /** gets or sets behavior's name */
  7041. name: string;
  7042. /**
  7043. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7044. */
  7045. init(): void;
  7046. /**
  7047. * Called when the behavior is attached to a target
  7048. * @param target defines the target where the behavior is attached to
  7049. */
  7050. attach(target: T): void;
  7051. /**
  7052. * Called when the behavior is detached from its target
  7053. */
  7054. detach(): void;
  7055. }
  7056. /**
  7057. * Interface implemented by classes supporting behaviors
  7058. */
  7059. export interface IBehaviorAware<T> {
  7060. /**
  7061. * Attach a behavior
  7062. * @param behavior defines the behavior to attach
  7063. * @returns the current host
  7064. */
  7065. addBehavior(behavior: Behavior<T>): T;
  7066. /**
  7067. * Remove a behavior from the current object
  7068. * @param behavior defines the behavior to detach
  7069. * @returns the current host
  7070. */
  7071. removeBehavior(behavior: Behavior<T>): T;
  7072. /**
  7073. * Gets a behavior using its name to search
  7074. * @param name defines the name to search
  7075. * @returns the behavior or null if not found
  7076. */
  7077. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7078. }
  7079. }
  7080. declare module "babylonjs/Collisions/intersectionInfo" {
  7081. import { Nullable } from "babylonjs/types";
  7082. /**
  7083. * @hidden
  7084. */
  7085. export class IntersectionInfo {
  7086. bu: Nullable<number>;
  7087. bv: Nullable<number>;
  7088. distance: number;
  7089. faceId: number;
  7090. subMeshId: number;
  7091. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7092. }
  7093. }
  7094. declare module "babylonjs/Culling/boundingSphere" {
  7095. import { DeepImmutable } from "babylonjs/types";
  7096. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7097. /**
  7098. * Class used to store bounding sphere information
  7099. */
  7100. export class BoundingSphere {
  7101. /**
  7102. * Gets the center of the bounding sphere in local space
  7103. */
  7104. readonly center: Vector3;
  7105. /**
  7106. * Radius of the bounding sphere in local space
  7107. */
  7108. radius: number;
  7109. /**
  7110. * Gets the center of the bounding sphere in world space
  7111. */
  7112. readonly centerWorld: Vector3;
  7113. /**
  7114. * Radius of the bounding sphere in world space
  7115. */
  7116. radiusWorld: number;
  7117. /**
  7118. * Gets the minimum vector in local space
  7119. */
  7120. readonly minimum: Vector3;
  7121. /**
  7122. * Gets the maximum vector in local space
  7123. */
  7124. readonly maximum: Vector3;
  7125. private _worldMatrix;
  7126. private static readonly TmpVector3;
  7127. /**
  7128. * Creates a new bounding sphere
  7129. * @param min defines the minimum vector (in local space)
  7130. * @param max defines the maximum vector (in local space)
  7131. * @param worldMatrix defines the new world matrix
  7132. */
  7133. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7134. /**
  7135. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7136. * @param min defines the new minimum vector (in local space)
  7137. * @param max defines the new maximum vector (in local space)
  7138. * @param worldMatrix defines the new world matrix
  7139. */
  7140. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7141. /**
  7142. * Scale the current bounding sphere by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding box
  7145. */
  7146. scale(factor: number): BoundingSphere;
  7147. /**
  7148. * Gets the world matrix of the bounding box
  7149. * @returns a matrix
  7150. */
  7151. getWorldMatrix(): DeepImmutable<Matrix>;
  7152. /** @hidden */
  7153. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7154. /**
  7155. * Tests if the bounding sphere is intersecting the frustum planes
  7156. * @param frustumPlanes defines the frustum planes to test
  7157. * @returns true if there is an intersection
  7158. */
  7159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7160. /**
  7161. * Tests if the bounding sphere center is in between the frustum planes.
  7162. * Used for optimistic fast inclusion.
  7163. * @param frustumPlanes defines the frustum planes to test
  7164. * @returns true if the sphere center is in between the frustum planes
  7165. */
  7166. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7167. /**
  7168. * Tests if a point is inside the bounding sphere
  7169. * @param point defines the point to test
  7170. * @returns true if the point is inside the bounding sphere
  7171. */
  7172. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7173. /**
  7174. * Checks if two sphere intersct
  7175. * @param sphere0 sphere 0
  7176. * @param sphere1 sphere 1
  7177. * @returns true if the speres intersect
  7178. */
  7179. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7180. }
  7181. }
  7182. declare module "babylonjs/Culling/boundingBox" {
  7183. import { DeepImmutable } from "babylonjs/types";
  7184. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7187. /**
  7188. * Class used to store bounding box information
  7189. */
  7190. export class BoundingBox implements ICullable {
  7191. /**
  7192. * Gets the 8 vectors representing the bounding box in local space
  7193. */
  7194. readonly vectors: Vector3[];
  7195. /**
  7196. * Gets the center of the bounding box in local space
  7197. */
  7198. readonly center: Vector3;
  7199. /**
  7200. * Gets the center of the bounding box in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Gets the extend size in local space
  7205. */
  7206. readonly extendSize: Vector3;
  7207. /**
  7208. * Gets the extend size in world space
  7209. */
  7210. readonly extendSizeWorld: Vector3;
  7211. /**
  7212. * Gets the OBB (object bounding box) directions
  7213. */
  7214. readonly directions: Vector3[];
  7215. /**
  7216. * Gets the 8 vectors representing the bounding box in world space
  7217. */
  7218. readonly vectorsWorld: Vector3[];
  7219. /**
  7220. * Gets the minimum vector in world space
  7221. */
  7222. readonly minimumWorld: Vector3;
  7223. /**
  7224. * Gets the maximum vector in world space
  7225. */
  7226. readonly maximumWorld: Vector3;
  7227. /**
  7228. * Gets the minimum vector in local space
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * Gets the maximum vector in local space
  7233. */
  7234. readonly maximum: Vector3;
  7235. private _worldMatrix;
  7236. private static readonly TmpVector3;
  7237. /**
  7238. * @hidden
  7239. */
  7240. _tag: number;
  7241. /**
  7242. * Creates a new bounding box
  7243. * @param min defines the minimum vector (in local space)
  7244. * @param max defines the maximum vector (in local space)
  7245. * @param worldMatrix defines the new world matrix
  7246. */
  7247. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7248. /**
  7249. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7250. * @param min defines the new minimum vector (in local space)
  7251. * @param max defines the new maximum vector (in local space)
  7252. * @param worldMatrix defines the new world matrix
  7253. */
  7254. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Scale the current bounding box by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding box
  7259. */
  7260. scale(factor: number): BoundingBox;
  7261. /**
  7262. * Gets the world matrix of the bounding box
  7263. * @returns a matrix
  7264. */
  7265. getWorldMatrix(): DeepImmutable<Matrix>;
  7266. /** @hidden */
  7267. _update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Tests if the bounding box is intersecting the frustum planes
  7270. * @param frustumPlanes defines the frustum planes to test
  7271. * @returns true if there is an intersection
  7272. */
  7273. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /**
  7275. * Tests if the bounding box is entirely inside the frustum planes
  7276. * @param frustumPlanes defines the frustum planes to test
  7277. * @returns true if there is an inclusion
  7278. */
  7279. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7280. /**
  7281. * Tests if a point is inside the bounding box
  7282. * @param point defines the point to test
  7283. * @returns true if the point is inside the bounding box
  7284. */
  7285. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7286. /**
  7287. * Tests if the bounding box intersects with a bounding sphere
  7288. * @param sphere defines the sphere to test
  7289. * @returns true if there is an intersection
  7290. */
  7291. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7292. /**
  7293. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7294. * @param min defines the min vector to use
  7295. * @param max defines the max vector to use
  7296. * @returns true if there is an intersection
  7297. */
  7298. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7299. /**
  7300. * Tests if two bounding boxes are intersections
  7301. * @param box0 defines the first box to test
  7302. * @param box1 defines the second box to test
  7303. * @returns true if there is an intersection
  7304. */
  7305. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7306. /**
  7307. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7308. * @param minPoint defines the minimum vector of the bounding box
  7309. * @param maxPoint defines the maximum vector of the bounding box
  7310. * @param sphereCenter defines the sphere center
  7311. * @param sphereRadius defines the sphere radius
  7312. * @returns true if there is an intersection
  7313. */
  7314. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7315. /**
  7316. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7317. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7318. * @param frustumPlanes defines the frustum planes to test
  7319. * @return true if there is an inclusion
  7320. */
  7321. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7322. /**
  7323. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7324. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7325. * @param frustumPlanes defines the frustum planes to test
  7326. * @return true if there is an intersection
  7327. */
  7328. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7329. }
  7330. }
  7331. declare module "babylonjs/Collisions/collider" {
  7332. import { Nullable, IndicesArray } from "babylonjs/types";
  7333. import { Vector3, Plane } from "babylonjs/Maths/math";
  7334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7335. /** @hidden */
  7336. export class Collider {
  7337. /** Define if a collision was found */
  7338. collisionFound: boolean;
  7339. /**
  7340. * Define last intersection point in local space
  7341. */
  7342. intersectionPoint: Vector3;
  7343. /**
  7344. * Define last collided mesh
  7345. */
  7346. collidedMesh: Nullable<AbstractMesh>;
  7347. private _collisionPoint;
  7348. private _planeIntersectionPoint;
  7349. private _tempVector;
  7350. private _tempVector2;
  7351. private _tempVector3;
  7352. private _tempVector4;
  7353. private _edge;
  7354. private _baseToVertex;
  7355. private _destinationPoint;
  7356. private _slidePlaneNormal;
  7357. private _displacementVector;
  7358. /** @hidden */
  7359. _radius: Vector3;
  7360. /** @hidden */
  7361. _retry: number;
  7362. private _velocity;
  7363. private _basePoint;
  7364. private _epsilon;
  7365. /** @hidden */
  7366. _velocityWorldLength: number;
  7367. /** @hidden */
  7368. _basePointWorld: Vector3;
  7369. private _velocityWorld;
  7370. private _normalizedVelocity;
  7371. /** @hidden */
  7372. _initialVelocity: Vector3;
  7373. /** @hidden */
  7374. _initialPosition: Vector3;
  7375. private _nearestDistance;
  7376. private _collisionMask;
  7377. collisionMask: number;
  7378. /**
  7379. * Gets the plane normal used to compute the sliding response (in local space)
  7380. */
  7381. readonly slidePlaneNormal: Vector3;
  7382. /** @hidden */
  7383. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7384. /** @hidden */
  7385. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7386. /** @hidden */
  7387. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7388. /** @hidden */
  7389. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7390. /** @hidden */
  7391. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7392. /** @hidden */
  7393. _getResponse(pos: Vector3, vel: Vector3): void;
  7394. }
  7395. }
  7396. declare module "babylonjs/Culling/boundingInfo" {
  7397. import { DeepImmutable } from "babylonjs/types";
  7398. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7399. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7400. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7401. import { Collider } from "babylonjs/Collisions/collider";
  7402. /**
  7403. * Interface for cullable objects
  7404. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7405. */
  7406. export interface ICullable {
  7407. /**
  7408. * Checks if the object or part of the object is in the frustum
  7409. * @param frustumPlanes Camera near/planes
  7410. * @returns true if the object is in frustum otherwise false
  7411. */
  7412. isInFrustum(frustumPlanes: Plane[]): boolean;
  7413. /**
  7414. * Checks if a cullable object (mesh...) is in the camera frustum
  7415. * Unlike isInFrustum this cheks the full bounding box
  7416. * @param frustumPlanes Camera near/planes
  7417. * @returns true if the object is in frustum otherwise false
  7418. */
  7419. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7420. }
  7421. /**
  7422. * Info for a bounding data of a mesh
  7423. */
  7424. export class BoundingInfo implements ICullable {
  7425. /**
  7426. * Bounding box for the mesh
  7427. */
  7428. readonly boundingBox: BoundingBox;
  7429. /**
  7430. * Bounding sphere for the mesh
  7431. */
  7432. readonly boundingSphere: BoundingSphere;
  7433. private _isLocked;
  7434. private static readonly TmpVector3;
  7435. /**
  7436. * Constructs bounding info
  7437. * @param minimum min vector of the bounding box/sphere
  7438. * @param maximum max vector of the bounding box/sphere
  7439. * @param worldMatrix defines the new world matrix
  7440. */
  7441. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7442. /**
  7443. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7444. * @param min defines the new minimum vector (in local space)
  7445. * @param max defines the new maximum vector (in local space)
  7446. * @param worldMatrix defines the new world matrix
  7447. */
  7448. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7449. /**
  7450. * min vector of the bounding box/sphere
  7451. */
  7452. readonly minimum: Vector3;
  7453. /**
  7454. * max vector of the bounding box/sphere
  7455. */
  7456. readonly maximum: Vector3;
  7457. /**
  7458. * If the info is locked and won't be updated to avoid perf overhead
  7459. */
  7460. isLocked: boolean;
  7461. /**
  7462. * Updates the bounding sphere and box
  7463. * @param world world matrix to be used to update
  7464. */
  7465. update(world: DeepImmutable<Matrix>): void;
  7466. /**
  7467. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7468. * @param center New center of the bounding info
  7469. * @param extend New extend of the bounding info
  7470. * @returns the current bounding info
  7471. */
  7472. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7473. /**
  7474. * Scale the current bounding info by applying a scale factor
  7475. * @param factor defines the scale factor to apply
  7476. * @returns the current bounding info
  7477. */
  7478. scale(factor: number): BoundingInfo;
  7479. /**
  7480. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7481. * @param frustumPlanes defines the frustum to test
  7482. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7483. * @returns true if the bounding info is in the frustum planes
  7484. */
  7485. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7486. /**
  7487. * Gets the world distance between the min and max points of the bounding box
  7488. */
  7489. readonly diagonalLength: number;
  7490. /**
  7491. * Checks if a cullable object (mesh...) is in the camera frustum
  7492. * Unlike isInFrustum this cheks the full bounding box
  7493. * @param frustumPlanes Camera near/planes
  7494. * @returns true if the object is in frustum otherwise false
  7495. */
  7496. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7497. /** @hidden */
  7498. _checkCollision(collider: Collider): boolean;
  7499. /**
  7500. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7501. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7502. * @param point the point to check intersection with
  7503. * @returns if the point intersects
  7504. */
  7505. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7506. /**
  7507. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7508. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7509. * @param boundingInfo the bounding info to check intersection with
  7510. * @param precise if the intersection should be done using OBB
  7511. * @returns if the bounding info intersects
  7512. */
  7513. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7514. }
  7515. }
  7516. declare module "babylonjs/Misc/smartArray" {
  7517. /**
  7518. * Defines an array and its length.
  7519. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7520. */
  7521. export interface ISmartArrayLike<T> {
  7522. /**
  7523. * The data of the array.
  7524. */
  7525. data: Array<T>;
  7526. /**
  7527. * The active length of the array.
  7528. */
  7529. length: number;
  7530. }
  7531. /**
  7532. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7533. */
  7534. export class SmartArray<T> implements ISmartArrayLike<T> {
  7535. /**
  7536. * The full set of data from the array.
  7537. */
  7538. data: Array<T>;
  7539. /**
  7540. * The active length of the array.
  7541. */
  7542. length: number;
  7543. protected _id: number;
  7544. /**
  7545. * Instantiates a Smart Array.
  7546. * @param capacity defines the default capacity of the array.
  7547. */
  7548. constructor(capacity: number);
  7549. /**
  7550. * Pushes a value at the end of the active data.
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Iterates over the active data and apply the lambda to them.
  7556. * @param func defines the action to apply on each value.
  7557. */
  7558. forEach(func: (content: T) => void): void;
  7559. /**
  7560. * Sorts the full sets of data.
  7561. * @param compareFn defines the comparison function to apply.
  7562. */
  7563. sort(compareFn: (a: T, b: T) => number): void;
  7564. /**
  7565. * Resets the active data to an empty array.
  7566. */
  7567. reset(): void;
  7568. /**
  7569. * Releases all the data from the array as well as the array.
  7570. */
  7571. dispose(): void;
  7572. /**
  7573. * Concats the active data with a given array.
  7574. * @param array defines the data to concatenate with.
  7575. */
  7576. concat(array: any): void;
  7577. /**
  7578. * Returns the position of a value in the active data.
  7579. * @param value defines the value to find the index for
  7580. * @returns the index if found in the active data otherwise -1
  7581. */
  7582. indexOf(value: T): number;
  7583. /**
  7584. * Returns whether an element is part of the active data.
  7585. * @param value defines the value to look for
  7586. * @returns true if found in the active data otherwise false
  7587. */
  7588. contains(value: T): boolean;
  7589. private static _GlobalId;
  7590. }
  7591. /**
  7592. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7593. * The data in this array can only be present once
  7594. */
  7595. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7596. private _duplicateId;
  7597. /**
  7598. * Pushes a value at the end of the active data.
  7599. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7600. * @param value defines the object to push in the array.
  7601. */
  7602. push(value: T): void;
  7603. /**
  7604. * Pushes a value at the end of the active data.
  7605. * If the data is already present, it won t be added again
  7606. * @param value defines the object to push in the array.
  7607. * @returns true if added false if it was already present
  7608. */
  7609. pushNoDuplicate(value: T): boolean;
  7610. /**
  7611. * Resets the active data to an empty array.
  7612. */
  7613. reset(): void;
  7614. /**
  7615. * Concats the active data with a given array.
  7616. * This ensures no dupplicate will be present in the result.
  7617. * @param array defines the data to concatenate with.
  7618. */
  7619. concatWithNoDuplicate(array: any): void;
  7620. }
  7621. }
  7622. declare module "babylonjs/Misc/iInspectable" {
  7623. /**
  7624. * Enum that determines the text-wrapping mode to use.
  7625. */
  7626. export enum InspectableType {
  7627. /**
  7628. * Checkbox for booleans
  7629. */
  7630. Checkbox = 0,
  7631. /**
  7632. * Sliders for numbers
  7633. */
  7634. Slider = 1,
  7635. /**
  7636. * Vector3
  7637. */
  7638. Vector3 = 2,
  7639. /**
  7640. * Quaternions
  7641. */
  7642. Quaternion = 3,
  7643. /**
  7644. * Color3
  7645. */
  7646. Color3 = 4
  7647. }
  7648. /**
  7649. * Interface used to define custom inspectable properties.
  7650. * This interface is used by the inspector to display custom property grids
  7651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7652. */
  7653. export interface IInspectable {
  7654. /**
  7655. * Gets the label to display
  7656. */
  7657. label: string;
  7658. /**
  7659. * Gets the name of the property to edit
  7660. */
  7661. propertyName: string;
  7662. /**
  7663. * Gets the type of the editor to use
  7664. */
  7665. type: InspectableType;
  7666. /**
  7667. * Gets the minimum value of the property when using in "slider" mode
  7668. */
  7669. min?: number;
  7670. /**
  7671. * Gets the maximum value of the property when using in "slider" mode
  7672. */
  7673. max?: number;
  7674. /**
  7675. * Gets the setp to use when using in "slider" mode
  7676. */
  7677. step?: number;
  7678. }
  7679. }
  7680. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7681. import { Nullable } from "babylonjs/types";
  7682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7683. /**
  7684. * This represents the required contract to create a new type of texture loader.
  7685. */
  7686. export interface IInternalTextureLoader {
  7687. /**
  7688. * Defines wether the loader supports cascade loading the different faces.
  7689. */
  7690. supportCascades: boolean;
  7691. /**
  7692. * This returns if the loader support the current file information.
  7693. * @param extension defines the file extension of the file being loaded
  7694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7695. * @param fallback defines the fallback internal texture if any
  7696. * @param isBase64 defines whether the texture is encoded as a base64
  7697. * @param isBuffer defines whether the texture data are stored as a buffer
  7698. * @returns true if the loader can load the specified file
  7699. */
  7700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7701. /**
  7702. * Transform the url before loading if required.
  7703. * @param rootUrl the url of the texture
  7704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7705. * @returns the transformed texture
  7706. */
  7707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7708. /**
  7709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7710. * @param rootUrl the url of the texture
  7711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7712. * @returns the fallback texture
  7713. */
  7714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7715. /**
  7716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7717. * @param data contains the texture data
  7718. * @param texture defines the BabylonJS internal texture
  7719. * @param createPolynomials will be true if polynomials have been requested
  7720. * @param onLoad defines the callback to trigger once the texture is ready
  7721. * @param onError defines the callback to trigger in case of error
  7722. */
  7723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7724. /**
  7725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7726. * @param data contains the texture data
  7727. * @param texture defines the BabylonJS internal texture
  7728. * @param callback defines the method to call once ready to upload
  7729. */
  7730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7731. }
  7732. }
  7733. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7735. import { Nullable } from "babylonjs/types";
  7736. import { Scene } from "babylonjs/scene";
  7737. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7738. module "babylonjs/Engines/engine" {
  7739. interface Engine {
  7740. /**
  7741. * Creates a depth stencil cube texture.
  7742. * This is only available in WebGL 2.
  7743. * @param size The size of face edge in the cube texture.
  7744. * @param options The options defining the cube texture.
  7745. * @returns The cube texture
  7746. */
  7747. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7748. /**
  7749. * Creates a cube texture
  7750. * @param rootUrl defines the url where the files to load is located
  7751. * @param scene defines the current scene
  7752. * @param files defines the list of files to load (1 per face)
  7753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7754. * @param onLoad defines an optional callback raised when the texture is loaded
  7755. * @param onError defines an optional callback raised if there is an issue to load the texture
  7756. * @param format defines the format of the data
  7757. * @param forcedExtension defines the extension to use to pick the right loader
  7758. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7761. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7762. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7763. * @returns the cube texture as an InternalTexture
  7764. */
  7765. 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;
  7766. /**
  7767. * Creates a cube texture
  7768. * @param rootUrl defines the url where the files to load is located
  7769. * @param scene defines the current scene
  7770. * @param files defines the list of files to load (1 per face)
  7771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7772. * @param onLoad defines an optional callback raised when the texture is loaded
  7773. * @param onError defines an optional callback raised if there is an issue to load the texture
  7774. * @param format defines the format of the data
  7775. * @param forcedExtension defines the extension to use to pick the right loader
  7776. * @returns the cube texture as an InternalTexture
  7777. */
  7778. 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;
  7779. /**
  7780. * Creates a cube texture
  7781. * @param rootUrl defines the url where the files to load is located
  7782. * @param scene defines the current scene
  7783. * @param files defines the list of files to load (1 per face)
  7784. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7785. * @param onLoad defines an optional callback raised when the texture is loaded
  7786. * @param onError defines an optional callback raised if there is an issue to load the texture
  7787. * @param format defines the format of the data
  7788. * @param forcedExtension defines the extension to use to pick the right loader
  7789. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7790. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7791. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7792. * @returns the cube texture as an InternalTexture
  7793. */
  7794. 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;
  7795. /** @hidden */
  7796. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7797. /** @hidden */
  7798. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7799. /** @hidden */
  7800. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7803. }
  7804. }
  7805. }
  7806. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7807. import { Nullable } from "babylonjs/types";
  7808. import { Scene } from "babylonjs/scene";
  7809. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7811. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7812. /**
  7813. * Class for creating a cube texture
  7814. */
  7815. export class CubeTexture extends BaseTexture {
  7816. private _delayedOnLoad;
  7817. /**
  7818. * The url of the texture
  7819. */
  7820. url: string;
  7821. /**
  7822. * Gets or sets the center of the bounding box associated with the cube texture.
  7823. * It must define where the camera used to render the texture was set
  7824. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7825. */
  7826. boundingBoxPosition: Vector3;
  7827. private _boundingBoxSize;
  7828. /**
  7829. * Gets or sets the size of the bounding box associated with the cube texture
  7830. * When defined, the cubemap will switch to local mode
  7831. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7832. * @example https://www.babylonjs-playground.com/#RNASML
  7833. */
  7834. /**
  7835. * Returns the bounding box size
  7836. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7837. */
  7838. boundingBoxSize: Vector3;
  7839. protected _rotationY: number;
  7840. /**
  7841. * Sets texture matrix rotation angle around Y axis in radians.
  7842. */
  7843. /**
  7844. * Gets texture matrix rotation angle around Y axis radians.
  7845. */
  7846. rotationY: number;
  7847. /**
  7848. * Are mip maps generated for this texture or not.
  7849. */
  7850. readonly noMipmap: boolean;
  7851. private _noMipmap;
  7852. private _files;
  7853. private _extensions;
  7854. private _textureMatrix;
  7855. private _format;
  7856. private _createPolynomials;
  7857. /** @hidden */
  7858. _prefiltered: boolean;
  7859. /**
  7860. * Creates a cube texture from an array of image urls
  7861. * @param files defines an array of image urls
  7862. * @param scene defines the hosting scene
  7863. * @param noMipmap specifies if mip maps are not used
  7864. * @returns a cube texture
  7865. */
  7866. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7867. /**
  7868. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7869. * @param url defines the url of the prefiltered texture
  7870. * @param scene defines the scene the texture is attached to
  7871. * @param forcedExtension defines the extension of the file if different from the url
  7872. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7873. * @return the prefiltered texture
  7874. */
  7875. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7876. /**
  7877. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7878. * as prefiltered data.
  7879. * @param rootUrl defines the url of the texture or the root name of the six images
  7880. * @param scene defines the scene the texture is attached to
  7881. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7882. * @param noMipmap defines if mipmaps should be created or not
  7883. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7884. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7885. * @param onError defines a callback triggered in case of error during load
  7886. * @param format defines the internal format to use for the texture once loaded
  7887. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7888. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7889. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7890. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7891. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7892. * @return the cube texture
  7893. */
  7894. 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);
  7895. /**
  7896. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7897. */
  7898. readonly isPrefiltered: boolean;
  7899. /**
  7900. * Get the current class name of the texture useful for serialization or dynamic coding.
  7901. * @returns "CubeTexture"
  7902. */
  7903. getClassName(): string;
  7904. /**
  7905. * Update the url (and optional buffer) of this texture if url was null during construction.
  7906. * @param url the url of the texture
  7907. * @param forcedExtension defines the extension to use
  7908. * @param onLoad callback called when the texture is loaded (defaults to null)
  7909. */
  7910. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7911. /**
  7912. * Delays loading of the cube texture
  7913. * @param forcedExtension defines the extension to use
  7914. */
  7915. delayLoad(forcedExtension?: string): void;
  7916. /**
  7917. * Returns the reflection texture matrix
  7918. * @returns the reflection texture matrix
  7919. */
  7920. getReflectionTextureMatrix(): Matrix;
  7921. /**
  7922. * Sets the reflection texture matrix
  7923. * @param value Reflection texture matrix
  7924. */
  7925. setReflectionTextureMatrix(value: Matrix): void;
  7926. /**
  7927. * Parses text to create a cube texture
  7928. * @param parsedTexture define the serialized text to read from
  7929. * @param scene defines the hosting scene
  7930. * @param rootUrl defines the root url of the cube texture
  7931. * @returns a cube texture
  7932. */
  7933. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7934. /**
  7935. * Makes a clone, or deep copy, of the cube texture
  7936. * @returns a new cube texture
  7937. */
  7938. clone(): CubeTexture;
  7939. }
  7940. }
  7941. declare module "babylonjs/Shaders/postprocess.vertex" {
  7942. /** @hidden */
  7943. export var postprocessVertexShader: {
  7944. name: string;
  7945. shader: string;
  7946. };
  7947. }
  7948. declare module "babylonjs/Cameras/targetCamera" {
  7949. import { Nullable } from "babylonjs/types";
  7950. import { Camera } from "babylonjs/Cameras/camera";
  7951. import { Scene } from "babylonjs/scene";
  7952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7953. /**
  7954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7955. * This is the base of the follow, arc rotate cameras and Free camera
  7956. * @see http://doc.babylonjs.com/features/cameras
  7957. */
  7958. export class TargetCamera extends Camera {
  7959. private static _RigCamTransformMatrix;
  7960. private static _TargetTransformMatrix;
  7961. private static _TargetFocalPoint;
  7962. /**
  7963. * Define the current direction the camera is moving to
  7964. */
  7965. cameraDirection: Vector3;
  7966. /**
  7967. * Define the current rotation the camera is rotating to
  7968. */
  7969. cameraRotation: Vector2;
  7970. /**
  7971. * When set, the up vector of the camera will be updated by the rotation of the camera
  7972. */
  7973. updateUpVectorFromRotation: boolean;
  7974. private _tmpQuaternion;
  7975. /**
  7976. * Define the current rotation of the camera
  7977. */
  7978. rotation: Vector3;
  7979. /**
  7980. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7981. */
  7982. rotationQuaternion: Quaternion;
  7983. /**
  7984. * Define the current speed of the camera
  7985. */
  7986. speed: number;
  7987. /**
  7988. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7989. * around all axis.
  7990. */
  7991. noRotationConstraint: boolean;
  7992. /**
  7993. * Define the current target of the camera as an object or a position.
  7994. */
  7995. lockedTarget: any;
  7996. /** @hidden */
  7997. _currentTarget: Vector3;
  7998. /** @hidden */
  7999. _initialFocalDistance: number;
  8000. /** @hidden */
  8001. _viewMatrix: Matrix;
  8002. /** @hidden */
  8003. _camMatrix: Matrix;
  8004. /** @hidden */
  8005. _cameraTransformMatrix: Matrix;
  8006. /** @hidden */
  8007. _cameraRotationMatrix: Matrix;
  8008. /** @hidden */
  8009. _referencePoint: Vector3;
  8010. /** @hidden */
  8011. _transformedReferencePoint: Vector3;
  8012. protected _globalCurrentTarget: Vector3;
  8013. protected _globalCurrentUpVector: Vector3;
  8014. /** @hidden */
  8015. _reset: () => void;
  8016. private _defaultUp;
  8017. /**
  8018. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8019. * This is the base of the follow, arc rotate cameras and Free camera
  8020. * @see http://doc.babylonjs.com/features/cameras
  8021. * @param name Defines the name of the camera in the scene
  8022. * @param position Defines the start position of the camera in the scene
  8023. * @param scene Defines the scene the camera belongs to
  8024. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8025. */
  8026. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8027. /**
  8028. * Gets the position in front of the camera at a given distance.
  8029. * @param distance The distance from the camera we want the position to be
  8030. * @returns the position
  8031. */
  8032. getFrontPosition(distance: number): Vector3;
  8033. /** @hidden */
  8034. _getLockedTargetPosition(): Nullable<Vector3>;
  8035. private _storedPosition;
  8036. private _storedRotation;
  8037. private _storedRotationQuaternion;
  8038. /**
  8039. * Store current camera state of the camera (fov, position, rotation, etc..)
  8040. * @returns the camera
  8041. */
  8042. storeState(): Camera;
  8043. /**
  8044. * Restored camera state. You must call storeState() first
  8045. * @returns whether it was successful or not
  8046. * @hidden
  8047. */
  8048. _restoreStateValues(): boolean;
  8049. /** @hidden */
  8050. _initCache(): void;
  8051. /** @hidden */
  8052. _updateCache(ignoreParentClass?: boolean): void;
  8053. /** @hidden */
  8054. _isSynchronizedViewMatrix(): boolean;
  8055. /** @hidden */
  8056. _computeLocalCameraSpeed(): number;
  8057. /**
  8058. * Defines the target the camera should look at.
  8059. * This will automatically adapt alpha beta and radius to fit within the new target.
  8060. * @param target Defines the new target as a Vector or a mesh
  8061. */
  8062. setTarget(target: Vector3): void;
  8063. /**
  8064. * Return the current target position of the camera. This value is expressed in local space.
  8065. * @returns the target position
  8066. */
  8067. getTarget(): Vector3;
  8068. /** @hidden */
  8069. _decideIfNeedsToMove(): boolean;
  8070. /** @hidden */
  8071. _updatePosition(): void;
  8072. /** @hidden */
  8073. _checkInputs(): void;
  8074. protected _updateCameraRotationMatrix(): void;
  8075. /**
  8076. * 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)
  8077. * @returns the current camera
  8078. */
  8079. private _rotateUpVectorWithCameraRotationMatrix;
  8080. private _cachedRotationZ;
  8081. private _cachedQuaternionRotationZ;
  8082. /** @hidden */
  8083. _getViewMatrix(): Matrix;
  8084. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8085. /**
  8086. * @hidden
  8087. */
  8088. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8089. /**
  8090. * @hidden
  8091. */
  8092. _updateRigCameras(): void;
  8093. private _getRigCamPositionAndTarget;
  8094. /**
  8095. * Gets the current object class name.
  8096. * @return the class name
  8097. */
  8098. getClassName(): string;
  8099. }
  8100. }
  8101. declare module "babylonjs/Cameras/cameraInputsManager" {
  8102. import { Nullable } from "babylonjs/types";
  8103. import { Camera } from "babylonjs/Cameras/camera";
  8104. /**
  8105. * @ignore
  8106. * This is a list of all the different input types that are available in the application.
  8107. * Fo instance: ArcRotateCameraGamepadInput...
  8108. */
  8109. export var CameraInputTypes: {};
  8110. /**
  8111. * This is the contract to implement in order to create a new input class.
  8112. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8113. */
  8114. export interface ICameraInput<TCamera extends Camera> {
  8115. /**
  8116. * Defines the camera the input is attached to.
  8117. */
  8118. camera: Nullable<TCamera>;
  8119. /**
  8120. * Gets the class name of the current intput.
  8121. * @returns the class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Get the friendly name associated with the input class.
  8126. * @returns the input friendly name
  8127. */
  8128. getSimpleName(): string;
  8129. /**
  8130. * Attach the input controls to a specific dom element to get the input from.
  8131. * @param element Defines the element the controls should be listened from
  8132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8133. */
  8134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8135. /**
  8136. * Detach the current controls from the specified dom element.
  8137. * @param element Defines the element to stop listening the inputs from
  8138. */
  8139. detachControl(element: Nullable<HTMLElement>): void;
  8140. /**
  8141. * Update the current camera state depending on the inputs that have been used this frame.
  8142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8143. */
  8144. checkInputs?: () => void;
  8145. }
  8146. /**
  8147. * Represents a map of input types to input instance or input index to input instance.
  8148. */
  8149. export interface CameraInputsMap<TCamera extends Camera> {
  8150. /**
  8151. * Accessor to the input by input type.
  8152. */
  8153. [name: string]: ICameraInput<TCamera>;
  8154. /**
  8155. * Accessor to the input by input index.
  8156. */
  8157. [idx: number]: ICameraInput<TCamera>;
  8158. }
  8159. /**
  8160. * This represents the input manager used within a camera.
  8161. * It helps dealing with all the different kind of input attached to a camera.
  8162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8163. */
  8164. export class CameraInputsManager<TCamera extends Camera> {
  8165. /**
  8166. * Defines the list of inputs attahed to the camera.
  8167. */
  8168. attached: CameraInputsMap<TCamera>;
  8169. /**
  8170. * Defines the dom element the camera is collecting inputs from.
  8171. * This is null if the controls have not been attached.
  8172. */
  8173. attachedElement: Nullable<HTMLElement>;
  8174. /**
  8175. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8176. */
  8177. noPreventDefault: boolean;
  8178. /**
  8179. * Defined the camera the input manager belongs to.
  8180. */
  8181. camera: TCamera;
  8182. /**
  8183. * Update the current camera state depending on the inputs that have been used this frame.
  8184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8185. */
  8186. checkInputs: () => void;
  8187. /**
  8188. * Instantiate a new Camera Input Manager.
  8189. * @param camera Defines the camera the input manager blongs to
  8190. */
  8191. constructor(camera: TCamera);
  8192. /**
  8193. * Add an input method to a camera
  8194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8195. * @param input camera input method
  8196. */
  8197. add(input: ICameraInput<TCamera>): void;
  8198. /**
  8199. * Remove a specific input method from a camera
  8200. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8201. * @param inputToRemove camera input method
  8202. */
  8203. remove(inputToRemove: ICameraInput<TCamera>): void;
  8204. /**
  8205. * Remove a specific input type from a camera
  8206. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8207. * @param inputType the type of the input to remove
  8208. */
  8209. removeByType(inputType: string): void;
  8210. private _addCheckInputs;
  8211. /**
  8212. * Attach the input controls to the currently attached dom element to listen the events from.
  8213. * @param input Defines the input to attach
  8214. */
  8215. attachInput(input: ICameraInput<TCamera>): void;
  8216. /**
  8217. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8218. * @param element Defines the dom element to collect the events from
  8219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8220. */
  8221. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8222. /**
  8223. * Detach the current manager inputs controls from a specific dom element.
  8224. * @param element Defines the dom element to collect the events from
  8225. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8226. */
  8227. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8228. /**
  8229. * Rebuild the dynamic inputCheck function from the current list of
  8230. * defined inputs in the manager.
  8231. */
  8232. rebuildInputCheck(): void;
  8233. /**
  8234. * Remove all attached input methods from a camera
  8235. */
  8236. clear(): void;
  8237. /**
  8238. * Serialize the current input manager attached to a camera.
  8239. * This ensures than once parsed,
  8240. * the input associated to the camera will be identical to the current ones
  8241. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8242. */
  8243. serialize(serializedCamera: any): void;
  8244. /**
  8245. * Parses an input manager serialized JSON to restore the previous list of inputs
  8246. * and states associated to a camera.
  8247. * @param parsedCamera Defines the JSON to parse
  8248. */
  8249. parse(parsedCamera: any): void;
  8250. }
  8251. }
  8252. declare module "babylonjs/Events/keyboardEvents" {
  8253. /**
  8254. * Gather the list of keyboard event types as constants.
  8255. */
  8256. export class KeyboardEventTypes {
  8257. /**
  8258. * The keydown event is fired when a key becomes active (pressed).
  8259. */
  8260. static readonly KEYDOWN: number;
  8261. /**
  8262. * The keyup event is fired when a key has been released.
  8263. */
  8264. static readonly KEYUP: number;
  8265. }
  8266. /**
  8267. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8268. */
  8269. export class KeyboardInfo {
  8270. /**
  8271. * Defines the type of event (KeyboardEventTypes)
  8272. */
  8273. type: number;
  8274. /**
  8275. * Defines the related dom event
  8276. */
  8277. event: KeyboardEvent;
  8278. /**
  8279. * Instantiates a new keyboard info.
  8280. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8281. * @param type Defines the type of event (KeyboardEventTypes)
  8282. * @param event Defines the related dom event
  8283. */
  8284. constructor(
  8285. /**
  8286. * Defines the type of event (KeyboardEventTypes)
  8287. */
  8288. type: number,
  8289. /**
  8290. * Defines the related dom event
  8291. */
  8292. event: KeyboardEvent);
  8293. }
  8294. /**
  8295. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8296. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8297. */
  8298. export class KeyboardInfoPre extends KeyboardInfo {
  8299. /**
  8300. * Defines the type of event (KeyboardEventTypes)
  8301. */
  8302. type: number;
  8303. /**
  8304. * Defines the related dom event
  8305. */
  8306. event: KeyboardEvent;
  8307. /**
  8308. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8309. */
  8310. skipOnPointerObservable: boolean;
  8311. /**
  8312. * Instantiates a new keyboard pre info.
  8313. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8314. * @param type Defines the type of event (KeyboardEventTypes)
  8315. * @param event Defines the related dom event
  8316. */
  8317. constructor(
  8318. /**
  8319. * Defines the type of event (KeyboardEventTypes)
  8320. */
  8321. type: number,
  8322. /**
  8323. * Defines the related dom event
  8324. */
  8325. event: KeyboardEvent);
  8326. }
  8327. }
  8328. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8329. import { Nullable } from "babylonjs/types";
  8330. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8331. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8332. /**
  8333. * Manage the keyboard inputs to control the movement of a free camera.
  8334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8335. */
  8336. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8337. /**
  8338. * Defines the camera the input is attached to.
  8339. */
  8340. camera: FreeCamera;
  8341. /**
  8342. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8343. */
  8344. keysUp: number[];
  8345. /**
  8346. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8347. */
  8348. keysDown: number[];
  8349. /**
  8350. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8351. */
  8352. keysLeft: number[];
  8353. /**
  8354. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8355. */
  8356. keysRight: number[];
  8357. private _keys;
  8358. private _onCanvasBlurObserver;
  8359. private _onKeyboardObserver;
  8360. private _engine;
  8361. private _scene;
  8362. /**
  8363. * Attach the input controls to a specific dom element to get the input from.
  8364. * @param element Defines the element the controls should be listened from
  8365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8366. */
  8367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8368. /**
  8369. * Detach the current controls from the specified dom element.
  8370. * @param element Defines the element to stop listening the inputs from
  8371. */
  8372. detachControl(element: Nullable<HTMLElement>): void;
  8373. /**
  8374. * Update the current camera state depending on the inputs that have been used this frame.
  8375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8376. */
  8377. checkInputs(): void;
  8378. /**
  8379. * Gets the class name of the current intput.
  8380. * @returns the class name
  8381. */
  8382. getClassName(): string;
  8383. /** @hidden */
  8384. _onLostFocus(): void;
  8385. /**
  8386. * Get the friendly name associated with the input class.
  8387. * @returns the input friendly name
  8388. */
  8389. getSimpleName(): string;
  8390. }
  8391. }
  8392. declare module "babylonjs/Materials/multiMaterial" {
  8393. import { Nullable } from "babylonjs/types";
  8394. import { Scene } from "babylonjs/scene";
  8395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8396. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. import { Material } from "babylonjs/Materials/material";
  8399. /**
  8400. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8401. * separate meshes. This can be use to improve performances.
  8402. * @see http://doc.babylonjs.com/how_to/multi_materials
  8403. */
  8404. export class MultiMaterial extends Material {
  8405. private _subMaterials;
  8406. /**
  8407. * Gets or Sets the list of Materials used within the multi material.
  8408. * They need to be ordered according to the submeshes order in the associated mesh
  8409. */
  8410. subMaterials: Nullable<Material>[];
  8411. /**
  8412. * Function used to align with Node.getChildren()
  8413. * @returns the list of Materials used within the multi material
  8414. */
  8415. getChildren(): Nullable<Material>[];
  8416. /**
  8417. * Instantiates a new Multi Material
  8418. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8419. * separate meshes. This can be use to improve performances.
  8420. * @see http://doc.babylonjs.com/how_to/multi_materials
  8421. * @param name Define the name in the scene
  8422. * @param scene Define the scene the material belongs to
  8423. */
  8424. constructor(name: string, scene: Scene);
  8425. private _hookArray;
  8426. /**
  8427. * Get one of the submaterial by its index in the submaterials array
  8428. * @param index The index to look the sub material at
  8429. * @returns The Material if the index has been defined
  8430. */
  8431. getSubMaterial(index: number): Nullable<Material>;
  8432. /**
  8433. * Get the list of active textures for the whole sub materials list.
  8434. * @returns All the textures that will be used during the rendering
  8435. */
  8436. getActiveTextures(): BaseTexture[];
  8437. /**
  8438. * Gets the current class name of the material e.g. "MultiMaterial"
  8439. * Mainly use in serialization.
  8440. * @returns the class name
  8441. */
  8442. getClassName(): string;
  8443. /**
  8444. * Checks if the material is ready to render the requested sub mesh
  8445. * @param mesh Define the mesh the submesh belongs to
  8446. * @param subMesh Define the sub mesh to look readyness for
  8447. * @param useInstances Define whether or not the material is used with instances
  8448. * @returns true if ready, otherwise false
  8449. */
  8450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8451. /**
  8452. * Clones the current material and its related sub materials
  8453. * @param name Define the name of the newly cloned material
  8454. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8455. * @returns the cloned material
  8456. */
  8457. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8458. /**
  8459. * Serializes the materials into a JSON representation.
  8460. * @returns the JSON representation
  8461. */
  8462. serialize(): any;
  8463. /**
  8464. * Dispose the material and release its associated resources
  8465. * @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)
  8466. * @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)
  8467. * @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)
  8468. */
  8469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8470. /**
  8471. * Creates a MultiMaterial from parsed MultiMaterial data.
  8472. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8473. * @param scene defines the hosting scene
  8474. * @returns a new MultiMaterial
  8475. */
  8476. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8477. }
  8478. }
  8479. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8480. /**
  8481. * Class used to represent data loading progression
  8482. */
  8483. export class SceneLoaderFlags {
  8484. private static _ForceFullSceneLoadingForIncremental;
  8485. private static _ShowLoadingScreen;
  8486. private static _CleanBoneMatrixWeights;
  8487. private static _loggingLevel;
  8488. /**
  8489. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8490. */
  8491. static ForceFullSceneLoadingForIncremental: boolean;
  8492. /**
  8493. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8494. */
  8495. static ShowLoadingScreen: boolean;
  8496. /**
  8497. * Defines the current logging level (while loading the scene)
  8498. * @ignorenaming
  8499. */
  8500. static loggingLevel: number;
  8501. /**
  8502. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8503. */
  8504. static CleanBoneMatrixWeights: boolean;
  8505. }
  8506. }
  8507. declare module "babylonjs/Meshes/transformNode" {
  8508. import { DeepImmutable } from "babylonjs/types";
  8509. import { Observable } from "babylonjs/Misc/observable";
  8510. import { Nullable } from "babylonjs/types";
  8511. import { Camera } from "babylonjs/Cameras/camera";
  8512. import { Scene } from "babylonjs/scene";
  8513. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8514. import { Node } from "babylonjs/node";
  8515. import { Bone } from "babylonjs/Bones/bone";
  8516. /**
  8517. * 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.
  8518. * @see https://doc.babylonjs.com/how_to/transformnode
  8519. */
  8520. export class TransformNode extends Node {
  8521. /**
  8522. * Object will not rotate to face the camera
  8523. */
  8524. static BILLBOARDMODE_NONE: number;
  8525. /**
  8526. * Object will rotate to face the camera but only on the x axis
  8527. */
  8528. static BILLBOARDMODE_X: number;
  8529. /**
  8530. * Object will rotate to face the camera but only on the y axis
  8531. */
  8532. static BILLBOARDMODE_Y: number;
  8533. /**
  8534. * Object will rotate to face the camera but only on the z axis
  8535. */
  8536. static BILLBOARDMODE_Z: number;
  8537. /**
  8538. * Object will rotate to face the camera
  8539. */
  8540. static BILLBOARDMODE_ALL: number;
  8541. private _forward;
  8542. private _forwardInverted;
  8543. private _up;
  8544. private _right;
  8545. private _rightInverted;
  8546. private _position;
  8547. private _rotation;
  8548. private _rotationQuaternion;
  8549. protected _scaling: Vector3;
  8550. protected _isDirty: boolean;
  8551. private _transformToBoneReferal;
  8552. private _billboardMode;
  8553. /**
  8554. * Gets or sets the billboard mode. Default is 0.
  8555. *
  8556. * | Value | Type | Description |
  8557. * | --- | --- | --- |
  8558. * | 0 | BILLBOARDMODE_NONE | |
  8559. * | 1 | BILLBOARDMODE_X | |
  8560. * | 2 | BILLBOARDMODE_Y | |
  8561. * | 4 | BILLBOARDMODE_Z | |
  8562. * | 7 | BILLBOARDMODE_ALL | |
  8563. *
  8564. */
  8565. billboardMode: number;
  8566. private _preserveParentRotationForBillboard;
  8567. /**
  8568. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8569. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8570. */
  8571. preserveParentRotationForBillboard: boolean;
  8572. /**
  8573. * 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
  8574. */
  8575. scalingDeterminant: number;
  8576. private _infiniteDistance;
  8577. /**
  8578. * Gets or sets the distance of the object to max, often used by skybox
  8579. */
  8580. infiniteDistance: boolean;
  8581. /**
  8582. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8583. * By default the system will update normals to compensate
  8584. */
  8585. ignoreNonUniformScaling: boolean;
  8586. /**
  8587. * 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
  8588. */
  8589. reIntegrateRotationIntoRotationQuaternion: boolean;
  8590. /** @hidden */
  8591. _poseMatrix: Nullable<Matrix>;
  8592. /** @hidden */
  8593. _localMatrix: Matrix;
  8594. private _usePivotMatrix;
  8595. private _absolutePosition;
  8596. private _pivotMatrix;
  8597. private _pivotMatrixInverse;
  8598. protected _postMultiplyPivotMatrix: boolean;
  8599. protected _isWorldMatrixFrozen: boolean;
  8600. /** @hidden */
  8601. _indexInSceneTransformNodesArray: number;
  8602. /**
  8603. * An event triggered after the world matrix is updated
  8604. */
  8605. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8606. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8607. /**
  8608. * Gets a string identifying the name of the class
  8609. * @returns "TransformNode" string
  8610. */
  8611. getClassName(): string;
  8612. /**
  8613. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8614. */
  8615. position: Vector3;
  8616. /**
  8617. * 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)).
  8618. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8619. */
  8620. rotation: Vector3;
  8621. /**
  8622. * 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)).
  8623. */
  8624. scaling: Vector3;
  8625. /**
  8626. * 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).
  8627. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8628. */
  8629. rotationQuaternion: Nullable<Quaternion>;
  8630. /**
  8631. * The forward direction of that transform in world space.
  8632. */
  8633. readonly forward: Vector3;
  8634. /**
  8635. * The up direction of that transform in world space.
  8636. */
  8637. readonly up: Vector3;
  8638. /**
  8639. * The right direction of that transform in world space.
  8640. */
  8641. readonly right: Vector3;
  8642. /**
  8643. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8644. * @param matrix the matrix to copy the pose from
  8645. * @returns this TransformNode.
  8646. */
  8647. updatePoseMatrix(matrix: Matrix): TransformNode;
  8648. /**
  8649. * Returns the mesh Pose matrix.
  8650. * @returns the pose matrix
  8651. */
  8652. getPoseMatrix(): Matrix;
  8653. /** @hidden */
  8654. _isSynchronized(): boolean;
  8655. /** @hidden */
  8656. _initCache(): void;
  8657. /**
  8658. * Flag the transform node as dirty (Forcing it to update everything)
  8659. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8660. * @returns this transform node
  8661. */
  8662. markAsDirty(property: string): TransformNode;
  8663. /**
  8664. * Returns the current mesh absolute position.
  8665. * Returns a Vector3.
  8666. */
  8667. readonly absolutePosition: Vector3;
  8668. /**
  8669. * Sets a new matrix to apply before all other transformation
  8670. * @param matrix defines the transform matrix
  8671. * @returns the current TransformNode
  8672. */
  8673. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8674. /**
  8675. * Sets a new pivot matrix to the current node
  8676. * @param matrix defines the new pivot matrix to use
  8677. * @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
  8678. * @returns the current TransformNode
  8679. */
  8680. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8681. /**
  8682. * Returns the mesh pivot matrix.
  8683. * Default : Identity.
  8684. * @returns the matrix
  8685. */
  8686. getPivotMatrix(): Matrix;
  8687. /**
  8688. * Prevents the World matrix to be computed any longer.
  8689. * @returns the TransformNode.
  8690. */
  8691. freezeWorldMatrix(): TransformNode;
  8692. /**
  8693. * Allows back the World matrix computation.
  8694. * @returns the TransformNode.
  8695. */
  8696. unfreezeWorldMatrix(): this;
  8697. /**
  8698. * True if the World matrix has been frozen.
  8699. */
  8700. readonly isWorldMatrixFrozen: boolean;
  8701. /**
  8702. * Retuns the mesh absolute position in the World.
  8703. * @returns a Vector3.
  8704. */
  8705. getAbsolutePosition(): Vector3;
  8706. /**
  8707. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8708. * @param absolutePosition the absolute position to set
  8709. * @returns the TransformNode.
  8710. */
  8711. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8712. /**
  8713. * Sets the mesh position in its local space.
  8714. * @param vector3 the position to set in localspace
  8715. * @returns the TransformNode.
  8716. */
  8717. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8718. /**
  8719. * Returns the mesh position in the local space from the current World matrix values.
  8720. * @returns a new Vector3.
  8721. */
  8722. getPositionExpressedInLocalSpace(): Vector3;
  8723. /**
  8724. * Translates the mesh along the passed Vector3 in its local space.
  8725. * @param vector3 the distance to translate in localspace
  8726. * @returns the TransformNode.
  8727. */
  8728. locallyTranslate(vector3: Vector3): TransformNode;
  8729. private static _lookAtVectorCache;
  8730. /**
  8731. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8732. * @param targetPoint the position (must be in same space as current mesh) to look at
  8733. * @param yawCor optional yaw (y-axis) correction in radians
  8734. * @param pitchCor optional pitch (x-axis) correction in radians
  8735. * @param rollCor optional roll (z-axis) correction in radians
  8736. * @param space the choosen space of the target
  8737. * @returns the TransformNode.
  8738. */
  8739. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8740. /**
  8741. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8742. * This Vector3 is expressed in the World space.
  8743. * @param localAxis axis to rotate
  8744. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8745. */
  8746. getDirection(localAxis: Vector3): Vector3;
  8747. /**
  8748. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8749. * localAxis is expressed in the mesh local space.
  8750. * result is computed in the Wordl space from the mesh World matrix.
  8751. * @param localAxis axis to rotate
  8752. * @param result the resulting transformnode
  8753. * @returns this TransformNode.
  8754. */
  8755. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8756. /**
  8757. * Sets this transform node rotation to the given local axis.
  8758. * @param localAxis the axis in local space
  8759. * @param yawCor optional yaw (y-axis) correction in radians
  8760. * @param pitchCor optional pitch (x-axis) correction in radians
  8761. * @param rollCor optional roll (z-axis) correction in radians
  8762. * @returns this TransformNode
  8763. */
  8764. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8765. /**
  8766. * Sets a new pivot point to the current node
  8767. * @param point defines the new pivot point to use
  8768. * @param space defines if the point is in world or local space (local by default)
  8769. * @returns the current TransformNode
  8770. */
  8771. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8772. /**
  8773. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8774. * @returns the pivot point
  8775. */
  8776. getPivotPoint(): Vector3;
  8777. /**
  8778. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8779. * @param result the vector3 to store the result
  8780. * @returns this TransformNode.
  8781. */
  8782. getPivotPointToRef(result: Vector3): TransformNode;
  8783. /**
  8784. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8785. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8786. */
  8787. getAbsolutePivotPoint(): Vector3;
  8788. /**
  8789. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8790. * @param result vector3 to store the result
  8791. * @returns this TransformNode.
  8792. */
  8793. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8794. /**
  8795. * Defines the passed node as the parent of the current node.
  8796. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8797. * @see https://doc.babylonjs.com/how_to/parenting
  8798. * @param node the node ot set as the parent
  8799. * @returns this TransformNode.
  8800. */
  8801. setParent(node: Nullable<Node>): TransformNode;
  8802. private _nonUniformScaling;
  8803. /**
  8804. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8805. */
  8806. readonly nonUniformScaling: boolean;
  8807. /** @hidden */
  8808. _updateNonUniformScalingState(value: boolean): boolean;
  8809. /**
  8810. * Attach the current TransformNode to another TransformNode associated with a bone
  8811. * @param bone Bone affecting the TransformNode
  8812. * @param affectedTransformNode TransformNode associated with the bone
  8813. * @returns this object
  8814. */
  8815. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8816. /**
  8817. * Detach the transform node if its associated with a bone
  8818. * @returns this object
  8819. */
  8820. detachFromBone(): TransformNode;
  8821. private static _rotationAxisCache;
  8822. /**
  8823. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8824. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8825. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8826. * The passed axis is also normalized.
  8827. * @param axis the axis to rotate around
  8828. * @param amount the amount to rotate in radians
  8829. * @param space Space to rotate in (Default: local)
  8830. * @returns the TransformNode.
  8831. */
  8832. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8833. /**
  8834. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8835. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8836. * The passed axis is also normalized. .
  8837. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8838. * @param point the point to rotate around
  8839. * @param axis the axis to rotate around
  8840. * @param amount the amount to rotate in radians
  8841. * @returns the TransformNode
  8842. */
  8843. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8844. /**
  8845. * Translates the mesh along the axis vector for the passed distance in the given space.
  8846. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8847. * @param axis the axis to translate in
  8848. * @param distance the distance to translate
  8849. * @param space Space to rotate in (Default: local)
  8850. * @returns the TransformNode.
  8851. */
  8852. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8853. /**
  8854. * Adds a rotation step to the mesh current rotation.
  8855. * x, y, z are Euler angles expressed in radians.
  8856. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8857. * This means this rotation is made in the mesh local space only.
  8858. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8859. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8860. * ```javascript
  8861. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8862. * ```
  8863. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8864. * 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.
  8865. * @param x Rotation to add
  8866. * @param y Rotation to add
  8867. * @param z Rotation to add
  8868. * @returns the TransformNode.
  8869. */
  8870. addRotation(x: number, y: number, z: number): TransformNode;
  8871. /**
  8872. * @hidden
  8873. */
  8874. protected _getEffectiveParent(): Nullable<Node>;
  8875. /**
  8876. * Computes the world matrix of the node
  8877. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8878. * @returns the world matrix
  8879. */
  8880. computeWorldMatrix(force?: boolean): Matrix;
  8881. protected _afterComputeWorldMatrix(): void;
  8882. /**
  8883. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8884. * @param func callback function to add
  8885. *
  8886. * @returns the TransformNode.
  8887. */
  8888. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8889. /**
  8890. * Removes a registered callback function.
  8891. * @param func callback function to remove
  8892. * @returns the TransformNode.
  8893. */
  8894. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8895. /**
  8896. * Gets the position of the current mesh in camera space
  8897. * @param camera defines the camera to use
  8898. * @returns a position
  8899. */
  8900. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8901. /**
  8902. * Returns the distance from the mesh to the active camera
  8903. * @param camera defines the camera to use
  8904. * @returns the distance
  8905. */
  8906. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8907. /**
  8908. * Clone the current transform node
  8909. * @param name Name of the new clone
  8910. * @param newParent New parent for the clone
  8911. * @param doNotCloneChildren Do not clone children hierarchy
  8912. * @returns the new transform node
  8913. */
  8914. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8915. /**
  8916. * Serializes the objects information.
  8917. * @param currentSerializationObject defines the object to serialize in
  8918. * @returns the serialized object
  8919. */
  8920. serialize(currentSerializationObject?: any): any;
  8921. /**
  8922. * Returns a new TransformNode object parsed from the source provided.
  8923. * @param parsedTransformNode is the source.
  8924. * @param scene the scne the object belongs to
  8925. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8926. * @returns a new TransformNode object parsed from the source provided.
  8927. */
  8928. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8929. /**
  8930. * Get all child-transformNodes of this node
  8931. * @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
  8932. * @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
  8933. * @returns an array of TransformNode
  8934. */
  8935. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8936. /**
  8937. * Releases resources associated with this transform node.
  8938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8940. */
  8941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8942. }
  8943. }
  8944. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8945. /**
  8946. * Class used to override all child animations of a given target
  8947. */
  8948. export class AnimationPropertiesOverride {
  8949. /**
  8950. * Gets or sets a value indicating if animation blending must be used
  8951. */
  8952. enableBlending: boolean;
  8953. /**
  8954. * Gets or sets the blending speed to use when enableBlending is true
  8955. */
  8956. blendingSpeed: number;
  8957. /**
  8958. * Gets or sets the default loop mode to use
  8959. */
  8960. loopMode: number;
  8961. }
  8962. }
  8963. declare module "babylonjs/Bones/bone" {
  8964. import { Skeleton } from "babylonjs/Bones/skeleton";
  8965. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8966. import { Nullable } from "babylonjs/types";
  8967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8968. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8969. import { Node } from "babylonjs/node";
  8970. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8971. /**
  8972. * Class used to store bone information
  8973. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8974. */
  8975. export class Bone extends Node {
  8976. /**
  8977. * defines the bone name
  8978. */
  8979. name: string;
  8980. private static _tmpVecs;
  8981. private static _tmpQuat;
  8982. private static _tmpMats;
  8983. /**
  8984. * Gets the list of child bones
  8985. */
  8986. children: Bone[];
  8987. /** Gets the animations associated with this bone */
  8988. animations: import("babylonjs/Animations/animation").Animation[];
  8989. /**
  8990. * Gets or sets bone length
  8991. */
  8992. length: number;
  8993. /**
  8994. * @hidden Internal only
  8995. * Set this value to map this bone to a different index in the transform matrices
  8996. * Set this value to -1 to exclude the bone from the transform matrices
  8997. */
  8998. _index: Nullable<number>;
  8999. private _skeleton;
  9000. private _localMatrix;
  9001. private _restPose;
  9002. private _baseMatrix;
  9003. private _absoluteTransform;
  9004. private _invertedAbsoluteTransform;
  9005. private _parent;
  9006. private _scalingDeterminant;
  9007. private _worldTransform;
  9008. private _localScaling;
  9009. private _localRotation;
  9010. private _localPosition;
  9011. private _needToDecompose;
  9012. private _needToCompose;
  9013. /** @hidden */
  9014. _linkedTransformNode: Nullable<TransformNode>;
  9015. /** @hidden */
  9016. _waitingTransformNodeId: Nullable<string>;
  9017. /** @hidden */
  9018. /** @hidden */
  9019. _matrix: Matrix;
  9020. /**
  9021. * Create a new bone
  9022. * @param name defines the bone name
  9023. * @param skeleton defines the parent skeleton
  9024. * @param parentBone defines the parent (can be null if the bone is the root)
  9025. * @param localMatrix defines the local matrix
  9026. * @param restPose defines the rest pose matrix
  9027. * @param baseMatrix defines the base matrix
  9028. * @param index defines index of the bone in the hiearchy
  9029. */
  9030. constructor(
  9031. /**
  9032. * defines the bone name
  9033. */
  9034. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9035. /**
  9036. * Gets the current object class name.
  9037. * @return the class name
  9038. */
  9039. getClassName(): string;
  9040. /**
  9041. * Gets the parent skeleton
  9042. * @returns a skeleton
  9043. */
  9044. getSkeleton(): Skeleton;
  9045. /**
  9046. * Gets parent bone
  9047. * @returns a bone or null if the bone is the root of the bone hierarchy
  9048. */
  9049. getParent(): Nullable<Bone>;
  9050. /**
  9051. * Returns an array containing the root bones
  9052. * @returns an array containing the root bones
  9053. */
  9054. getChildren(): Array<Bone>;
  9055. /**
  9056. * Sets the parent bone
  9057. * @param parent defines the parent (can be null if the bone is the root)
  9058. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9059. */
  9060. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9061. /**
  9062. * Gets the local matrix
  9063. * @returns a matrix
  9064. */
  9065. getLocalMatrix(): Matrix;
  9066. /**
  9067. * Gets the base matrix (initial matrix which remains unchanged)
  9068. * @returns a matrix
  9069. */
  9070. getBaseMatrix(): Matrix;
  9071. /**
  9072. * Gets the rest pose matrix
  9073. * @returns a matrix
  9074. */
  9075. getRestPose(): Matrix;
  9076. /**
  9077. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9078. */
  9079. getWorldMatrix(): Matrix;
  9080. /**
  9081. * Sets the local matrix to rest pose matrix
  9082. */
  9083. returnToRest(): void;
  9084. /**
  9085. * Gets the inverse of the absolute transform matrix.
  9086. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9087. * @returns a matrix
  9088. */
  9089. getInvertedAbsoluteTransform(): Matrix;
  9090. /**
  9091. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9092. * @returns a matrix
  9093. */
  9094. getAbsoluteTransform(): Matrix;
  9095. /**
  9096. * Links with the given transform node.
  9097. * The local matrix of this bone is copied from the transform node every frame.
  9098. * @param transformNode defines the transform node to link to
  9099. */
  9100. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9101. /** Gets or sets current position (in local space) */
  9102. position: Vector3;
  9103. /** Gets or sets current rotation (in local space) */
  9104. rotation: Vector3;
  9105. /** Gets or sets current rotation quaternion (in local space) */
  9106. rotationQuaternion: Quaternion;
  9107. /** Gets or sets current scaling (in local space) */
  9108. scaling: Vector3;
  9109. /**
  9110. * Gets the animation properties override
  9111. */
  9112. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9113. private _decompose;
  9114. private _compose;
  9115. /**
  9116. * Update the base and local matrices
  9117. * @param matrix defines the new base or local matrix
  9118. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9119. * @param updateLocalMatrix defines if the local matrix should be updated
  9120. */
  9121. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9122. /** @hidden */
  9123. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9124. /**
  9125. * Flag the bone as dirty (Forcing it to update everything)
  9126. */
  9127. markAsDirty(): void;
  9128. /** @hidden */
  9129. _markAsDirtyAndCompose(): void;
  9130. private _markAsDirtyAndDecompose;
  9131. /**
  9132. * Translate the bone in local or world space
  9133. * @param vec The amount to translate the bone
  9134. * @param space The space that the translation is in
  9135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9136. */
  9137. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9138. /**
  9139. * Set the postion of the bone in local or world space
  9140. * @param position The position to set the bone
  9141. * @param space The space that the position is in
  9142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9143. */
  9144. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9145. /**
  9146. * Set the absolute position of the bone (world space)
  9147. * @param position The position to set the bone
  9148. * @param mesh The mesh that this bone is attached to
  9149. */
  9150. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9151. /**
  9152. * Scale the bone on the x, y and z axes (in local space)
  9153. * @param x The amount to scale the bone on the x axis
  9154. * @param y The amount to scale the bone on the y axis
  9155. * @param z The amount to scale the bone on the z axis
  9156. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9157. */
  9158. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9159. /**
  9160. * Set the bone scaling in local space
  9161. * @param scale defines the scaling vector
  9162. */
  9163. setScale(scale: Vector3): void;
  9164. /**
  9165. * Gets the current scaling in local space
  9166. * @returns the current scaling vector
  9167. */
  9168. getScale(): Vector3;
  9169. /**
  9170. * Gets the current scaling in local space and stores it in a target vector
  9171. * @param result defines the target vector
  9172. */
  9173. getScaleToRef(result: Vector3): void;
  9174. /**
  9175. * Set the yaw, pitch, and roll of the bone in local or world space
  9176. * @param yaw The rotation of the bone on the y axis
  9177. * @param pitch The rotation of the bone on the x axis
  9178. * @param roll The rotation of the bone on the z axis
  9179. * @param space The space that the axes of rotation are in
  9180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9181. */
  9182. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9183. /**
  9184. * Add a rotation to the bone on an axis in local or world space
  9185. * @param axis The axis to rotate the bone on
  9186. * @param amount The amount to rotate the bone
  9187. * @param space The space that the axis is in
  9188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9189. */
  9190. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9191. /**
  9192. * Set the rotation of the bone to a particular axis angle in local or world space
  9193. * @param axis The axis to rotate the bone on
  9194. * @param angle The angle that the bone should be rotated to
  9195. * @param space The space that the axis is in
  9196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9197. */
  9198. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9199. /**
  9200. * Set the euler rotation of the bone in local of world space
  9201. * @param rotation The euler rotation that the bone should be set to
  9202. * @param space The space that the rotation is in
  9203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9204. */
  9205. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9206. /**
  9207. * Set the quaternion rotation of the bone in local of world space
  9208. * @param quat The quaternion rotation that the bone should be set to
  9209. * @param space The space that the rotation is in
  9210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9211. */
  9212. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9213. /**
  9214. * Set the rotation matrix of the bone in local of world space
  9215. * @param rotMat The rotation matrix that the bone should be set to
  9216. * @param space The space that the rotation is in
  9217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9218. */
  9219. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9220. private _rotateWithMatrix;
  9221. private _getNegativeRotationToRef;
  9222. /**
  9223. * Get the position of the bone in local or world space
  9224. * @param space The space that the returned position is in
  9225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9226. * @returns The position of the bone
  9227. */
  9228. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9229. /**
  9230. * Copy the position of the bone to a vector3 in local or world space
  9231. * @param space The space that the returned position is in
  9232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9233. * @param result The vector3 to copy the position to
  9234. */
  9235. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9236. /**
  9237. * Get the absolute position of the bone (world space)
  9238. * @param mesh The mesh that this bone is attached to
  9239. * @returns The absolute position of the bone
  9240. */
  9241. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9242. /**
  9243. * Copy the absolute position of the bone (world space) to the result param
  9244. * @param mesh The mesh that this bone is attached to
  9245. * @param result The vector3 to copy the absolute position to
  9246. */
  9247. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9248. /**
  9249. * Compute the absolute transforms of this bone and its children
  9250. */
  9251. computeAbsoluteTransforms(): void;
  9252. /**
  9253. * Get the world direction from an axis that is in the local space of the bone
  9254. * @param localAxis The local direction that is used to compute the world direction
  9255. * @param mesh The mesh that this bone is attached to
  9256. * @returns The world direction
  9257. */
  9258. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9259. /**
  9260. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9261. * @param localAxis The local direction that is used to compute the world direction
  9262. * @param mesh The mesh that this bone is attached to
  9263. * @param result The vector3 that the world direction will be copied to
  9264. */
  9265. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9266. /**
  9267. * Get the euler rotation of the bone in local or world space
  9268. * @param space The space that the rotation should be in
  9269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9270. * @returns The euler rotation
  9271. */
  9272. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9273. /**
  9274. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9275. * @param space The space that the rotation should be in
  9276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9277. * @param result The vector3 that the rotation should be copied to
  9278. */
  9279. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9280. /**
  9281. * Get the quaternion rotation of the bone in either local or world space
  9282. * @param space The space that the rotation should be in
  9283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9284. * @returns The quaternion rotation
  9285. */
  9286. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9287. /**
  9288. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9289. * @param space The space that the rotation should be in
  9290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9291. * @param result The quaternion that the rotation should be copied to
  9292. */
  9293. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9294. /**
  9295. * Get the rotation matrix of the bone in local or world space
  9296. * @param space The space that the rotation should be in
  9297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9298. * @returns The rotation matrix
  9299. */
  9300. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9301. /**
  9302. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9303. * @param space The space that the rotation should be in
  9304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9305. * @param result The quaternion that the rotation should be copied to
  9306. */
  9307. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9308. /**
  9309. * Get the world position of a point that is in the local space of the bone
  9310. * @param position The local position
  9311. * @param mesh The mesh that this bone is attached to
  9312. * @returns The world position
  9313. */
  9314. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9315. /**
  9316. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9317. * @param position The local position
  9318. * @param mesh The mesh that this bone is attached to
  9319. * @param result The vector3 that the world position should be copied to
  9320. */
  9321. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9322. /**
  9323. * Get the local position of a point that is in world space
  9324. * @param position The world position
  9325. * @param mesh The mesh that this bone is attached to
  9326. * @returns The local position
  9327. */
  9328. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9329. /**
  9330. * Get the local position of a point that is in world space and copy it to the result param
  9331. * @param position The world position
  9332. * @param mesh The mesh that this bone is attached to
  9333. * @param result The vector3 that the local position should be copied to
  9334. */
  9335. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9336. }
  9337. }
  9338. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9339. import { Nullable } from "babylonjs/types";
  9340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9341. import { Scene } from "babylonjs/scene";
  9342. module "babylonjs/Engines/engine" {
  9343. interface Engine {
  9344. /**
  9345. * Creates a raw texture
  9346. * @param data defines the data to store in the texture
  9347. * @param width defines the width of the texture
  9348. * @param height defines the height of the texture
  9349. * @param format defines the format of the data
  9350. * @param generateMipMaps defines if the engine should generate the mip levels
  9351. * @param invertY defines if data must be stored with Y axis inverted
  9352. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9353. * @param compression defines the compression used (null by default)
  9354. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9355. * @returns the raw texture inside an InternalTexture
  9356. */
  9357. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9358. /**
  9359. * Update a raw texture
  9360. * @param texture defines the texture to update
  9361. * @param data defines the data to store in the texture
  9362. * @param format defines the format of the data
  9363. * @param invertY defines if data must be stored with Y axis inverted
  9364. */
  9365. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9366. /**
  9367. * Update a raw texture
  9368. * @param texture defines the texture to update
  9369. * @param data defines the data to store in the texture
  9370. * @param format defines the format of the data
  9371. * @param invertY defines if data must be stored with Y axis inverted
  9372. * @param compression defines the compression used (null by default)
  9373. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9374. */
  9375. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9376. /**
  9377. * Creates a new raw cube texture
  9378. * @param data defines the array of data to use to create each face
  9379. * @param size defines the size of the textures
  9380. * @param format defines the format of the data
  9381. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9382. * @param generateMipMaps defines if the engine should generate the mip levels
  9383. * @param invertY defines if data must be stored with Y axis inverted
  9384. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9385. * @param compression defines the compression used (null by default)
  9386. * @returns the cube texture as an InternalTexture
  9387. */
  9388. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9389. /**
  9390. * Update a raw cube texture
  9391. * @param texture defines the texture to udpdate
  9392. * @param data defines the data to store
  9393. * @param format defines the data format
  9394. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9395. * @param invertY defines if data must be stored with Y axis inverted
  9396. */
  9397. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9398. /**
  9399. * Update a raw cube texture
  9400. * @param texture defines the texture to udpdate
  9401. * @param data defines the data to store
  9402. * @param format defines the data format
  9403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9404. * @param invertY defines if data must be stored with Y axis inverted
  9405. * @param compression defines the compression used (null by default)
  9406. */
  9407. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9408. /**
  9409. * Update a raw cube texture
  9410. * @param texture defines the texture to udpdate
  9411. * @param data defines the data to store
  9412. * @param format defines the data format
  9413. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9414. * @param invertY defines if data must be stored with Y axis inverted
  9415. * @param compression defines the compression used (null by default)
  9416. * @param level defines which level of the texture to update
  9417. */
  9418. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9419. /**
  9420. * Creates a new raw cube texture from a specified url
  9421. * @param url defines the url where the data is located
  9422. * @param scene defines the current scene
  9423. * @param size defines the size of the textures
  9424. * @param format defines the format of the data
  9425. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9426. * @param noMipmap defines if the engine should avoid generating the mip levels
  9427. * @param callback defines a callback used to extract texture data from loaded data
  9428. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9429. * @param onLoad defines a callback called when texture is loaded
  9430. * @param onError defines a callback called if there is an error
  9431. * @returns the cube texture as an InternalTexture
  9432. */
  9433. 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;
  9434. /**
  9435. * Creates a new raw cube texture from a specified url
  9436. * @param url defines the url where the data is located
  9437. * @param scene defines the current scene
  9438. * @param size defines the size of the textures
  9439. * @param format defines the format of the data
  9440. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9441. * @param noMipmap defines if the engine should avoid generating the mip levels
  9442. * @param callback defines a callback used to extract texture data from loaded data
  9443. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9444. * @param onLoad defines a callback called when texture is loaded
  9445. * @param onError defines a callback called if there is an error
  9446. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9447. * @param invertY defines if data must be stored with Y axis inverted
  9448. * @returns the cube texture as an InternalTexture
  9449. */
  9450. 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;
  9451. /**
  9452. * Creates a new raw 3D texture
  9453. * @param data defines the data used to create the texture
  9454. * @param width defines the width of the texture
  9455. * @param height defines the height of the texture
  9456. * @param depth defines the depth of the texture
  9457. * @param format defines the format of the texture
  9458. * @param generateMipMaps defines if the engine must generate mip levels
  9459. * @param invertY defines if data must be stored with Y axis inverted
  9460. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9461. * @param compression defines the compressed used (can be null)
  9462. * @param textureType defines the compressed used (can be null)
  9463. * @returns a new raw 3D texture (stored in an InternalTexture)
  9464. */
  9465. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9466. /**
  9467. * Update a raw 3D texture
  9468. * @param texture defines the texture to update
  9469. * @param data defines the data to store
  9470. * @param format defines the data format
  9471. * @param invertY defines if data must be stored with Y axis inverted
  9472. */
  9473. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9474. /**
  9475. * Update a raw 3D texture
  9476. * @param texture defines the texture to update
  9477. * @param data defines the data to store
  9478. * @param format defines the data format
  9479. * @param invertY defines if data must be stored with Y axis inverted
  9480. * @param compression defines the used compression (can be null)
  9481. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9482. */
  9483. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9484. }
  9485. }
  9486. }
  9487. declare module "babylonjs/Materials/Textures/rawTexture" {
  9488. import { Scene } from "babylonjs/scene";
  9489. import { Texture } from "babylonjs/Materials/Textures/texture";
  9490. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9491. /**
  9492. * Raw texture can help creating a texture directly from an array of data.
  9493. * This can be super useful if you either get the data from an uncompressed source or
  9494. * if you wish to create your texture pixel by pixel.
  9495. */
  9496. export class RawTexture extends Texture {
  9497. /**
  9498. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9499. */
  9500. format: number;
  9501. private _engine;
  9502. /**
  9503. * Instantiates a new RawTexture.
  9504. * Raw texture can help creating a texture directly from an array of data.
  9505. * This can be super useful if you either get the data from an uncompressed source or
  9506. * if you wish to create your texture pixel by pixel.
  9507. * @param data define the array of data to use to create the texture
  9508. * @param width define the width of the texture
  9509. * @param height define the height of the texture
  9510. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9511. * @param scene define the scene the texture belongs to
  9512. * @param generateMipMaps define whether mip maps should be generated or not
  9513. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9514. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9515. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9516. */
  9517. constructor(data: ArrayBufferView, width: number, height: number,
  9518. /**
  9519. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9520. */
  9521. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9522. /**
  9523. * Updates the texture underlying data.
  9524. * @param data Define the new data of the texture
  9525. */
  9526. update(data: ArrayBufferView): void;
  9527. /**
  9528. * Creates a luminance texture from some data.
  9529. * @param data Define the texture data
  9530. * @param width Define the width of the texture
  9531. * @param height Define the height of the texture
  9532. * @param scene Define the scene the texture belongs to
  9533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9536. * @returns the luminance texture
  9537. */
  9538. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9539. /**
  9540. * Creates a luminance alpha texture from some data.
  9541. * @param data Define the texture data
  9542. * @param width Define the width of the texture
  9543. * @param height Define the height of the texture
  9544. * @param scene Define the scene the texture belongs to
  9545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9548. * @returns the luminance alpha texture
  9549. */
  9550. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9551. /**
  9552. * Creates an alpha texture from some data.
  9553. * @param data Define the texture data
  9554. * @param width Define the width of the texture
  9555. * @param height Define the height of the texture
  9556. * @param scene Define the scene the texture belongs to
  9557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9560. * @returns the alpha texture
  9561. */
  9562. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9563. /**
  9564. * Creates a RGB texture from some data.
  9565. * @param data Define the texture data
  9566. * @param width Define the width of the texture
  9567. * @param height Define the height of the texture
  9568. * @param scene Define the scene the texture belongs to
  9569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9572. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9573. * @returns the RGB alpha texture
  9574. */
  9575. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9576. /**
  9577. * Creates a RGBA texture from some data.
  9578. * @param data Define the texture data
  9579. * @param width Define the width of the texture
  9580. * @param height Define the height of the texture
  9581. * @param scene Define the scene the texture belongs to
  9582. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9583. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9584. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9585. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9586. * @returns the RGBA texture
  9587. */
  9588. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9589. /**
  9590. * Creates a R texture from some data.
  9591. * @param data Define the texture data
  9592. * @param width Define the width of the texture
  9593. * @param height Define the height of the texture
  9594. * @param scene Define the scene the texture belongs to
  9595. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9596. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9597. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9598. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9599. * @returns the R texture
  9600. */
  9601. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9602. }
  9603. }
  9604. declare module "babylonjs/Animations/runtimeAnimation" {
  9605. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9606. import { Animatable } from "babylonjs/Animations/animatable";
  9607. import { Scene } from "babylonjs/scene";
  9608. /**
  9609. * Defines a runtime animation
  9610. */
  9611. export class RuntimeAnimation {
  9612. private _events;
  9613. /**
  9614. * The current frame of the runtime animation
  9615. */
  9616. private _currentFrame;
  9617. /**
  9618. * The animation used by the runtime animation
  9619. */
  9620. private _animation;
  9621. /**
  9622. * The target of the runtime animation
  9623. */
  9624. private _target;
  9625. /**
  9626. * The initiating animatable
  9627. */
  9628. private _host;
  9629. /**
  9630. * The original value of the runtime animation
  9631. */
  9632. private _originalValue;
  9633. /**
  9634. * The original blend value of the runtime animation
  9635. */
  9636. private _originalBlendValue;
  9637. /**
  9638. * The offsets cache of the runtime animation
  9639. */
  9640. private _offsetsCache;
  9641. /**
  9642. * The high limits cache of the runtime animation
  9643. */
  9644. private _highLimitsCache;
  9645. /**
  9646. * Specifies if the runtime animation has been stopped
  9647. */
  9648. private _stopped;
  9649. /**
  9650. * The blending factor of the runtime animation
  9651. */
  9652. private _blendingFactor;
  9653. /**
  9654. * The BabylonJS scene
  9655. */
  9656. private _scene;
  9657. /**
  9658. * The current value of the runtime animation
  9659. */
  9660. private _currentValue;
  9661. /** @hidden */
  9662. _animationState: _IAnimationState;
  9663. /**
  9664. * The active target of the runtime animation
  9665. */
  9666. private _activeTargets;
  9667. private _currentActiveTarget;
  9668. private _directTarget;
  9669. /**
  9670. * The target path of the runtime animation
  9671. */
  9672. private _targetPath;
  9673. /**
  9674. * The weight of the runtime animation
  9675. */
  9676. private _weight;
  9677. /**
  9678. * The ratio offset of the runtime animation
  9679. */
  9680. private _ratioOffset;
  9681. /**
  9682. * The previous delay of the runtime animation
  9683. */
  9684. private _previousDelay;
  9685. /**
  9686. * The previous ratio of the runtime animation
  9687. */
  9688. private _previousRatio;
  9689. private _enableBlending;
  9690. private _keys;
  9691. private _minFrame;
  9692. private _maxFrame;
  9693. private _minValue;
  9694. private _maxValue;
  9695. private _targetIsArray;
  9696. /**
  9697. * Gets the current frame of the runtime animation
  9698. */
  9699. readonly currentFrame: number;
  9700. /**
  9701. * Gets the weight of the runtime animation
  9702. */
  9703. readonly weight: number;
  9704. /**
  9705. * Gets the current value of the runtime animation
  9706. */
  9707. readonly currentValue: any;
  9708. /**
  9709. * Gets the target path of the runtime animation
  9710. */
  9711. readonly targetPath: string;
  9712. /**
  9713. * Gets the actual target of the runtime animation
  9714. */
  9715. readonly target: any;
  9716. /** @hidden */
  9717. _onLoop: () => void;
  9718. /**
  9719. * Create a new RuntimeAnimation object
  9720. * @param target defines the target of the animation
  9721. * @param animation defines the source animation object
  9722. * @param scene defines the hosting scene
  9723. * @param host defines the initiating Animatable
  9724. */
  9725. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9726. private _preparePath;
  9727. /**
  9728. * Gets the animation from the runtime animation
  9729. */
  9730. readonly animation: Animation;
  9731. /**
  9732. * Resets the runtime animation to the beginning
  9733. * @param restoreOriginal defines whether to restore the target property to the original value
  9734. */
  9735. reset(restoreOriginal?: boolean): void;
  9736. /**
  9737. * Specifies if the runtime animation is stopped
  9738. * @returns Boolean specifying if the runtime animation is stopped
  9739. */
  9740. isStopped(): boolean;
  9741. /**
  9742. * Disposes of the runtime animation
  9743. */
  9744. dispose(): void;
  9745. /**
  9746. * Apply the interpolated value to the target
  9747. * @param currentValue defines the value computed by the animation
  9748. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9749. */
  9750. setValue(currentValue: any, weight: number): void;
  9751. private _getOriginalValues;
  9752. private _setValue;
  9753. /**
  9754. * Gets the loop pmode of the runtime animation
  9755. * @returns Loop Mode
  9756. */
  9757. private _getCorrectLoopMode;
  9758. /**
  9759. * Move the current animation to a given frame
  9760. * @param frame defines the frame to move to
  9761. */
  9762. goToFrame(frame: number): void;
  9763. /**
  9764. * @hidden Internal use only
  9765. */
  9766. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9767. /**
  9768. * Execute the current animation
  9769. * @param delay defines the delay to add to the current frame
  9770. * @param from defines the lower bound of the animation range
  9771. * @param to defines the upper bound of the animation range
  9772. * @param loop defines if the current animation must loop
  9773. * @param speedRatio defines the current speed ratio
  9774. * @param weight defines the weight of the animation (default is -1 so no weight)
  9775. * @param onLoop optional callback called when animation loops
  9776. * @returns a boolean indicating if the animation is running
  9777. */
  9778. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9779. }
  9780. }
  9781. declare module "babylonjs/Animations/animatable" {
  9782. import { Animation } from "babylonjs/Animations/animation";
  9783. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9784. import { Nullable } from "babylonjs/types";
  9785. import { Observable } from "babylonjs/Misc/observable";
  9786. import { Scene } from "babylonjs/scene";
  9787. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9788. import { Node } from "babylonjs/node";
  9789. /**
  9790. * Class used to store an actual running animation
  9791. */
  9792. export class Animatable {
  9793. /** defines the target object */
  9794. target: any;
  9795. /** defines the starting frame number (default is 0) */
  9796. fromFrame: number;
  9797. /** defines the ending frame number (default is 100) */
  9798. toFrame: number;
  9799. /** defines if the animation must loop (default is false) */
  9800. loopAnimation: boolean;
  9801. /** defines a callback to call when animation ends if it is not looping */
  9802. onAnimationEnd?: (() => void) | null | undefined;
  9803. /** defines a callback to call when animation loops */
  9804. onAnimationLoop?: (() => void) | null | undefined;
  9805. private _localDelayOffset;
  9806. private _pausedDelay;
  9807. private _runtimeAnimations;
  9808. private _paused;
  9809. private _scene;
  9810. private _speedRatio;
  9811. private _weight;
  9812. private _syncRoot;
  9813. /**
  9814. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9815. * This will only apply for non looping animation (default is true)
  9816. */
  9817. disposeOnEnd: boolean;
  9818. /**
  9819. * Gets a boolean indicating if the animation has started
  9820. */
  9821. animationStarted: boolean;
  9822. /**
  9823. * Observer raised when the animation ends
  9824. */
  9825. onAnimationEndObservable: Observable<Animatable>;
  9826. /**
  9827. * Observer raised when the animation loops
  9828. */
  9829. onAnimationLoopObservable: Observable<Animatable>;
  9830. /**
  9831. * Gets the root Animatable used to synchronize and normalize animations
  9832. */
  9833. readonly syncRoot: Nullable<Animatable>;
  9834. /**
  9835. * Gets the current frame of the first RuntimeAnimation
  9836. * Used to synchronize Animatables
  9837. */
  9838. readonly masterFrame: number;
  9839. /**
  9840. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9841. */
  9842. weight: number;
  9843. /**
  9844. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9845. */
  9846. speedRatio: number;
  9847. /**
  9848. * Creates a new Animatable
  9849. * @param scene defines the hosting scene
  9850. * @param target defines the target object
  9851. * @param fromFrame defines the starting frame number (default is 0)
  9852. * @param toFrame defines the ending frame number (default is 100)
  9853. * @param loopAnimation defines if the animation must loop (default is false)
  9854. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9855. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9856. * @param animations defines a group of animation to add to the new Animatable
  9857. * @param onAnimationLoop defines a callback to call when animation loops
  9858. */
  9859. constructor(scene: Scene,
  9860. /** defines the target object */
  9861. target: any,
  9862. /** defines the starting frame number (default is 0) */
  9863. fromFrame?: number,
  9864. /** defines the ending frame number (default is 100) */
  9865. toFrame?: number,
  9866. /** defines if the animation must loop (default is false) */
  9867. loopAnimation?: boolean, speedRatio?: number,
  9868. /** defines a callback to call when animation ends if it is not looping */
  9869. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9870. /** defines a callback to call when animation loops */
  9871. onAnimationLoop?: (() => void) | null | undefined);
  9872. /**
  9873. * Synchronize and normalize current Animatable with a source Animatable
  9874. * This is useful when using animation weights and when animations are not of the same length
  9875. * @param root defines the root Animatable to synchronize with
  9876. * @returns the current Animatable
  9877. */
  9878. syncWith(root: Animatable): Animatable;
  9879. /**
  9880. * Gets the list of runtime animations
  9881. * @returns an array of RuntimeAnimation
  9882. */
  9883. getAnimations(): RuntimeAnimation[];
  9884. /**
  9885. * Adds more animations to the current animatable
  9886. * @param target defines the target of the animations
  9887. * @param animations defines the new animations to add
  9888. */
  9889. appendAnimations(target: any, animations: Animation[]): void;
  9890. /**
  9891. * Gets the source animation for a specific property
  9892. * @param property defines the propertyu to look for
  9893. * @returns null or the source animation for the given property
  9894. */
  9895. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9896. /**
  9897. * Gets the runtime animation for a specific property
  9898. * @param property defines the propertyu to look for
  9899. * @returns null or the runtime animation for the given property
  9900. */
  9901. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9902. /**
  9903. * Resets the animatable to its original state
  9904. */
  9905. reset(): void;
  9906. /**
  9907. * Allows the animatable to blend with current running animations
  9908. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9909. * @param blendingSpeed defines the blending speed to use
  9910. */
  9911. enableBlending(blendingSpeed: number): void;
  9912. /**
  9913. * Disable animation blending
  9914. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9915. */
  9916. disableBlending(): void;
  9917. /**
  9918. * Jump directly to a given frame
  9919. * @param frame defines the frame to jump to
  9920. */
  9921. goToFrame(frame: number): void;
  9922. /**
  9923. * Pause the animation
  9924. */
  9925. pause(): void;
  9926. /**
  9927. * Restart the animation
  9928. */
  9929. restart(): void;
  9930. private _raiseOnAnimationEnd;
  9931. /**
  9932. * Stop and delete the current animation
  9933. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9934. * @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)
  9935. */
  9936. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9937. /**
  9938. * Wait asynchronously for the animation to end
  9939. * @returns a promise which will be fullfilled when the animation ends
  9940. */
  9941. waitAsync(): Promise<Animatable>;
  9942. /** @hidden */
  9943. _animate(delay: number): boolean;
  9944. }
  9945. module "babylonjs/scene" {
  9946. interface Scene {
  9947. /** @hidden */
  9948. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9949. /** @hidden */
  9950. _processLateAnimationBindingsForMatrices(holder: {
  9951. totalWeight: number;
  9952. animations: RuntimeAnimation[];
  9953. originalValue: Matrix;
  9954. }): any;
  9955. /** @hidden */
  9956. _processLateAnimationBindingsForQuaternions(holder: {
  9957. totalWeight: number;
  9958. animations: RuntimeAnimation[];
  9959. originalValue: Quaternion;
  9960. }, refQuaternion: Quaternion): Quaternion;
  9961. /** @hidden */
  9962. _processLateAnimationBindings(): void;
  9963. /**
  9964. * Will start the animation sequence of a given target
  9965. * @param target defines the target
  9966. * @param from defines from which frame should animation start
  9967. * @param to defines until which frame should animation run.
  9968. * @param weight defines the weight to apply to the animation (1.0 by default)
  9969. * @param loop defines if the animation loops
  9970. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9971. * @param onAnimationEnd defines the function to be executed when the animation ends
  9972. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9973. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9974. * @param onAnimationLoop defines the callback to call when an animation loops
  9975. * @returns the animatable object created for this animation
  9976. */
  9977. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9978. /**
  9979. * Will start the animation sequence of a given target
  9980. * @param target defines the target
  9981. * @param from defines from which frame should animation start
  9982. * @param to defines until which frame should animation run.
  9983. * @param loop defines if the animation loops
  9984. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9985. * @param onAnimationEnd defines the function to be executed when the animation ends
  9986. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9987. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9988. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9989. * @param onAnimationLoop defines the callback to call when an animation loops
  9990. * @returns the animatable object created for this animation
  9991. */
  9992. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9993. /**
  9994. * Will start the animation sequence of a given target and its hierarchy
  9995. * @param target defines the target
  9996. * @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.
  9997. * @param from defines from which frame should animation start
  9998. * @param to defines until which frame should animation run.
  9999. * @param loop defines if the animation loops
  10000. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10001. * @param onAnimationEnd defines the function to be executed when the animation ends
  10002. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10003. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10004. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10005. * @param onAnimationLoop defines the callback to call when an animation loops
  10006. * @returns the list of created animatables
  10007. */
  10008. 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[];
  10009. /**
  10010. * Begin a new animation on a given node
  10011. * @param target defines the target where the animation will take place
  10012. * @param animations defines the list of animations to start
  10013. * @param from defines the initial value
  10014. * @param to defines the final value
  10015. * @param loop defines if you want animation to loop (off by default)
  10016. * @param speedRatio defines the speed ratio to apply to all animations
  10017. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10018. * @param onAnimationLoop defines the callback to call when an animation loops
  10019. * @returns the list of created animatables
  10020. */
  10021. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10022. /**
  10023. * Begin a new animation on a given node and its hierarchy
  10024. * @param target defines the root node where the animation will take place
  10025. * @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.
  10026. * @param animations defines the list of animations to start
  10027. * @param from defines the initial value
  10028. * @param to defines the final value
  10029. * @param loop defines if you want animation to loop (off by default)
  10030. * @param speedRatio defines the speed ratio to apply to all animations
  10031. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10032. * @param onAnimationLoop defines the callback to call when an animation loops
  10033. * @returns the list of animatables created for all nodes
  10034. */
  10035. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10036. /**
  10037. * Gets the animatable associated with a specific target
  10038. * @param target defines the target of the animatable
  10039. * @returns the required animatable if found
  10040. */
  10041. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10042. /**
  10043. * Gets all animatables associated with a given target
  10044. * @param target defines the target to look animatables for
  10045. * @returns an array of Animatables
  10046. */
  10047. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10048. /**
  10049. * Stops and removes all animations that have been applied to the scene
  10050. */
  10051. stopAllAnimations(): void;
  10052. }
  10053. }
  10054. module "babylonjs/Bones/bone" {
  10055. interface Bone {
  10056. /**
  10057. * Copy an animation range from another bone
  10058. * @param source defines the source bone
  10059. * @param rangeName defines the range name to copy
  10060. * @param frameOffset defines the frame offset
  10061. * @param rescaleAsRequired defines if rescaling must be applied if required
  10062. * @param skelDimensionsRatio defines the scaling ratio
  10063. * @returns true if operation was successful
  10064. */
  10065. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10066. }
  10067. }
  10068. }
  10069. declare module "babylonjs/Bones/skeleton" {
  10070. import { Bone } from "babylonjs/Bones/bone";
  10071. import { IAnimatable } from "babylonjs/Misc/tools";
  10072. import { Observable } from "babylonjs/Misc/observable";
  10073. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10074. import { Scene } from "babylonjs/scene";
  10075. import { Nullable } from "babylonjs/types";
  10076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10077. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10078. import { Animatable } from "babylonjs/Animations/animatable";
  10079. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10080. import { Animation } from "babylonjs/Animations/animation";
  10081. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10082. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10083. /**
  10084. * Class used to handle skinning animations
  10085. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10086. */
  10087. export class Skeleton implements IAnimatable {
  10088. /** defines the skeleton name */
  10089. name: string;
  10090. /** defines the skeleton Id */
  10091. id: string;
  10092. /**
  10093. * Defines the list of child bones
  10094. */
  10095. bones: Bone[];
  10096. /**
  10097. * Defines an estimate of the dimension of the skeleton at rest
  10098. */
  10099. dimensionsAtRest: Vector3;
  10100. /**
  10101. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10102. */
  10103. needInitialSkinMatrix: boolean;
  10104. /**
  10105. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10106. */
  10107. overrideMesh: Nullable<AbstractMesh>;
  10108. /**
  10109. * Gets the list of animations attached to this skeleton
  10110. */
  10111. animations: Array<Animation>;
  10112. private _scene;
  10113. private _isDirty;
  10114. private _transformMatrices;
  10115. private _transformMatrixTexture;
  10116. private _meshesWithPoseMatrix;
  10117. private _animatables;
  10118. private _identity;
  10119. private _synchronizedWithMesh;
  10120. private _ranges;
  10121. private _lastAbsoluteTransformsUpdateId;
  10122. private _canUseTextureForBones;
  10123. private _uniqueId;
  10124. /** @hidden */
  10125. _numBonesWithLinkedTransformNode: number;
  10126. /** @hidden */
  10127. _hasWaitingData: Nullable<boolean>;
  10128. /**
  10129. * Specifies if the skeleton should be serialized
  10130. */
  10131. doNotSerialize: boolean;
  10132. private _useTextureToStoreBoneMatrices;
  10133. /**
  10134. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10135. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10136. */
  10137. useTextureToStoreBoneMatrices: boolean;
  10138. private _animationPropertiesOverride;
  10139. /**
  10140. * Gets or sets the animation properties override
  10141. */
  10142. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10143. /**
  10144. * List of inspectable custom properties (used by the Inspector)
  10145. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10146. */
  10147. inspectableCustomProperties: IInspectable[];
  10148. /**
  10149. * An observable triggered before computing the skeleton's matrices
  10150. */
  10151. onBeforeComputeObservable: Observable<Skeleton>;
  10152. /**
  10153. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10154. */
  10155. readonly isUsingTextureForMatrices: boolean;
  10156. /**
  10157. * Gets the unique ID of this skeleton
  10158. */
  10159. readonly uniqueId: number;
  10160. /**
  10161. * Creates a new skeleton
  10162. * @param name defines the skeleton name
  10163. * @param id defines the skeleton Id
  10164. * @param scene defines the hosting scene
  10165. */
  10166. constructor(
  10167. /** defines the skeleton name */
  10168. name: string,
  10169. /** defines the skeleton Id */
  10170. id: string, scene: Scene);
  10171. /**
  10172. * Gets the current object class name.
  10173. * @return the class name
  10174. */
  10175. getClassName(): string;
  10176. /**
  10177. * Returns an array containing the root bones
  10178. * @returns an array containing the root bones
  10179. */
  10180. getChildren(): Array<Bone>;
  10181. /**
  10182. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10183. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10184. * @returns a Float32Array containing matrices data
  10185. */
  10186. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10187. /**
  10188. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10189. * @returns a raw texture containing the data
  10190. */
  10191. getTransformMatrixTexture(): Nullable<RawTexture>;
  10192. /**
  10193. * Gets the current hosting scene
  10194. * @returns a scene object
  10195. */
  10196. getScene(): Scene;
  10197. /**
  10198. * Gets a string representing the current skeleton data
  10199. * @param fullDetails defines a boolean indicating if we want a verbose version
  10200. * @returns a string representing the current skeleton data
  10201. */
  10202. toString(fullDetails?: boolean): string;
  10203. /**
  10204. * Get bone's index searching by name
  10205. * @param name defines bone's name to search for
  10206. * @return the indice of the bone. Returns -1 if not found
  10207. */
  10208. getBoneIndexByName(name: string): number;
  10209. /**
  10210. * Creater a new animation range
  10211. * @param name defines the name of the range
  10212. * @param from defines the start key
  10213. * @param to defines the end key
  10214. */
  10215. createAnimationRange(name: string, from: number, to: number): void;
  10216. /**
  10217. * Delete a specific animation range
  10218. * @param name defines the name of the range
  10219. * @param deleteFrames defines if frames must be removed as well
  10220. */
  10221. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10222. /**
  10223. * Gets a specific animation range
  10224. * @param name defines the name of the range to look for
  10225. * @returns the requested animation range or null if not found
  10226. */
  10227. getAnimationRange(name: string): Nullable<AnimationRange>;
  10228. /**
  10229. * Gets the list of all animation ranges defined on this skeleton
  10230. * @returns an array
  10231. */
  10232. getAnimationRanges(): Nullable<AnimationRange>[];
  10233. /**
  10234. * Copy animation range from a source skeleton.
  10235. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10236. * @param source defines the source skeleton
  10237. * @param name defines the name of the range to copy
  10238. * @param rescaleAsRequired defines if rescaling must be applied if required
  10239. * @returns true if operation was successful
  10240. */
  10241. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10242. /**
  10243. * Forces the skeleton to go to rest pose
  10244. */
  10245. returnToRest(): void;
  10246. private _getHighestAnimationFrame;
  10247. /**
  10248. * Begin a specific animation range
  10249. * @param name defines the name of the range to start
  10250. * @param loop defines if looping must be turned on (false by default)
  10251. * @param speedRatio defines the speed ratio to apply (1 by default)
  10252. * @param onAnimationEnd defines a callback which will be called when animation will end
  10253. * @returns a new animatable
  10254. */
  10255. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10256. /** @hidden */
  10257. _markAsDirty(): void;
  10258. /** @hidden */
  10259. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10260. /** @hidden */
  10261. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10262. private _computeTransformMatrices;
  10263. /**
  10264. * Build all resources required to render a skeleton
  10265. */
  10266. prepare(): void;
  10267. /**
  10268. * Gets the list of animatables currently running for this skeleton
  10269. * @returns an array of animatables
  10270. */
  10271. getAnimatables(): IAnimatable[];
  10272. /**
  10273. * Clone the current skeleton
  10274. * @param name defines the name of the new skeleton
  10275. * @param id defines the id of the new skeleton
  10276. * @returns the new skeleton
  10277. */
  10278. clone(name: string, id: string): Skeleton;
  10279. /**
  10280. * Enable animation blending for this skeleton
  10281. * @param blendingSpeed defines the blending speed to apply
  10282. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10283. */
  10284. enableBlending(blendingSpeed?: number): void;
  10285. /**
  10286. * Releases all resources associated with the current skeleton
  10287. */
  10288. dispose(): void;
  10289. /**
  10290. * Serialize the skeleton in a JSON object
  10291. * @returns a JSON object
  10292. */
  10293. serialize(): any;
  10294. /**
  10295. * Creates a new skeleton from serialized data
  10296. * @param parsedSkeleton defines the serialized data
  10297. * @param scene defines the hosting scene
  10298. * @returns a new skeleton
  10299. */
  10300. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10301. /**
  10302. * Compute all node absolute transforms
  10303. * @param forceUpdate defines if computation must be done even if cache is up to date
  10304. */
  10305. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10306. /**
  10307. * Gets the root pose matrix
  10308. * @returns a matrix
  10309. */
  10310. getPoseMatrix(): Nullable<Matrix>;
  10311. /**
  10312. * Sorts bones per internal index
  10313. */
  10314. sortBones(): void;
  10315. private _sortBones;
  10316. }
  10317. }
  10318. declare module "babylonjs/Morph/morphTarget" {
  10319. import { IAnimatable } from "babylonjs/Misc/tools";
  10320. import { Observable } from "babylonjs/Misc/observable";
  10321. import { Nullable, FloatArray } from "babylonjs/types";
  10322. import { Scene } from "babylonjs/scene";
  10323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10324. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10325. /**
  10326. * Defines a target to use with MorphTargetManager
  10327. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10328. */
  10329. export class MorphTarget implements IAnimatable {
  10330. /** defines the name of the target */
  10331. name: string;
  10332. /**
  10333. * Gets or sets the list of animations
  10334. */
  10335. animations: import("babylonjs/Animations/animation").Animation[];
  10336. private _scene;
  10337. private _positions;
  10338. private _normals;
  10339. private _tangents;
  10340. private _influence;
  10341. /**
  10342. * Observable raised when the influence changes
  10343. */
  10344. onInfluenceChanged: Observable<boolean>;
  10345. /** @hidden */
  10346. _onDataLayoutChanged: Observable<void>;
  10347. /**
  10348. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10349. */
  10350. influence: number;
  10351. /**
  10352. * Gets or sets the id of the morph Target
  10353. */
  10354. id: string;
  10355. private _animationPropertiesOverride;
  10356. /**
  10357. * Gets or sets the animation properties override
  10358. */
  10359. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10360. /**
  10361. * Creates a new MorphTarget
  10362. * @param name defines the name of the target
  10363. * @param influence defines the influence to use
  10364. * @param scene defines the scene the morphtarget belongs to
  10365. */
  10366. constructor(
  10367. /** defines the name of the target */
  10368. name: string, influence?: number, scene?: Nullable<Scene>);
  10369. /**
  10370. * Gets a boolean defining if the target contains position data
  10371. */
  10372. readonly hasPositions: boolean;
  10373. /**
  10374. * Gets a boolean defining if the target contains normal data
  10375. */
  10376. readonly hasNormals: boolean;
  10377. /**
  10378. * Gets a boolean defining if the target contains tangent data
  10379. */
  10380. readonly hasTangents: boolean;
  10381. /**
  10382. * Affects position data to this target
  10383. * @param data defines the position data to use
  10384. */
  10385. setPositions(data: Nullable<FloatArray>): void;
  10386. /**
  10387. * Gets the position data stored in this target
  10388. * @returns a FloatArray containing the position data (or null if not present)
  10389. */
  10390. getPositions(): Nullable<FloatArray>;
  10391. /**
  10392. * Affects normal data to this target
  10393. * @param data defines the normal data to use
  10394. */
  10395. setNormals(data: Nullable<FloatArray>): void;
  10396. /**
  10397. * Gets the normal data stored in this target
  10398. * @returns a FloatArray containing the normal data (or null if not present)
  10399. */
  10400. getNormals(): Nullable<FloatArray>;
  10401. /**
  10402. * Affects tangent data to this target
  10403. * @param data defines the tangent data to use
  10404. */
  10405. setTangents(data: Nullable<FloatArray>): void;
  10406. /**
  10407. * Gets the tangent data stored in this target
  10408. * @returns a FloatArray containing the tangent data (or null if not present)
  10409. */
  10410. getTangents(): Nullable<FloatArray>;
  10411. /**
  10412. * Serializes the current target into a Serialization object
  10413. * @returns the serialized object
  10414. */
  10415. serialize(): any;
  10416. /**
  10417. * Returns the string "MorphTarget"
  10418. * @returns "MorphTarget"
  10419. */
  10420. getClassName(): string;
  10421. /**
  10422. * Creates a new target from serialized data
  10423. * @param serializationObject defines the serialized data to use
  10424. * @returns a new MorphTarget
  10425. */
  10426. static Parse(serializationObject: any): MorphTarget;
  10427. /**
  10428. * Creates a MorphTarget from mesh data
  10429. * @param mesh defines the source mesh
  10430. * @param name defines the name to use for the new target
  10431. * @param influence defines the influence to attach to the target
  10432. * @returns a new MorphTarget
  10433. */
  10434. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10435. }
  10436. }
  10437. declare module "babylonjs/Morph/morphTargetManager" {
  10438. import { Nullable } from "babylonjs/types";
  10439. import { Scene } from "babylonjs/scene";
  10440. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10441. /**
  10442. * This class is used to deform meshes using morphing between different targets
  10443. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10444. */
  10445. export class MorphTargetManager {
  10446. private _targets;
  10447. private _targetInfluenceChangedObservers;
  10448. private _targetDataLayoutChangedObservers;
  10449. private _activeTargets;
  10450. private _scene;
  10451. private _influences;
  10452. private _supportsNormals;
  10453. private _supportsTangents;
  10454. private _vertexCount;
  10455. private _uniqueId;
  10456. private _tempInfluences;
  10457. /**
  10458. * Creates a new MorphTargetManager
  10459. * @param scene defines the current scene
  10460. */
  10461. constructor(scene?: Nullable<Scene>);
  10462. /**
  10463. * Gets the unique ID of this manager
  10464. */
  10465. readonly uniqueId: number;
  10466. /**
  10467. * Gets the number of vertices handled by this manager
  10468. */
  10469. readonly vertexCount: number;
  10470. /**
  10471. * Gets a boolean indicating if this manager supports morphing of normals
  10472. */
  10473. readonly supportsNormals: boolean;
  10474. /**
  10475. * Gets a boolean indicating if this manager supports morphing of tangents
  10476. */
  10477. readonly supportsTangents: boolean;
  10478. /**
  10479. * Gets the number of targets stored in this manager
  10480. */
  10481. readonly numTargets: number;
  10482. /**
  10483. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10484. */
  10485. readonly numInfluencers: number;
  10486. /**
  10487. * Gets the list of influences (one per target)
  10488. */
  10489. readonly influences: Float32Array;
  10490. /**
  10491. * Gets the active target at specified index. An active target is a target with an influence > 0
  10492. * @param index defines the index to check
  10493. * @returns the requested target
  10494. */
  10495. getActiveTarget(index: number): MorphTarget;
  10496. /**
  10497. * Gets the target at specified index
  10498. * @param index defines the index to check
  10499. * @returns the requested target
  10500. */
  10501. getTarget(index: number): MorphTarget;
  10502. /**
  10503. * Add a new target to this manager
  10504. * @param target defines the target to add
  10505. */
  10506. addTarget(target: MorphTarget): void;
  10507. /**
  10508. * Removes a target from the manager
  10509. * @param target defines the target to remove
  10510. */
  10511. removeTarget(target: MorphTarget): void;
  10512. /**
  10513. * Serializes the current manager into a Serialization object
  10514. * @returns the serialized object
  10515. */
  10516. serialize(): any;
  10517. private _syncActiveTargets;
  10518. /**
  10519. * Syncrhonize the targets with all the meshes using this morph target manager
  10520. */
  10521. synchronize(): void;
  10522. /**
  10523. * Creates a new MorphTargetManager from serialized data
  10524. * @param serializationObject defines the serialized data
  10525. * @param scene defines the hosting scene
  10526. * @returns the new MorphTargetManager
  10527. */
  10528. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10529. }
  10530. }
  10531. declare module "babylonjs/sceneComponent" {
  10532. import { Scene } from "babylonjs/scene";
  10533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10534. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10535. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10536. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10537. import { Nullable } from "babylonjs/types";
  10538. import { Camera } from "babylonjs/Cameras/camera";
  10539. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10540. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10541. import { AbstractScene } from "babylonjs/abstractScene";
  10542. /**
  10543. * Groups all the scene component constants in one place to ease maintenance.
  10544. * @hidden
  10545. */
  10546. export class SceneComponentConstants {
  10547. static readonly NAME_EFFECTLAYER: string;
  10548. static readonly NAME_LAYER: string;
  10549. static readonly NAME_LENSFLARESYSTEM: string;
  10550. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10551. static readonly NAME_PARTICLESYSTEM: string;
  10552. static readonly NAME_GAMEPAD: string;
  10553. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10554. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10555. static readonly NAME_DEPTHRENDERER: string;
  10556. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10557. static readonly NAME_SPRITE: string;
  10558. static readonly NAME_OUTLINERENDERER: string;
  10559. static readonly NAME_PROCEDURALTEXTURE: string;
  10560. static readonly NAME_SHADOWGENERATOR: string;
  10561. static readonly NAME_OCTREE: string;
  10562. static readonly NAME_PHYSICSENGINE: string;
  10563. static readonly NAME_AUDIO: string;
  10564. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10565. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10566. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10567. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10568. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10569. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10570. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10571. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10572. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10573. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10574. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10575. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10576. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10577. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10578. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10579. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10580. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10581. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10582. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10583. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10584. static readonly STEP_AFTERRENDER_AUDIO: number;
  10585. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10586. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10587. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10588. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10589. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10590. static readonly STEP_POINTERMOVE_SPRITE: number;
  10591. static readonly STEP_POINTERDOWN_SPRITE: number;
  10592. static readonly STEP_POINTERUP_SPRITE: number;
  10593. }
  10594. /**
  10595. * This represents a scene component.
  10596. *
  10597. * This is used to decouple the dependency the scene is having on the different workloads like
  10598. * layers, post processes...
  10599. */
  10600. export interface ISceneComponent {
  10601. /**
  10602. * The name of the component. Each component must have a unique name.
  10603. */
  10604. name: string;
  10605. /**
  10606. * The scene the component belongs to.
  10607. */
  10608. scene: Scene;
  10609. /**
  10610. * Register the component to one instance of a scene.
  10611. */
  10612. register(): void;
  10613. /**
  10614. * Rebuilds the elements related to this component in case of
  10615. * context lost for instance.
  10616. */
  10617. rebuild(): void;
  10618. /**
  10619. * Disposes the component and the associated ressources.
  10620. */
  10621. dispose(): void;
  10622. }
  10623. /**
  10624. * This represents a SERIALIZABLE scene component.
  10625. *
  10626. * This extends Scene Component to add Serialization methods on top.
  10627. */
  10628. export interface ISceneSerializableComponent extends ISceneComponent {
  10629. /**
  10630. * Adds all the elements from the container to the scene
  10631. * @param container the container holding the elements
  10632. */
  10633. addFromContainer(container: AbstractScene): void;
  10634. /**
  10635. * Removes all the elements in the container from the scene
  10636. * @param container contains the elements to remove
  10637. * @param dispose if the removed element should be disposed (default: false)
  10638. */
  10639. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10640. /**
  10641. * Serializes the component data to the specified json object
  10642. * @param serializationObject The object to serialize to
  10643. */
  10644. serialize(serializationObject: any): void;
  10645. }
  10646. /**
  10647. * Strong typing of a Mesh related stage step action
  10648. */
  10649. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10650. /**
  10651. * Strong typing of a Evaluate Sub Mesh related stage step action
  10652. */
  10653. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10654. /**
  10655. * Strong typing of a Active Mesh related stage step action
  10656. */
  10657. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10658. /**
  10659. * Strong typing of a Camera related stage step action
  10660. */
  10661. export type CameraStageAction = (camera: Camera) => void;
  10662. /**
  10663. * Strong typing of a Camera Frame buffer related stage step action
  10664. */
  10665. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10666. /**
  10667. * Strong typing of a Render Target related stage step action
  10668. */
  10669. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10670. /**
  10671. * Strong typing of a RenderingGroup related stage step action
  10672. */
  10673. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10674. /**
  10675. * Strong typing of a Mesh Render related stage step action
  10676. */
  10677. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10678. /**
  10679. * Strong typing of a simple stage step action
  10680. */
  10681. export type SimpleStageAction = () => void;
  10682. /**
  10683. * Strong typing of a render target action.
  10684. */
  10685. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10686. /**
  10687. * Strong typing of a pointer move action.
  10688. */
  10689. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10690. /**
  10691. * Strong typing of a pointer up/down action.
  10692. */
  10693. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10694. /**
  10695. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10696. * @hidden
  10697. */
  10698. export class Stage<T extends Function> extends Array<{
  10699. index: number;
  10700. component: ISceneComponent;
  10701. action: T;
  10702. }> {
  10703. /**
  10704. * Hide ctor from the rest of the world.
  10705. * @param items The items to add.
  10706. */
  10707. private constructor();
  10708. /**
  10709. * Creates a new Stage.
  10710. * @returns A new instance of a Stage
  10711. */
  10712. static Create<T extends Function>(): Stage<T>;
  10713. /**
  10714. * Registers a step in an ordered way in the targeted stage.
  10715. * @param index Defines the position to register the step in
  10716. * @param component Defines the component attached to the step
  10717. * @param action Defines the action to launch during the step
  10718. */
  10719. registerStep(index: number, component: ISceneComponent, action: T): void;
  10720. /**
  10721. * Clears all the steps from the stage.
  10722. */
  10723. clear(): void;
  10724. }
  10725. }
  10726. declare module "babylonjs/Meshes/meshLODLevel" {
  10727. import { Mesh } from "babylonjs/Meshes/mesh";
  10728. import { Nullable } from "babylonjs/types";
  10729. /**
  10730. * Class used to represent a specific level of detail of a mesh
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10732. */
  10733. export class MeshLODLevel {
  10734. /** Defines the distance where this level should star being displayed */
  10735. distance: number;
  10736. /** Defines the mesh to use to render this level */
  10737. mesh: Nullable<Mesh>;
  10738. /**
  10739. * Creates a new LOD level
  10740. * @param distance defines the distance where this level should star being displayed
  10741. * @param mesh defines the mesh to use to render this level
  10742. */
  10743. constructor(
  10744. /** Defines the distance where this level should star being displayed */
  10745. distance: number,
  10746. /** Defines the mesh to use to render this level */
  10747. mesh: Nullable<Mesh>);
  10748. }
  10749. }
  10750. declare module "babylonjs/Lights/shadowLight" {
  10751. import { Camera } from "babylonjs/Cameras/camera";
  10752. import { Scene } from "babylonjs/scene";
  10753. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10755. import { Light } from "babylonjs/Lights/light";
  10756. /**
  10757. * Interface describing all the common properties and methods a shadow light needs to implement.
  10758. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10759. * as well as binding the different shadow properties to the effects.
  10760. */
  10761. export interface IShadowLight extends Light {
  10762. /**
  10763. * The light id in the scene (used in scene.findLighById for instance)
  10764. */
  10765. id: string;
  10766. /**
  10767. * The position the shdow will be casted from.
  10768. */
  10769. position: Vector3;
  10770. /**
  10771. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10772. */
  10773. direction: Vector3;
  10774. /**
  10775. * The transformed position. Position of the light in world space taking parenting in account.
  10776. */
  10777. transformedPosition: Vector3;
  10778. /**
  10779. * The transformed direction. Direction of the light in world space taking parenting in account.
  10780. */
  10781. transformedDirection: Vector3;
  10782. /**
  10783. * The friendly name of the light in the scene.
  10784. */
  10785. name: string;
  10786. /**
  10787. * Defines the shadow projection clipping minimum z value.
  10788. */
  10789. shadowMinZ: number;
  10790. /**
  10791. * Defines the shadow projection clipping maximum z value.
  10792. */
  10793. shadowMaxZ: number;
  10794. /**
  10795. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10796. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10797. */
  10798. computeTransformedInformation(): boolean;
  10799. /**
  10800. * Gets the scene the light belongs to.
  10801. * @returns The scene
  10802. */
  10803. getScene(): Scene;
  10804. /**
  10805. * Callback defining a custom Projection Matrix Builder.
  10806. * This can be used to override the default projection matrix computation.
  10807. */
  10808. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10809. /**
  10810. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10811. * @param matrix The materix to updated with the projection information
  10812. * @param viewMatrix The transform matrix of the light
  10813. * @param renderList The list of mesh to render in the map
  10814. * @returns The current light
  10815. */
  10816. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10817. /**
  10818. * Gets the current depth scale used in ESM.
  10819. * @returns The scale
  10820. */
  10821. getDepthScale(): number;
  10822. /**
  10823. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10824. * @returns true if a cube texture needs to be use
  10825. */
  10826. needCube(): boolean;
  10827. /**
  10828. * Detects if the projection matrix requires to be recomputed this frame.
  10829. * @returns true if it requires to be recomputed otherwise, false.
  10830. */
  10831. needProjectionMatrixCompute(): boolean;
  10832. /**
  10833. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10834. */
  10835. forceProjectionMatrixCompute(): void;
  10836. /**
  10837. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10838. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10839. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10840. */
  10841. getShadowDirection(faceIndex?: number): Vector3;
  10842. /**
  10843. * Gets the minZ used for shadow according to both the scene and the light.
  10844. * @param activeCamera The camera we are returning the min for
  10845. * @returns the depth min z
  10846. */
  10847. getDepthMinZ(activeCamera: Camera): number;
  10848. /**
  10849. * Gets the maxZ used for shadow according to both the scene and the light.
  10850. * @param activeCamera The camera we are returning the max for
  10851. * @returns the depth max z
  10852. */
  10853. getDepthMaxZ(activeCamera: Camera): number;
  10854. }
  10855. /**
  10856. * Base implementation IShadowLight
  10857. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10858. */
  10859. export abstract class ShadowLight extends Light implements IShadowLight {
  10860. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10861. protected _position: Vector3;
  10862. protected _setPosition(value: Vector3): void;
  10863. /**
  10864. * Sets the position the shadow will be casted from. Also use as the light position for both
  10865. * point and spot lights.
  10866. */
  10867. /**
  10868. * Sets the position the shadow will be casted from. Also use as the light position for both
  10869. * point and spot lights.
  10870. */
  10871. position: Vector3;
  10872. protected _direction: Vector3;
  10873. protected _setDirection(value: Vector3): void;
  10874. /**
  10875. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10876. * Also use as the light direction on spot and directional lights.
  10877. */
  10878. /**
  10879. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10880. * Also use as the light direction on spot and directional lights.
  10881. */
  10882. direction: Vector3;
  10883. private _shadowMinZ;
  10884. /**
  10885. * Gets the shadow projection clipping minimum z value.
  10886. */
  10887. /**
  10888. * Sets the shadow projection clipping minimum z value.
  10889. */
  10890. shadowMinZ: number;
  10891. private _shadowMaxZ;
  10892. /**
  10893. * Sets the shadow projection clipping maximum z value.
  10894. */
  10895. /**
  10896. * Gets the shadow projection clipping maximum z value.
  10897. */
  10898. shadowMaxZ: number;
  10899. /**
  10900. * Callback defining a custom Projection Matrix Builder.
  10901. * This can be used to override the default projection matrix computation.
  10902. */
  10903. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10904. /**
  10905. * The transformed position. Position of the light in world space taking parenting in account.
  10906. */
  10907. transformedPosition: Vector3;
  10908. /**
  10909. * The transformed direction. Direction of the light in world space taking parenting in account.
  10910. */
  10911. transformedDirection: Vector3;
  10912. private _needProjectionMatrixCompute;
  10913. /**
  10914. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10915. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10916. */
  10917. computeTransformedInformation(): boolean;
  10918. /**
  10919. * Return the depth scale used for the shadow map.
  10920. * @returns the depth scale.
  10921. */
  10922. getDepthScale(): number;
  10923. /**
  10924. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10925. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10926. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10927. */
  10928. getShadowDirection(faceIndex?: number): Vector3;
  10929. /**
  10930. * Returns the ShadowLight absolute position in the World.
  10931. * @returns the position vector in world space
  10932. */
  10933. getAbsolutePosition(): Vector3;
  10934. /**
  10935. * Sets the ShadowLight direction toward the passed target.
  10936. * @param target The point to target in local space
  10937. * @returns the updated ShadowLight direction
  10938. */
  10939. setDirectionToTarget(target: Vector3): Vector3;
  10940. /**
  10941. * Returns the light rotation in euler definition.
  10942. * @returns the x y z rotation in local space.
  10943. */
  10944. getRotation(): Vector3;
  10945. /**
  10946. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10947. * @returns true if a cube texture needs to be use
  10948. */
  10949. needCube(): boolean;
  10950. /**
  10951. * Detects if the projection matrix requires to be recomputed this frame.
  10952. * @returns true if it requires to be recomputed otherwise, false.
  10953. */
  10954. needProjectionMatrixCompute(): boolean;
  10955. /**
  10956. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10957. */
  10958. forceProjectionMatrixCompute(): void;
  10959. /** @hidden */
  10960. _initCache(): void;
  10961. /** @hidden */
  10962. _isSynchronized(): boolean;
  10963. /**
  10964. * Computes the world matrix of the node
  10965. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10966. * @returns the world matrix
  10967. */
  10968. computeWorldMatrix(force?: boolean): Matrix;
  10969. /**
  10970. * Gets the minZ used for shadow according to both the scene and the light.
  10971. * @param activeCamera The camera we are returning the min for
  10972. * @returns the depth min z
  10973. */
  10974. getDepthMinZ(activeCamera: Camera): number;
  10975. /**
  10976. * Gets the maxZ used for shadow according to both the scene and the light.
  10977. * @param activeCamera The camera we are returning the max for
  10978. * @returns the depth max z
  10979. */
  10980. getDepthMaxZ(activeCamera: Camera): number;
  10981. /**
  10982. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10983. * @param matrix The materix to updated with the projection information
  10984. * @param viewMatrix The transform matrix of the light
  10985. * @param renderList The list of mesh to render in the map
  10986. * @returns The current light
  10987. */
  10988. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10989. }
  10990. }
  10991. declare module "babylonjs/Materials/materialHelper" {
  10992. import { Nullable } from "babylonjs/types";
  10993. import { Scene } from "babylonjs/scene";
  10994. import { Engine } from "babylonjs/Engines/engine";
  10995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10996. import { Light } from "babylonjs/Lights/light";
  10997. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10998. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  10999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11000. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11001. /**
  11002. * "Static Class" containing the most commonly used helper while dealing with material for
  11003. * rendering purpose.
  11004. *
  11005. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11006. *
  11007. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11008. */
  11009. export class MaterialHelper {
  11010. /**
  11011. * Bind the current view position to an effect.
  11012. * @param effect The effect to be bound
  11013. * @param scene The scene the eyes position is used from
  11014. */
  11015. static BindEyePosition(effect: Effect, scene: Scene): void;
  11016. /**
  11017. * Helps preparing the defines values about the UVs in used in the effect.
  11018. * UVs are shared as much as we can accross channels in the shaders.
  11019. * @param texture The texture we are preparing the UVs for
  11020. * @param defines The defines to update
  11021. * @param key The channel key "diffuse", "specular"... used in the shader
  11022. */
  11023. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11024. /**
  11025. * Binds a texture matrix value to its corrsponding uniform
  11026. * @param texture The texture to bind the matrix for
  11027. * @param uniformBuffer The uniform buffer receivin the data
  11028. * @param key The channel key "diffuse", "specular"... used in the shader
  11029. */
  11030. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11031. /**
  11032. * Gets the current status of the fog (should it be enabled?)
  11033. * @param mesh defines the mesh to evaluate for fog support
  11034. * @param scene defines the hosting scene
  11035. * @returns true if fog must be enabled
  11036. */
  11037. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11038. /**
  11039. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11040. * @param mesh defines the current mesh
  11041. * @param scene defines the current scene
  11042. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11043. * @param pointsCloud defines if point cloud rendering has to be turned on
  11044. * @param fogEnabled defines if fog has to be turned on
  11045. * @param alphaTest defines if alpha testing has to be turned on
  11046. * @param defines defines the current list of defines
  11047. */
  11048. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11049. /**
  11050. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11051. * @param scene defines the current scene
  11052. * @param engine defines the current engine
  11053. * @param defines specifies the list of active defines
  11054. * @param useInstances defines if instances have to be turned on
  11055. * @param useClipPlane defines if clip plane have to be turned on
  11056. */
  11057. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11058. /**
  11059. * Prepares the defines for bones
  11060. * @param mesh The mesh containing the geometry data we will draw
  11061. * @param defines The defines to update
  11062. */
  11063. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11064. /**
  11065. * Prepares the defines for morph targets
  11066. * @param mesh The mesh containing the geometry data we will draw
  11067. * @param defines The defines to update
  11068. */
  11069. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11070. /**
  11071. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11072. * @param mesh The mesh containing the geometry data we will draw
  11073. * @param defines The defines to update
  11074. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11075. * @param useBones Precise whether bones should be used or not (override mesh info)
  11076. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11077. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11078. * @returns false if defines are considered not dirty and have not been checked
  11079. */
  11080. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11081. /**
  11082. * Prepares the defines related to multiview
  11083. * @param scene The scene we are intending to draw
  11084. * @param defines The defines to update
  11085. */
  11086. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11087. /**
  11088. * Prepares the defines related to the light information passed in parameter
  11089. * @param scene The scene we are intending to draw
  11090. * @param mesh The mesh the effect is compiling for
  11091. * @param defines The defines to update
  11092. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11093. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11094. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11095. * @returns true if normals will be required for the rest of the effect
  11096. */
  11097. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11098. /**
  11099. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  11100. * that won t be acctive due to defines being turned off.
  11101. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11102. * @param samplersList The samplers list
  11103. * @param defines The defines helping in the list generation
  11104. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11105. */
  11106. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11107. /**
  11108. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11109. * @param defines The defines to update while falling back
  11110. * @param fallbacks The authorized effect fallbacks
  11111. * @param maxSimultaneousLights The maximum number of lights allowed
  11112. * @param rank the current rank of the Effect
  11113. * @returns The newly affected rank
  11114. */
  11115. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11116. /**
  11117. * Prepares the list of attributes required for morph targets according to the effect defines.
  11118. * @param attribs The current list of supported attribs
  11119. * @param mesh The mesh to prepare the morph targets attributes for
  11120. * @param defines The current Defines of the effect
  11121. */
  11122. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11123. /**
  11124. * Prepares the list of attributes required for bones according to the effect defines.
  11125. * @param attribs The current list of supported attribs
  11126. * @param mesh The mesh to prepare the bones attributes for
  11127. * @param defines The current Defines of the effect
  11128. * @param fallbacks The current efffect fallback strategy
  11129. */
  11130. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11131. /**
  11132. * Check and prepare the list of attributes required for instances according to the effect defines.
  11133. * @param attribs The current list of supported attribs
  11134. * @param defines The current MaterialDefines of the effect
  11135. */
  11136. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11137. /**
  11138. * Add the list of attributes required for instances to the attribs array.
  11139. * @param attribs The current list of supported attribs
  11140. */
  11141. static PushAttributesForInstances(attribs: string[]): void;
  11142. /**
  11143. * Binds the light shadow information to the effect for the given mesh.
  11144. * @param light The light containing the generator
  11145. * @param scene The scene the lights belongs to
  11146. * @param mesh The mesh we are binding the information to render
  11147. * @param lightIndex The light index in the effect used to render the mesh
  11148. * @param effect The effect we are binding the data to
  11149. */
  11150. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11151. /**
  11152. * Binds the light information to the effect.
  11153. * @param light The light containing the generator
  11154. * @param effect The effect we are binding the data to
  11155. * @param lightIndex The light index in the effect used to render
  11156. */
  11157. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11158. /**
  11159. * Binds the lights information from the scene to the effect for the given mesh.
  11160. * @param scene The scene the lights belongs to
  11161. * @param mesh The mesh we are binding the information to render
  11162. * @param effect The effect we are binding the data to
  11163. * @param defines The generated defines for the effect
  11164. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11165. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11166. */
  11167. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11168. private static _tempFogColor;
  11169. /**
  11170. * Binds the fog information from the scene to the effect for the given mesh.
  11171. * @param scene The scene the lights belongs to
  11172. * @param mesh The mesh we are binding the information to render
  11173. * @param effect The effect we are binding the data to
  11174. * @param linearSpace Defines if the fog effect is applied in linear space
  11175. */
  11176. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11177. /**
  11178. * Binds the bones information from the mesh to the effect.
  11179. * @param mesh The mesh we are binding the information to render
  11180. * @param effect The effect we are binding the data to
  11181. */
  11182. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11183. /**
  11184. * Binds the morph targets information from the mesh to the effect.
  11185. * @param abstractMesh The mesh we are binding the information to render
  11186. * @param effect The effect we are binding the data to
  11187. */
  11188. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11189. /**
  11190. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11191. * @param defines The generated defines used in the effect
  11192. * @param effect The effect we are binding the data to
  11193. * @param scene The scene we are willing to render with logarithmic scale for
  11194. */
  11195. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11196. /**
  11197. * Binds the clip plane information from the scene to the effect.
  11198. * @param scene The scene the clip plane information are extracted from
  11199. * @param effect The effect we are binding the data to
  11200. */
  11201. static BindClipPlane(effect: Effect, scene: Scene): void;
  11202. }
  11203. }
  11204. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11205. /** @hidden */
  11206. export var shadowMapPixelShader: {
  11207. name: string;
  11208. shader: string;
  11209. };
  11210. }
  11211. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11212. /** @hidden */
  11213. export var bonesDeclaration: {
  11214. name: string;
  11215. shader: string;
  11216. };
  11217. }
  11218. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11219. /** @hidden */
  11220. export var morphTargetsVertexGlobalDeclaration: {
  11221. name: string;
  11222. shader: string;
  11223. };
  11224. }
  11225. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11226. /** @hidden */
  11227. export var morphTargetsVertexDeclaration: {
  11228. name: string;
  11229. shader: string;
  11230. };
  11231. }
  11232. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11233. /** @hidden */
  11234. export var instancesDeclaration: {
  11235. name: string;
  11236. shader: string;
  11237. };
  11238. }
  11239. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11240. /** @hidden */
  11241. export var helperFunctions: {
  11242. name: string;
  11243. shader: string;
  11244. };
  11245. }
  11246. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11247. /** @hidden */
  11248. export var morphTargetsVertex: {
  11249. name: string;
  11250. shader: string;
  11251. };
  11252. }
  11253. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11254. /** @hidden */
  11255. export var instancesVertex: {
  11256. name: string;
  11257. shader: string;
  11258. };
  11259. }
  11260. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11261. /** @hidden */
  11262. export var bonesVertex: {
  11263. name: string;
  11264. shader: string;
  11265. };
  11266. }
  11267. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11268. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11269. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11270. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11271. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11272. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11273. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11274. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11275. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11276. /** @hidden */
  11277. export var shadowMapVertexShader: {
  11278. name: string;
  11279. shader: string;
  11280. };
  11281. }
  11282. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11283. /** @hidden */
  11284. export var depthBoxBlurPixelShader: {
  11285. name: string;
  11286. shader: string;
  11287. };
  11288. }
  11289. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11290. import { Nullable } from "babylonjs/types";
  11291. import { Scene } from "babylonjs/scene";
  11292. import { Matrix } from "babylonjs/Maths/math";
  11293. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11295. import { Mesh } from "babylonjs/Meshes/mesh";
  11296. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11297. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11298. import { Effect } from "babylonjs/Materials/effect";
  11299. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11300. import "babylonjs/Shaders/shadowMap.fragment";
  11301. import "babylonjs/Shaders/shadowMap.vertex";
  11302. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11303. import { Observable } from "babylonjs/Misc/observable";
  11304. /**
  11305. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11306. */
  11307. export interface ICustomShaderOptions {
  11308. /**
  11309. * Gets or sets the custom shader name to use
  11310. */
  11311. shaderName: string;
  11312. /**
  11313. * The list of attribute names used in the shader
  11314. */
  11315. attributes?: string[];
  11316. /**
  11317. * The list of unifrom names used in the shader
  11318. */
  11319. uniforms?: string[];
  11320. /**
  11321. * The list of sampler names used in the shader
  11322. */
  11323. samplers?: string[];
  11324. /**
  11325. * The list of defines used in the shader
  11326. */
  11327. defines?: string[];
  11328. }
  11329. /**
  11330. * Interface to implement to create a shadow generator compatible with BJS.
  11331. */
  11332. export interface IShadowGenerator {
  11333. /**
  11334. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11335. * @returns The render target texture if present otherwise, null
  11336. */
  11337. getShadowMap(): Nullable<RenderTargetTexture>;
  11338. /**
  11339. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11340. * @returns The render target texture if the shadow map is present otherwise, null
  11341. */
  11342. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11343. /**
  11344. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11345. * @param subMesh The submesh we want to render in the shadow map
  11346. * @param useInstances Defines wether will draw in the map using instances
  11347. * @returns true if ready otherwise, false
  11348. */
  11349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11350. /**
  11351. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11352. * @param defines Defines of the material we want to update
  11353. * @param lightIndex Index of the light in the enabled light list of the material
  11354. */
  11355. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11356. /**
  11357. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11358. * defined in the generator but impacting the effect).
  11359. * It implies the unifroms available on the materials are the standard BJS ones.
  11360. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11361. * @param effect The effect we are binfing the information for
  11362. */
  11363. bindShadowLight(lightIndex: string, effect: Effect): void;
  11364. /**
  11365. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11366. * (eq to shadow prjection matrix * light transform matrix)
  11367. * @returns The transform matrix used to create the shadow map
  11368. */
  11369. getTransformMatrix(): Matrix;
  11370. /**
  11371. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11372. * Cube and 2D textures for instance.
  11373. */
  11374. recreateShadowMap(): void;
  11375. /**
  11376. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11377. * @param onCompiled Callback triggered at the and of the effects compilation
  11378. * @param options Sets of optional options forcing the compilation with different modes
  11379. */
  11380. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11381. useInstances: boolean;
  11382. }>): void;
  11383. /**
  11384. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11385. * @param options Sets of optional options forcing the compilation with different modes
  11386. * @returns A promise that resolves when the compilation completes
  11387. */
  11388. forceCompilationAsync(options?: Partial<{
  11389. useInstances: boolean;
  11390. }>): Promise<void>;
  11391. /**
  11392. * Serializes the shadow generator setup to a json object.
  11393. * @returns The serialized JSON object
  11394. */
  11395. serialize(): any;
  11396. /**
  11397. * Disposes the Shadow map and related Textures and effects.
  11398. */
  11399. dispose(): void;
  11400. }
  11401. /**
  11402. * Default implementation IShadowGenerator.
  11403. * This is the main object responsible of generating shadows in the framework.
  11404. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11405. */
  11406. export class ShadowGenerator implements IShadowGenerator {
  11407. /**
  11408. * Shadow generator mode None: no filtering applied.
  11409. */
  11410. static readonly FILTER_NONE: number;
  11411. /**
  11412. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11413. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11414. */
  11415. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11416. /**
  11417. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11418. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11419. */
  11420. static readonly FILTER_POISSONSAMPLING: number;
  11421. /**
  11422. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11423. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11424. */
  11425. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11426. /**
  11427. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11428. * edge artifacts on steep falloff.
  11429. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11430. */
  11431. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11432. /**
  11433. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11434. * edge artifacts on steep falloff.
  11435. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11436. */
  11437. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11438. /**
  11439. * Shadow generator mode PCF: Percentage Closer Filtering
  11440. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11441. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11442. */
  11443. static readonly FILTER_PCF: number;
  11444. /**
  11445. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11446. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11447. * Contact Hardening
  11448. */
  11449. static readonly FILTER_PCSS: number;
  11450. /**
  11451. * Reserved for PCF and PCSS
  11452. * Highest Quality.
  11453. *
  11454. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11455. *
  11456. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11457. */
  11458. static readonly QUALITY_HIGH: number;
  11459. /**
  11460. * Reserved for PCF and PCSS
  11461. * Good tradeoff for quality/perf cross devices
  11462. *
  11463. * Execute PCF on a 3*3 kernel.
  11464. *
  11465. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11466. */
  11467. static readonly QUALITY_MEDIUM: number;
  11468. /**
  11469. * Reserved for PCF and PCSS
  11470. * The lowest quality but the fastest.
  11471. *
  11472. * Execute PCF on a 1*1 kernel.
  11473. *
  11474. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11475. */
  11476. static readonly QUALITY_LOW: number;
  11477. /** Gets or sets the custom shader name to use */
  11478. customShaderOptions: ICustomShaderOptions;
  11479. /**
  11480. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11481. */
  11482. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11483. /**
  11484. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11485. */
  11486. onAfterShadowMapRenderObservable: Observable<Effect>;
  11487. /**
  11488. * Observable triggered before a mesh is rendered in the shadow map.
  11489. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11490. */
  11491. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11492. /**
  11493. * Observable triggered after a mesh is rendered in the shadow map.
  11494. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11495. */
  11496. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11497. private _bias;
  11498. /**
  11499. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11500. */
  11501. /**
  11502. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11503. */
  11504. bias: number;
  11505. private _normalBias;
  11506. /**
  11507. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11508. */
  11509. /**
  11510. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11511. */
  11512. normalBias: number;
  11513. private _blurBoxOffset;
  11514. /**
  11515. * Gets the blur box offset: offset applied during the blur pass.
  11516. * Only useful if useKernelBlur = false
  11517. */
  11518. /**
  11519. * Sets the blur box offset: offset applied during the blur pass.
  11520. * Only useful if useKernelBlur = false
  11521. */
  11522. blurBoxOffset: number;
  11523. private _blurScale;
  11524. /**
  11525. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11526. * 2 means half of the size.
  11527. */
  11528. /**
  11529. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11530. * 2 means half of the size.
  11531. */
  11532. blurScale: number;
  11533. private _blurKernel;
  11534. /**
  11535. * Gets the blur kernel: kernel size of the blur pass.
  11536. * Only useful if useKernelBlur = true
  11537. */
  11538. /**
  11539. * Sets the blur kernel: kernel size of the blur pass.
  11540. * Only useful if useKernelBlur = true
  11541. */
  11542. blurKernel: number;
  11543. private _useKernelBlur;
  11544. /**
  11545. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11546. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11547. */
  11548. /**
  11549. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11550. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11551. */
  11552. useKernelBlur: boolean;
  11553. private _depthScale;
  11554. /**
  11555. * Gets the depth scale used in ESM mode.
  11556. */
  11557. /**
  11558. * Sets the depth scale used in ESM mode.
  11559. * This can override the scale stored on the light.
  11560. */
  11561. depthScale: number;
  11562. private _filter;
  11563. /**
  11564. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11565. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11566. */
  11567. /**
  11568. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11569. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11570. */
  11571. filter: number;
  11572. /**
  11573. * Gets if the current filter is set to Poisson Sampling.
  11574. */
  11575. /**
  11576. * Sets the current filter to Poisson Sampling.
  11577. */
  11578. usePoissonSampling: boolean;
  11579. /**
  11580. * Gets if the current filter is set to ESM.
  11581. */
  11582. /**
  11583. * Sets the current filter is to ESM.
  11584. */
  11585. useExponentialShadowMap: boolean;
  11586. /**
  11587. * Gets if the current filter is set to filtered ESM.
  11588. */
  11589. /**
  11590. * Gets if the current filter is set to filtered ESM.
  11591. */
  11592. useBlurExponentialShadowMap: boolean;
  11593. /**
  11594. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11595. * exponential to prevent steep falloff artifacts).
  11596. */
  11597. /**
  11598. * Sets the current filter to "close ESM" (using the inverse of the
  11599. * exponential to prevent steep falloff artifacts).
  11600. */
  11601. useCloseExponentialShadowMap: boolean;
  11602. /**
  11603. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11604. * exponential to prevent steep falloff artifacts).
  11605. */
  11606. /**
  11607. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11608. * exponential to prevent steep falloff artifacts).
  11609. */
  11610. useBlurCloseExponentialShadowMap: boolean;
  11611. /**
  11612. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11613. */
  11614. /**
  11615. * Sets the current filter to "PCF" (percentage closer filtering).
  11616. */
  11617. usePercentageCloserFiltering: boolean;
  11618. private _filteringQuality;
  11619. /**
  11620. * Gets the PCF or PCSS Quality.
  11621. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11622. */
  11623. /**
  11624. * Sets the PCF or PCSS Quality.
  11625. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11626. */
  11627. filteringQuality: number;
  11628. /**
  11629. * Gets if the current filter is set to "PCSS" (contact hardening).
  11630. */
  11631. /**
  11632. * Sets the current filter to "PCSS" (contact hardening).
  11633. */
  11634. useContactHardeningShadow: boolean;
  11635. private _contactHardeningLightSizeUVRatio;
  11636. /**
  11637. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11638. * Using a ratio helps keeping shape stability independently of the map size.
  11639. *
  11640. * It does not account for the light projection as it was having too much
  11641. * instability during the light setup or during light position changes.
  11642. *
  11643. * Only valid if useContactHardeningShadow is true.
  11644. */
  11645. /**
  11646. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11647. * Using a ratio helps keeping shape stability independently of the map size.
  11648. *
  11649. * It does not account for the light projection as it was having too much
  11650. * instability during the light setup or during light position changes.
  11651. *
  11652. * Only valid if useContactHardeningShadow is true.
  11653. */
  11654. contactHardeningLightSizeUVRatio: number;
  11655. private _darkness;
  11656. /** Gets or sets the actual darkness of a shadow */
  11657. darkness: number;
  11658. /**
  11659. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11660. * 0 means strongest and 1 would means no shadow.
  11661. * @returns the darkness.
  11662. */
  11663. getDarkness(): number;
  11664. /**
  11665. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11666. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11667. * @returns the shadow generator allowing fluent coding.
  11668. */
  11669. setDarkness(darkness: number): ShadowGenerator;
  11670. private _transparencyShadow;
  11671. /** Gets or sets the ability to have transparent shadow */
  11672. transparencyShadow: boolean;
  11673. /**
  11674. * Sets the ability to have transparent shadow (boolean).
  11675. * @param transparent True if transparent else False
  11676. * @returns the shadow generator allowing fluent coding
  11677. */
  11678. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11679. private _shadowMap;
  11680. private _shadowMap2;
  11681. /**
  11682. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11683. * @returns The render target texture if present otherwise, null
  11684. */
  11685. getShadowMap(): Nullable<RenderTargetTexture>;
  11686. /**
  11687. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11688. * @returns The render target texture if the shadow map is present otherwise, null
  11689. */
  11690. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11691. /**
  11692. * Gets the class name of that object
  11693. * @returns "ShadowGenerator"
  11694. */
  11695. getClassName(): string;
  11696. /**
  11697. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11698. * @param mesh Mesh to add
  11699. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11700. * @returns the Shadow Generator itself
  11701. */
  11702. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11703. /**
  11704. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11705. * @param mesh Mesh to remove
  11706. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11707. * @returns the Shadow Generator itself
  11708. */
  11709. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11710. /**
  11711. * Controls the extent to which the shadows fade out at the edge of the frustum
  11712. * Used only by directionals and spots
  11713. */
  11714. frustumEdgeFalloff: number;
  11715. private _light;
  11716. /**
  11717. * Returns the associated light object.
  11718. * @returns the light generating the shadow
  11719. */
  11720. getLight(): IShadowLight;
  11721. /**
  11722. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11723. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11724. * It might on the other hand introduce peter panning.
  11725. */
  11726. forceBackFacesOnly: boolean;
  11727. private _scene;
  11728. private _lightDirection;
  11729. private _effect;
  11730. private _viewMatrix;
  11731. private _projectionMatrix;
  11732. private _transformMatrix;
  11733. private _cachedPosition;
  11734. private _cachedDirection;
  11735. private _cachedDefines;
  11736. private _currentRenderID;
  11737. private _boxBlurPostprocess;
  11738. private _kernelBlurXPostprocess;
  11739. private _kernelBlurYPostprocess;
  11740. private _blurPostProcesses;
  11741. private _mapSize;
  11742. private _currentFaceIndex;
  11743. private _currentFaceIndexCache;
  11744. private _textureType;
  11745. private _defaultTextureMatrix;
  11746. /** @hidden */
  11747. static _SceneComponentInitialization: (scene: Scene) => void;
  11748. /**
  11749. * Creates a ShadowGenerator object.
  11750. * A ShadowGenerator is the required tool to use the shadows.
  11751. * Each light casting shadows needs to use its own ShadowGenerator.
  11752. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11753. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11754. * @param light The light object generating the shadows.
  11755. * @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.
  11756. */
  11757. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11758. private _initializeGenerator;
  11759. private _initializeShadowMap;
  11760. private _initializeBlurRTTAndPostProcesses;
  11761. private _renderForShadowMap;
  11762. private _renderSubMeshForShadowMap;
  11763. private _applyFilterValues;
  11764. /**
  11765. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11766. * @param onCompiled Callback triggered at the and of the effects compilation
  11767. * @param options Sets of optional options forcing the compilation with different modes
  11768. */
  11769. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11770. useInstances: boolean;
  11771. }>): void;
  11772. /**
  11773. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11774. * @param options Sets of optional options forcing the compilation with different modes
  11775. * @returns A promise that resolves when the compilation completes
  11776. */
  11777. forceCompilationAsync(options?: Partial<{
  11778. useInstances: boolean;
  11779. }>): Promise<void>;
  11780. /**
  11781. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11782. * @param subMesh The submesh we want to render in the shadow map
  11783. * @param useInstances Defines wether will draw in the map using instances
  11784. * @returns true if ready otherwise, false
  11785. */
  11786. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11787. /**
  11788. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11789. * @param defines Defines of the material we want to update
  11790. * @param lightIndex Index of the light in the enabled light list of the material
  11791. */
  11792. prepareDefines(defines: any, lightIndex: number): void;
  11793. /**
  11794. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11795. * defined in the generator but impacting the effect).
  11796. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11797. * @param effect The effect we are binfing the information for
  11798. */
  11799. bindShadowLight(lightIndex: string, effect: Effect): void;
  11800. /**
  11801. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11802. * (eq to shadow prjection matrix * light transform matrix)
  11803. * @returns The transform matrix used to create the shadow map
  11804. */
  11805. getTransformMatrix(): Matrix;
  11806. /**
  11807. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11808. * Cube and 2D textures for instance.
  11809. */
  11810. recreateShadowMap(): void;
  11811. private _disposeBlurPostProcesses;
  11812. private _disposeRTTandPostProcesses;
  11813. /**
  11814. * Disposes the ShadowGenerator.
  11815. * Returns nothing.
  11816. */
  11817. dispose(): void;
  11818. /**
  11819. * Serializes the shadow generator setup to a json object.
  11820. * @returns The serialized JSON object
  11821. */
  11822. serialize(): any;
  11823. /**
  11824. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11825. * @param parsedShadowGenerator The JSON object to parse
  11826. * @param scene The scene to create the shadow map for
  11827. * @returns The parsed shadow generator
  11828. */
  11829. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11830. }
  11831. }
  11832. declare module "babylonjs/Lights/light" {
  11833. import { Nullable } from "babylonjs/types";
  11834. import { Scene } from "babylonjs/scene";
  11835. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11836. import { Node } from "babylonjs/node";
  11837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11838. import { Effect } from "babylonjs/Materials/effect";
  11839. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11840. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11841. /**
  11842. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11843. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11844. * 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.
  11845. */
  11846. export abstract class Light extends Node {
  11847. /**
  11848. * Falloff Default: light is falling off following the material specification:
  11849. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11850. */
  11851. static readonly FALLOFF_DEFAULT: number;
  11852. /**
  11853. * Falloff Physical: light is falling off following the inverse squared distance law.
  11854. */
  11855. static readonly FALLOFF_PHYSICAL: number;
  11856. /**
  11857. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11858. * to enhance interoperability with other engines.
  11859. */
  11860. static readonly FALLOFF_GLTF: number;
  11861. /**
  11862. * Falloff Standard: light is falling off like in the standard material
  11863. * to enhance interoperability with other materials.
  11864. */
  11865. static readonly FALLOFF_STANDARD: number;
  11866. /**
  11867. * If every light affecting the material is in this lightmapMode,
  11868. * material.lightmapTexture adds or multiplies
  11869. * (depends on material.useLightmapAsShadowmap)
  11870. * after every other light calculations.
  11871. */
  11872. static readonly LIGHTMAP_DEFAULT: number;
  11873. /**
  11874. * material.lightmapTexture as only diffuse lighting from this light
  11875. * adds only specular lighting from this light
  11876. * adds dynamic shadows
  11877. */
  11878. static readonly LIGHTMAP_SPECULAR: number;
  11879. /**
  11880. * material.lightmapTexture as only lighting
  11881. * no light calculation from this light
  11882. * only adds dynamic shadows from this light
  11883. */
  11884. static readonly LIGHTMAP_SHADOWSONLY: number;
  11885. /**
  11886. * Each light type uses the default quantity according to its type:
  11887. * point/spot lights use luminous intensity
  11888. * directional lights use illuminance
  11889. */
  11890. static readonly INTENSITYMODE_AUTOMATIC: number;
  11891. /**
  11892. * lumen (lm)
  11893. */
  11894. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11895. /**
  11896. * candela (lm/sr)
  11897. */
  11898. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11899. /**
  11900. * lux (lm/m^2)
  11901. */
  11902. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11903. /**
  11904. * nit (cd/m^2)
  11905. */
  11906. static readonly INTENSITYMODE_LUMINANCE: number;
  11907. /**
  11908. * Light type const id of the point light.
  11909. */
  11910. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11911. /**
  11912. * Light type const id of the directional light.
  11913. */
  11914. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11915. /**
  11916. * Light type const id of the spot light.
  11917. */
  11918. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11919. /**
  11920. * Light type const id of the hemispheric light.
  11921. */
  11922. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11923. /**
  11924. * Diffuse gives the basic color to an object.
  11925. */
  11926. diffuse: Color3;
  11927. /**
  11928. * Specular produces a highlight color on an object.
  11929. * Note: This is note affecting PBR materials.
  11930. */
  11931. specular: Color3;
  11932. /**
  11933. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11934. * falling off base on range or angle.
  11935. * This can be set to any values in Light.FALLOFF_x.
  11936. *
  11937. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11938. * other types of materials.
  11939. */
  11940. falloffType: number;
  11941. /**
  11942. * Strength of the light.
  11943. * Note: By default it is define in the framework own unit.
  11944. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11945. */
  11946. intensity: number;
  11947. private _range;
  11948. protected _inverseSquaredRange: number;
  11949. /**
  11950. * Defines how far from the source the light is impacting in scene units.
  11951. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11952. */
  11953. /**
  11954. * Defines how far from the source the light is impacting in scene units.
  11955. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11956. */
  11957. range: number;
  11958. /**
  11959. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11960. * of light.
  11961. */
  11962. private _photometricScale;
  11963. private _intensityMode;
  11964. /**
  11965. * Gets the photometric scale used to interpret the intensity.
  11966. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11967. */
  11968. /**
  11969. * Sets the photometric scale used to interpret the intensity.
  11970. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11971. */
  11972. intensityMode: number;
  11973. private _radius;
  11974. /**
  11975. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11976. */
  11977. /**
  11978. * sets the light radius used by PBR Materials to simulate soft area lights.
  11979. */
  11980. radius: number;
  11981. private _renderPriority;
  11982. /**
  11983. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11984. * exceeding the number allowed of the materials.
  11985. */
  11986. renderPriority: number;
  11987. private _shadowEnabled;
  11988. /**
  11989. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11990. * the current shadow generator.
  11991. */
  11992. /**
  11993. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11994. * the current shadow generator.
  11995. */
  11996. shadowEnabled: boolean;
  11997. private _includedOnlyMeshes;
  11998. /**
  11999. * Gets the only meshes impacted by this light.
  12000. */
  12001. /**
  12002. * Sets the only meshes impacted by this light.
  12003. */
  12004. includedOnlyMeshes: AbstractMesh[];
  12005. private _excludedMeshes;
  12006. /**
  12007. * Gets the meshes not impacted by this light.
  12008. */
  12009. /**
  12010. * Sets the meshes not impacted by this light.
  12011. */
  12012. excludedMeshes: AbstractMesh[];
  12013. private _excludeWithLayerMask;
  12014. /**
  12015. * Gets the layer id use to find what meshes are not impacted by the light.
  12016. * Inactive if 0
  12017. */
  12018. /**
  12019. * Sets the layer id use to find what meshes are not impacted by the light.
  12020. * Inactive if 0
  12021. */
  12022. excludeWithLayerMask: number;
  12023. private _includeOnlyWithLayerMask;
  12024. /**
  12025. * Gets the layer id use to find what meshes are impacted by the light.
  12026. * Inactive if 0
  12027. */
  12028. /**
  12029. * Sets the layer id use to find what meshes are impacted by the light.
  12030. * Inactive if 0
  12031. */
  12032. includeOnlyWithLayerMask: number;
  12033. private _lightmapMode;
  12034. /**
  12035. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12036. */
  12037. /**
  12038. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12039. */
  12040. lightmapMode: number;
  12041. /**
  12042. * Shadow generator associted to the light.
  12043. * @hidden Internal use only.
  12044. */
  12045. _shadowGenerator: Nullable<IShadowGenerator>;
  12046. /**
  12047. * @hidden Internal use only.
  12048. */
  12049. _excludedMeshesIds: string[];
  12050. /**
  12051. * @hidden Internal use only.
  12052. */
  12053. _includedOnlyMeshesIds: string[];
  12054. /**
  12055. * The current light unifom buffer.
  12056. * @hidden Internal use only.
  12057. */
  12058. _uniformBuffer: UniformBuffer;
  12059. /**
  12060. * Creates a Light object in the scene.
  12061. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12062. * @param name The firendly name of the light
  12063. * @param scene The scene the light belongs too
  12064. */
  12065. constructor(name: string, scene: Scene);
  12066. protected abstract _buildUniformLayout(): void;
  12067. /**
  12068. * Sets the passed Effect "effect" with the Light information.
  12069. * @param effect The effect to update
  12070. * @param lightIndex The index of the light in the effect to update
  12071. * @returns The light
  12072. */
  12073. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12074. /**
  12075. * Returns the string "Light".
  12076. * @returns the class name
  12077. */
  12078. getClassName(): string;
  12079. /** @hidden */
  12080. readonly _isLight: boolean;
  12081. /**
  12082. * Converts the light information to a readable string for debug purpose.
  12083. * @param fullDetails Supports for multiple levels of logging within scene loading
  12084. * @returns the human readable light info
  12085. */
  12086. toString(fullDetails?: boolean): string;
  12087. /** @hidden */
  12088. protected _syncParentEnabledState(): void;
  12089. /**
  12090. * Set the enabled state of this node.
  12091. * @param value - the new enabled state
  12092. */
  12093. setEnabled(value: boolean): void;
  12094. /**
  12095. * Returns the Light associated shadow generator if any.
  12096. * @return the associated shadow generator.
  12097. */
  12098. getShadowGenerator(): Nullable<IShadowGenerator>;
  12099. /**
  12100. * Returns a Vector3, the absolute light position in the World.
  12101. * @returns the world space position of the light
  12102. */
  12103. getAbsolutePosition(): Vector3;
  12104. /**
  12105. * Specifies if the light will affect the passed mesh.
  12106. * @param mesh The mesh to test against the light
  12107. * @return true the mesh is affected otherwise, false.
  12108. */
  12109. canAffectMesh(mesh: AbstractMesh): boolean;
  12110. /**
  12111. * Sort function to order lights for rendering.
  12112. * @param a First Light object to compare to second.
  12113. * @param b Second Light object to compare first.
  12114. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12115. */
  12116. static CompareLightsPriority(a: Light, b: Light): number;
  12117. /**
  12118. * Releases resources associated with this node.
  12119. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12120. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12121. */
  12122. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12123. /**
  12124. * Returns the light type ID (integer).
  12125. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12126. */
  12127. getTypeID(): number;
  12128. /**
  12129. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12130. * @returns the scaled intensity in intensity mode unit
  12131. */
  12132. getScaledIntensity(): number;
  12133. /**
  12134. * Returns a new Light object, named "name", from the current one.
  12135. * @param name The name of the cloned light
  12136. * @returns the new created light
  12137. */
  12138. clone(name: string): Nullable<Light>;
  12139. /**
  12140. * Serializes the current light into a Serialization object.
  12141. * @returns the serialized object.
  12142. */
  12143. serialize(): any;
  12144. /**
  12145. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12146. * This new light is named "name" and added to the passed scene.
  12147. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12148. * @param name The friendly name of the light
  12149. * @param scene The scene the new light will belong to
  12150. * @returns the constructor function
  12151. */
  12152. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12153. /**
  12154. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12155. * @param parsedLight The JSON representation of the light
  12156. * @param scene The scene to create the parsed light in
  12157. * @returns the created light after parsing
  12158. */
  12159. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12160. private _hookArrayForExcluded;
  12161. private _hookArrayForIncludedOnly;
  12162. private _resyncMeshes;
  12163. /**
  12164. * Forces the meshes to update their light related information in their rendering used effects
  12165. * @hidden Internal Use Only
  12166. */
  12167. _markMeshesAsLightDirty(): void;
  12168. /**
  12169. * Recomputes the cached photometric scale if needed.
  12170. */
  12171. private _computePhotometricScale;
  12172. /**
  12173. * Returns the Photometric Scale according to the light type and intensity mode.
  12174. */
  12175. private _getPhotometricScale;
  12176. /**
  12177. * Reorder the light in the scene according to their defined priority.
  12178. * @hidden Internal Use Only
  12179. */
  12180. _reorderLightsInScene(): void;
  12181. /**
  12182. * Prepares the list of defines specific to the light type.
  12183. * @param defines the list of defines
  12184. * @param lightIndex defines the index of the light for the effect
  12185. */
  12186. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12187. }
  12188. }
  12189. declare module "babylonjs/Meshes/instancedMesh" {
  12190. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12191. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12192. import { Camera } from "babylonjs/Cameras/camera";
  12193. import { Node } from "babylonjs/node";
  12194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12195. import { Mesh } from "babylonjs/Meshes/mesh";
  12196. import { Material } from "babylonjs/Materials/material";
  12197. import { Skeleton } from "babylonjs/Bones/skeleton";
  12198. import { Light } from "babylonjs/Lights/light";
  12199. /**
  12200. * Creates an instance based on a source mesh.
  12201. */
  12202. export class InstancedMesh extends AbstractMesh {
  12203. private _sourceMesh;
  12204. private _currentLOD;
  12205. /** @hidden */
  12206. _indexInSourceMeshInstanceArray: number;
  12207. constructor(name: string, source: Mesh);
  12208. /**
  12209. * Returns the string "InstancedMesh".
  12210. */
  12211. getClassName(): string;
  12212. /** Gets the list of lights affecting that mesh */
  12213. readonly lightSources: Light[];
  12214. _resyncLightSources(): void;
  12215. _resyncLighSource(light: Light): void;
  12216. _removeLightSource(light: Light): void;
  12217. /**
  12218. * If the source mesh receives shadows
  12219. */
  12220. readonly receiveShadows: boolean;
  12221. /**
  12222. * The material of the source mesh
  12223. */
  12224. readonly material: Nullable<Material>;
  12225. /**
  12226. * Visibility of the source mesh
  12227. */
  12228. readonly visibility: number;
  12229. /**
  12230. * Skeleton of the source mesh
  12231. */
  12232. readonly skeleton: Nullable<Skeleton>;
  12233. /**
  12234. * Rendering ground id of the source mesh
  12235. */
  12236. renderingGroupId: number;
  12237. /**
  12238. * Returns the total number of vertices (integer).
  12239. */
  12240. getTotalVertices(): number;
  12241. /**
  12242. * Returns a positive integer : the total number of indices in this mesh geometry.
  12243. * @returns the numner of indices or zero if the mesh has no geometry.
  12244. */
  12245. getTotalIndices(): number;
  12246. /**
  12247. * The source mesh of the instance
  12248. */
  12249. readonly sourceMesh: Mesh;
  12250. /**
  12251. * Is this node ready to be used/rendered
  12252. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12253. * @return {boolean} is it ready
  12254. */
  12255. isReady(completeCheck?: boolean): boolean;
  12256. /**
  12257. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12258. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12259. * @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.
  12260. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12261. */
  12262. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12263. /**
  12264. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12265. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12266. * The `data` are either a numeric array either a Float32Array.
  12267. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12268. * 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).
  12269. * Note that a new underlying VertexBuffer object is created each call.
  12270. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12271. *
  12272. * Possible `kind` values :
  12273. * - VertexBuffer.PositionKind
  12274. * - VertexBuffer.UVKind
  12275. * - VertexBuffer.UV2Kind
  12276. * - VertexBuffer.UV3Kind
  12277. * - VertexBuffer.UV4Kind
  12278. * - VertexBuffer.UV5Kind
  12279. * - VertexBuffer.UV6Kind
  12280. * - VertexBuffer.ColorKind
  12281. * - VertexBuffer.MatricesIndicesKind
  12282. * - VertexBuffer.MatricesIndicesExtraKind
  12283. * - VertexBuffer.MatricesWeightsKind
  12284. * - VertexBuffer.MatricesWeightsExtraKind
  12285. *
  12286. * Returns the Mesh.
  12287. */
  12288. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12289. /**
  12290. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12291. * If the mesh has no geometry, it is simply returned as it is.
  12292. * The `data` are either a numeric array either a Float32Array.
  12293. * No new underlying VertexBuffer object is created.
  12294. * 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.
  12295. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12296. *
  12297. * Possible `kind` values :
  12298. * - VertexBuffer.PositionKind
  12299. * - VertexBuffer.UVKind
  12300. * - VertexBuffer.UV2Kind
  12301. * - VertexBuffer.UV3Kind
  12302. * - VertexBuffer.UV4Kind
  12303. * - VertexBuffer.UV5Kind
  12304. * - VertexBuffer.UV6Kind
  12305. * - VertexBuffer.ColorKind
  12306. * - VertexBuffer.MatricesIndicesKind
  12307. * - VertexBuffer.MatricesIndicesExtraKind
  12308. * - VertexBuffer.MatricesWeightsKind
  12309. * - VertexBuffer.MatricesWeightsExtraKind
  12310. *
  12311. * Returns the Mesh.
  12312. */
  12313. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12314. /**
  12315. * Sets the mesh indices.
  12316. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12317. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12318. * This method creates a new index buffer each call.
  12319. * Returns the Mesh.
  12320. */
  12321. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12322. /**
  12323. * Boolean : True if the mesh owns the requested kind of data.
  12324. */
  12325. isVerticesDataPresent(kind: string): boolean;
  12326. /**
  12327. * Returns an array of indices (IndicesArray).
  12328. */
  12329. getIndices(): Nullable<IndicesArray>;
  12330. readonly _positions: Nullable<Vector3[]>;
  12331. /**
  12332. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12333. * This means the mesh underlying bounding box and sphere are recomputed.
  12334. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12335. * @returns the current mesh
  12336. */
  12337. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12338. /** @hidden */
  12339. _preActivate(): InstancedMesh;
  12340. /** @hidden */
  12341. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12342. /** @hidden */
  12343. _postActivate(): void;
  12344. getWorldMatrix(): Matrix;
  12345. readonly isAnInstance: boolean;
  12346. /**
  12347. * Returns the current associated LOD AbstractMesh.
  12348. */
  12349. getLOD(camera: Camera): AbstractMesh;
  12350. /** @hidden */
  12351. _syncSubMeshes(): InstancedMesh;
  12352. /** @hidden */
  12353. _generatePointsArray(): boolean;
  12354. /**
  12355. * Creates a new InstancedMesh from the current mesh.
  12356. * - name (string) : the cloned mesh name
  12357. * - newParent (optional Node) : the optional Node to parent the clone to.
  12358. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12359. *
  12360. * Returns the clone.
  12361. */
  12362. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12363. /**
  12364. * Disposes the InstancedMesh.
  12365. * Returns nothing.
  12366. */
  12367. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12368. }
  12369. }
  12370. declare module "babylonjs/Materials/shaderMaterial" {
  12371. import { Scene } from "babylonjs/scene";
  12372. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12374. import { Mesh } from "babylonjs/Meshes/mesh";
  12375. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12377. import { Texture } from "babylonjs/Materials/Textures/texture";
  12378. import { Material } from "babylonjs/Materials/material";
  12379. /**
  12380. * Defines the options associated with the creation of a shader material.
  12381. */
  12382. export interface IShaderMaterialOptions {
  12383. /**
  12384. * Does the material work in alpha blend mode
  12385. */
  12386. needAlphaBlending: boolean;
  12387. /**
  12388. * Does the material work in alpha test mode
  12389. */
  12390. needAlphaTesting: boolean;
  12391. /**
  12392. * The list of attribute names used in the shader
  12393. */
  12394. attributes: string[];
  12395. /**
  12396. * The list of unifrom names used in the shader
  12397. */
  12398. uniforms: string[];
  12399. /**
  12400. * The list of UBO names used in the shader
  12401. */
  12402. uniformBuffers: string[];
  12403. /**
  12404. * The list of sampler names used in the shader
  12405. */
  12406. samplers: string[];
  12407. /**
  12408. * The list of defines used in the shader
  12409. */
  12410. defines: string[];
  12411. }
  12412. /**
  12413. * 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.
  12414. *
  12415. * This returned material effects how the mesh will look based on the code in the shaders.
  12416. *
  12417. * @see http://doc.babylonjs.com/how_to/shader_material
  12418. */
  12419. export class ShaderMaterial extends Material {
  12420. private _shaderPath;
  12421. private _options;
  12422. private _textures;
  12423. private _textureArrays;
  12424. private _floats;
  12425. private _ints;
  12426. private _floatsArrays;
  12427. private _colors3;
  12428. private _colors3Arrays;
  12429. private _colors4;
  12430. private _vectors2;
  12431. private _vectors3;
  12432. private _vectors4;
  12433. private _matrices;
  12434. private _matrices3x3;
  12435. private _matrices2x2;
  12436. private _vectors2Arrays;
  12437. private _vectors3Arrays;
  12438. private _cachedWorldViewMatrix;
  12439. private _cachedWorldViewProjectionMatrix;
  12440. private _renderId;
  12441. /**
  12442. * Instantiate a new shader material.
  12443. * 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.
  12444. * This returned material effects how the mesh will look based on the code in the shaders.
  12445. * @see http://doc.babylonjs.com/how_to/shader_material
  12446. * @param name Define the name of the material in the scene
  12447. * @param scene Define the scene the material belongs to
  12448. * @param shaderPath Defines the route to the shader code in one of three ways:
  12449. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12450. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12451. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12452. * @param options Define the options used to create the shader
  12453. */
  12454. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12455. /**
  12456. * Gets the options used to compile the shader.
  12457. * They can be modified to trigger a new compilation
  12458. */
  12459. readonly options: IShaderMaterialOptions;
  12460. /**
  12461. * Gets the current class name of the material e.g. "ShaderMaterial"
  12462. * Mainly use in serialization.
  12463. * @returns the class name
  12464. */
  12465. getClassName(): string;
  12466. /**
  12467. * Specifies if the material will require alpha blending
  12468. * @returns a boolean specifying if alpha blending is needed
  12469. */
  12470. needAlphaBlending(): boolean;
  12471. /**
  12472. * Specifies if this material should be rendered in alpha test mode
  12473. * @returns a boolean specifying if an alpha test is needed.
  12474. */
  12475. needAlphaTesting(): boolean;
  12476. private _checkUniform;
  12477. /**
  12478. * Set a texture in the shader.
  12479. * @param name Define the name of the uniform samplers as defined in the shader
  12480. * @param texture Define the texture to bind to this sampler
  12481. * @return the material itself allowing "fluent" like uniform updates
  12482. */
  12483. setTexture(name: string, texture: Texture): ShaderMaterial;
  12484. /**
  12485. * Set a texture array in the shader.
  12486. * @param name Define the name of the uniform sampler array as defined in the shader
  12487. * @param textures Define the list of textures to bind to this sampler
  12488. * @return the material itself allowing "fluent" like uniform updates
  12489. */
  12490. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12491. /**
  12492. * Set a float in the shader.
  12493. * @param name Define the name of the uniform as defined in the shader
  12494. * @param value Define the value to give to the uniform
  12495. * @return the material itself allowing "fluent" like uniform updates
  12496. */
  12497. setFloat(name: string, value: number): ShaderMaterial;
  12498. /**
  12499. * Set a int in the shader.
  12500. * @param name Define the name of the uniform as defined in the shader
  12501. * @param value Define the value to give to the uniform
  12502. * @return the material itself allowing "fluent" like uniform updates
  12503. */
  12504. setInt(name: string, value: number): ShaderMaterial;
  12505. /**
  12506. * Set an array of floats in the shader.
  12507. * @param name Define the name of the uniform as defined in the shader
  12508. * @param value Define the value to give to the uniform
  12509. * @return the material itself allowing "fluent" like uniform updates
  12510. */
  12511. setFloats(name: string, value: number[]): ShaderMaterial;
  12512. /**
  12513. * Set a vec3 in the shader from a Color3.
  12514. * @param name Define the name of the uniform as defined in the shader
  12515. * @param value Define the value to give to the uniform
  12516. * @return the material itself allowing "fluent" like uniform updates
  12517. */
  12518. setColor3(name: string, value: Color3): ShaderMaterial;
  12519. /**
  12520. * Set a vec3 array in the shader from a Color3 array.
  12521. * @param name Define the name of the uniform as defined in the shader
  12522. * @param value Define the value to give to the uniform
  12523. * @return the material itself allowing "fluent" like uniform updates
  12524. */
  12525. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12526. /**
  12527. * Set a vec4 in the shader from a Color4.
  12528. * @param name Define the name of the uniform as defined in the shader
  12529. * @param value Define the value to give to the uniform
  12530. * @return the material itself allowing "fluent" like uniform updates
  12531. */
  12532. setColor4(name: string, value: Color4): ShaderMaterial;
  12533. /**
  12534. * Set a vec2 in the shader from a Vector2.
  12535. * @param name Define the name of the uniform as defined in the shader
  12536. * @param value Define the value to give to the uniform
  12537. * @return the material itself allowing "fluent" like uniform updates
  12538. */
  12539. setVector2(name: string, value: Vector2): ShaderMaterial;
  12540. /**
  12541. * Set a vec3 in the shader from a Vector3.
  12542. * @param name Define the name of the uniform as defined in the shader
  12543. * @param value Define the value to give to the uniform
  12544. * @return the material itself allowing "fluent" like uniform updates
  12545. */
  12546. setVector3(name: string, value: Vector3): ShaderMaterial;
  12547. /**
  12548. * Set a vec4 in the shader from a Vector4.
  12549. * @param name Define the name of the uniform as defined in the shader
  12550. * @param value Define the value to give to the uniform
  12551. * @return the material itself allowing "fluent" like uniform updates
  12552. */
  12553. setVector4(name: string, value: Vector4): ShaderMaterial;
  12554. /**
  12555. * Set a mat4 in the shader from a Matrix.
  12556. * @param name Define the name of the uniform as defined in the shader
  12557. * @param value Define the value to give to the uniform
  12558. * @return the material itself allowing "fluent" like uniform updates
  12559. */
  12560. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12561. /**
  12562. * Set a mat3 in the shader from a Float32Array.
  12563. * @param name Define the name of the uniform as defined in the shader
  12564. * @param value Define the value to give to the uniform
  12565. * @return the material itself allowing "fluent" like uniform updates
  12566. */
  12567. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12568. /**
  12569. * Set a mat2 in the shader from a Float32Array.
  12570. * @param name Define the name of the uniform as defined in the shader
  12571. * @param value Define the value to give to the uniform
  12572. * @return the material itself allowing "fluent" like uniform updates
  12573. */
  12574. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12575. /**
  12576. * Set a vec2 array in the shader from a number array.
  12577. * @param name Define the name of the uniform as defined in the shader
  12578. * @param value Define the value to give to the uniform
  12579. * @return the material itself allowing "fluent" like uniform updates
  12580. */
  12581. setArray2(name: string, value: number[]): ShaderMaterial;
  12582. /**
  12583. * Set a vec3 array in the shader from a number array.
  12584. * @param name Define the name of the uniform as defined in the shader
  12585. * @param value Define the value to give to the uniform
  12586. * @return the material itself allowing "fluent" like uniform updates
  12587. */
  12588. setArray3(name: string, value: number[]): ShaderMaterial;
  12589. private _checkCache;
  12590. /**
  12591. * Specifies that the submesh is ready to be used
  12592. * @param mesh defines the mesh to check
  12593. * @param subMesh defines which submesh to check
  12594. * @param useInstances specifies that instances should be used
  12595. * @returns a boolean indicating that the submesh is ready or not
  12596. */
  12597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12598. /**
  12599. * Checks if the material is ready to render the requested mesh
  12600. * @param mesh Define the mesh to render
  12601. * @param useInstances Define whether or not the material is used with instances
  12602. * @returns true if ready, otherwise false
  12603. */
  12604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12605. /**
  12606. * Binds the world matrix to the material
  12607. * @param world defines the world transformation matrix
  12608. */
  12609. bindOnlyWorldMatrix(world: Matrix): void;
  12610. /**
  12611. * Binds the material to the mesh
  12612. * @param world defines the world transformation matrix
  12613. * @param mesh defines the mesh to bind the material to
  12614. */
  12615. bind(world: Matrix, mesh?: Mesh): void;
  12616. /**
  12617. * Gets the active textures from the material
  12618. * @returns an array of textures
  12619. */
  12620. getActiveTextures(): BaseTexture[];
  12621. /**
  12622. * Specifies if the material uses a texture
  12623. * @param texture defines the texture to check against the material
  12624. * @returns a boolean specifying if the material uses the texture
  12625. */
  12626. hasTexture(texture: BaseTexture): boolean;
  12627. /**
  12628. * Makes a duplicate of the material, and gives it a new name
  12629. * @param name defines the new name for the duplicated material
  12630. * @returns the cloned material
  12631. */
  12632. clone(name: string): ShaderMaterial;
  12633. /**
  12634. * Disposes the material
  12635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12637. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12638. */
  12639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12640. /**
  12641. * Serializes this material in a JSON representation
  12642. * @returns the serialized material object
  12643. */
  12644. serialize(): any;
  12645. /**
  12646. * Creates a shader material from parsed shader material data
  12647. * @param source defines the JSON represnetation of the material
  12648. * @param scene defines the hosting scene
  12649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12650. * @returns a new material
  12651. */
  12652. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12653. }
  12654. }
  12655. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12656. /** @hidden */
  12657. export var clipPlaneFragmentDeclaration: {
  12658. name: string;
  12659. shader: string;
  12660. };
  12661. }
  12662. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12663. /** @hidden */
  12664. export var clipPlaneFragment: {
  12665. name: string;
  12666. shader: string;
  12667. };
  12668. }
  12669. declare module "babylonjs/Shaders/color.fragment" {
  12670. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12671. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12672. /** @hidden */
  12673. export var colorPixelShader: {
  12674. name: string;
  12675. shader: string;
  12676. };
  12677. }
  12678. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12679. /** @hidden */
  12680. export var clipPlaneVertexDeclaration: {
  12681. name: string;
  12682. shader: string;
  12683. };
  12684. }
  12685. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12686. /** @hidden */
  12687. export var clipPlaneVertex: {
  12688. name: string;
  12689. shader: string;
  12690. };
  12691. }
  12692. declare module "babylonjs/Shaders/color.vertex" {
  12693. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12694. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12695. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12696. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12697. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12698. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12699. /** @hidden */
  12700. export var colorVertexShader: {
  12701. name: string;
  12702. shader: string;
  12703. };
  12704. }
  12705. declare module "babylonjs/Meshes/linesMesh" {
  12706. import { Nullable } from "babylonjs/types";
  12707. import { Scene } from "babylonjs/scene";
  12708. import { Color3 } from "babylonjs/Maths/math";
  12709. import { Node } from "babylonjs/node";
  12710. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12711. import { Mesh } from "babylonjs/Meshes/mesh";
  12712. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12713. import { Effect } from "babylonjs/Materials/effect";
  12714. import { Material } from "babylonjs/Materials/material";
  12715. import "babylonjs/Shaders/color.fragment";
  12716. import "babylonjs/Shaders/color.vertex";
  12717. /**
  12718. * Line mesh
  12719. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12720. */
  12721. export class LinesMesh extends Mesh {
  12722. /**
  12723. * If vertex color should be applied to the mesh
  12724. */
  12725. readonly useVertexColor?: boolean | undefined;
  12726. /**
  12727. * If vertex alpha should be applied to the mesh
  12728. */
  12729. readonly useVertexAlpha?: boolean | undefined;
  12730. /**
  12731. * Color of the line (Default: White)
  12732. */
  12733. color: Color3;
  12734. /**
  12735. * Alpha of the line (Default: 1)
  12736. */
  12737. alpha: number;
  12738. /**
  12739. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12740. * This margin is expressed in world space coordinates, so its value may vary.
  12741. * Default value is 0.1
  12742. */
  12743. intersectionThreshold: number;
  12744. private _colorShader;
  12745. private color4;
  12746. /**
  12747. * Creates a new LinesMesh
  12748. * @param name defines the name
  12749. * @param scene defines the hosting scene
  12750. * @param parent defines the parent mesh if any
  12751. * @param source defines the optional source LinesMesh used to clone data from
  12752. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12753. * When false, achieved by calling a clone(), also passing False.
  12754. * This will make creation of children, recursive.
  12755. * @param useVertexColor defines if this LinesMesh supports vertex color
  12756. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12757. */
  12758. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12759. /**
  12760. * If vertex color should be applied to the mesh
  12761. */
  12762. useVertexColor?: boolean | undefined,
  12763. /**
  12764. * If vertex alpha should be applied to the mesh
  12765. */
  12766. useVertexAlpha?: boolean | undefined);
  12767. private _addClipPlaneDefine;
  12768. private _removeClipPlaneDefine;
  12769. isReady(): boolean;
  12770. /**
  12771. * Returns the string "LineMesh"
  12772. */
  12773. getClassName(): string;
  12774. /**
  12775. * @hidden
  12776. */
  12777. /**
  12778. * @hidden
  12779. */
  12780. material: Material;
  12781. /**
  12782. * @hidden
  12783. */
  12784. readonly checkCollisions: boolean;
  12785. /** @hidden */
  12786. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12787. /** @hidden */
  12788. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12789. /**
  12790. * Disposes of the line mesh
  12791. * @param doNotRecurse If children should be disposed
  12792. */
  12793. dispose(doNotRecurse?: boolean): void;
  12794. /**
  12795. * Returns a new LineMesh object cloned from the current one.
  12796. */
  12797. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12798. /**
  12799. * Creates a new InstancedLinesMesh object from the mesh model.
  12800. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12801. * @param name defines the name of the new instance
  12802. * @returns a new InstancedLinesMesh
  12803. */
  12804. createInstance(name: string): InstancedLinesMesh;
  12805. }
  12806. /**
  12807. * Creates an instance based on a source LinesMesh
  12808. */
  12809. export class InstancedLinesMesh extends InstancedMesh {
  12810. /**
  12811. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12812. * This margin is expressed in world space coordinates, so its value may vary.
  12813. * Initilized with the intersectionThreshold value of the source LinesMesh
  12814. */
  12815. intersectionThreshold: number;
  12816. constructor(name: string, source: LinesMesh);
  12817. /**
  12818. * Returns the string "InstancedLinesMesh".
  12819. */
  12820. getClassName(): string;
  12821. }
  12822. }
  12823. declare module "babylonjs/Meshes/groundMesh" {
  12824. import { Scene } from "babylonjs/scene";
  12825. import { Vector3 } from "babylonjs/Maths/math";
  12826. import { Mesh } from "babylonjs/Meshes/mesh";
  12827. /**
  12828. * Mesh representing the gorund
  12829. */
  12830. export class GroundMesh extends Mesh {
  12831. /** If octree should be generated */
  12832. generateOctree: boolean;
  12833. private _heightQuads;
  12834. /** @hidden */
  12835. _subdivisionsX: number;
  12836. /** @hidden */
  12837. _subdivisionsY: number;
  12838. /** @hidden */
  12839. _width: number;
  12840. /** @hidden */
  12841. _height: number;
  12842. /** @hidden */
  12843. _minX: number;
  12844. /** @hidden */
  12845. _maxX: number;
  12846. /** @hidden */
  12847. _minZ: number;
  12848. /** @hidden */
  12849. _maxZ: number;
  12850. constructor(name: string, scene: Scene);
  12851. /**
  12852. * "GroundMesh"
  12853. * @returns "GroundMesh"
  12854. */
  12855. getClassName(): string;
  12856. /**
  12857. * The minimum of x and y subdivisions
  12858. */
  12859. readonly subdivisions: number;
  12860. /**
  12861. * X subdivisions
  12862. */
  12863. readonly subdivisionsX: number;
  12864. /**
  12865. * Y subdivisions
  12866. */
  12867. readonly subdivisionsY: number;
  12868. /**
  12869. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12870. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12871. * @param chunksCount the number of subdivisions for x and y
  12872. * @param octreeBlocksSize (Default: 32)
  12873. */
  12874. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12875. /**
  12876. * Returns a height (y) value in the Worl system :
  12877. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12878. * @param x x coordinate
  12879. * @param z z coordinate
  12880. * @returns the ground y position if (x, z) are outside the ground surface.
  12881. */
  12882. getHeightAtCoordinates(x: number, z: number): number;
  12883. /**
  12884. * Returns a normalized vector (Vector3) orthogonal to the ground
  12885. * at the ground coordinates (x, z) expressed in the World system.
  12886. * @param x x coordinate
  12887. * @param z z coordinate
  12888. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12889. */
  12890. getNormalAtCoordinates(x: number, z: number): Vector3;
  12891. /**
  12892. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12893. * at the ground coordinates (x, z) expressed in the World system.
  12894. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12895. * @param x x coordinate
  12896. * @param z z coordinate
  12897. * @param ref vector to store the result
  12898. * @returns the GroundMesh.
  12899. */
  12900. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12901. /**
  12902. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12903. * if the ground has been updated.
  12904. * This can be used in the render loop.
  12905. * @returns the GroundMesh.
  12906. */
  12907. updateCoordinateHeights(): GroundMesh;
  12908. private _getFacetAt;
  12909. private _initHeightQuads;
  12910. private _computeHeightQuads;
  12911. /**
  12912. * Serializes this ground mesh
  12913. * @param serializationObject object to write serialization to
  12914. */
  12915. serialize(serializationObject: any): void;
  12916. /**
  12917. * Parses a serialized ground mesh
  12918. * @param parsedMesh the serialized mesh
  12919. * @param scene the scene to create the ground mesh in
  12920. * @returns the created ground mesh
  12921. */
  12922. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12923. }
  12924. }
  12925. declare module "babylonjs/Physics/physicsJoint" {
  12926. import { Vector3 } from "babylonjs/Maths/math";
  12927. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  12928. /**
  12929. * Interface for Physics-Joint data
  12930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12931. */
  12932. export interface PhysicsJointData {
  12933. /**
  12934. * The main pivot of the joint
  12935. */
  12936. mainPivot?: Vector3;
  12937. /**
  12938. * The connected pivot of the joint
  12939. */
  12940. connectedPivot?: Vector3;
  12941. /**
  12942. * The main axis of the joint
  12943. */
  12944. mainAxis?: Vector3;
  12945. /**
  12946. * The connected axis of the joint
  12947. */
  12948. connectedAxis?: Vector3;
  12949. /**
  12950. * The collision of the joint
  12951. */
  12952. collision?: boolean;
  12953. /**
  12954. * Native Oimo/Cannon/Energy data
  12955. */
  12956. nativeParams?: any;
  12957. }
  12958. /**
  12959. * This is a holder class for the physics joint created by the physics plugin
  12960. * It holds a set of functions to control the underlying joint
  12961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12962. */
  12963. export class PhysicsJoint {
  12964. /**
  12965. * The type of the physics joint
  12966. */
  12967. type: number;
  12968. /**
  12969. * The data for the physics joint
  12970. */
  12971. jointData: PhysicsJointData;
  12972. private _physicsJoint;
  12973. protected _physicsPlugin: IPhysicsEnginePlugin;
  12974. /**
  12975. * Initializes the physics joint
  12976. * @param type The type of the physics joint
  12977. * @param jointData The data for the physics joint
  12978. */
  12979. constructor(
  12980. /**
  12981. * The type of the physics joint
  12982. */
  12983. type: number,
  12984. /**
  12985. * The data for the physics joint
  12986. */
  12987. jointData: PhysicsJointData);
  12988. /**
  12989. * Gets the physics joint
  12990. */
  12991. /**
  12992. * Sets the physics joint
  12993. */
  12994. physicsJoint: any;
  12995. /**
  12996. * Sets the physics plugin
  12997. */
  12998. physicsPlugin: IPhysicsEnginePlugin;
  12999. /**
  13000. * Execute a function that is physics-plugin specific.
  13001. * @param {Function} func the function that will be executed.
  13002. * It accepts two parameters: the physics world and the physics joint
  13003. */
  13004. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13005. /**
  13006. * Distance-Joint type
  13007. */
  13008. static DistanceJoint: number;
  13009. /**
  13010. * Hinge-Joint type
  13011. */
  13012. static HingeJoint: number;
  13013. /**
  13014. * Ball-and-Socket joint type
  13015. */
  13016. static BallAndSocketJoint: number;
  13017. /**
  13018. * Wheel-Joint type
  13019. */
  13020. static WheelJoint: number;
  13021. /**
  13022. * Slider-Joint type
  13023. */
  13024. static SliderJoint: number;
  13025. /**
  13026. * Prismatic-Joint type
  13027. */
  13028. static PrismaticJoint: number;
  13029. /**
  13030. * Universal-Joint type
  13031. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13032. */
  13033. static UniversalJoint: number;
  13034. /**
  13035. * Hinge-Joint 2 type
  13036. */
  13037. static Hinge2Joint: number;
  13038. /**
  13039. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13040. */
  13041. static PointToPointJoint: number;
  13042. /**
  13043. * Spring-Joint type
  13044. */
  13045. static SpringJoint: number;
  13046. /**
  13047. * Lock-Joint type
  13048. */
  13049. static LockJoint: number;
  13050. }
  13051. /**
  13052. * A class representing a physics distance joint
  13053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13054. */
  13055. export class DistanceJoint extends PhysicsJoint {
  13056. /**
  13057. *
  13058. * @param jointData The data for the Distance-Joint
  13059. */
  13060. constructor(jointData: DistanceJointData);
  13061. /**
  13062. * Update the predefined distance.
  13063. * @param maxDistance The maximum preferred distance
  13064. * @param minDistance The minimum preferred distance
  13065. */
  13066. updateDistance(maxDistance: number, minDistance?: number): void;
  13067. }
  13068. /**
  13069. * Represents a Motor-Enabled Joint
  13070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13071. */
  13072. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13073. /**
  13074. * Initializes the Motor-Enabled Joint
  13075. * @param type The type of the joint
  13076. * @param jointData The physica joint data for the joint
  13077. */
  13078. constructor(type: number, jointData: PhysicsJointData);
  13079. /**
  13080. * Set the motor values.
  13081. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13082. * @param force the force to apply
  13083. * @param maxForce max force for this motor.
  13084. */
  13085. setMotor(force?: number, maxForce?: number): void;
  13086. /**
  13087. * Set the motor's limits.
  13088. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13089. * @param upperLimit The upper limit of the motor
  13090. * @param lowerLimit The lower limit of the motor
  13091. */
  13092. setLimit(upperLimit: number, lowerLimit?: number): void;
  13093. }
  13094. /**
  13095. * This class represents a single physics Hinge-Joint
  13096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13097. */
  13098. export class HingeJoint extends MotorEnabledJoint {
  13099. /**
  13100. * Initializes the Hinge-Joint
  13101. * @param jointData The joint data for the Hinge-Joint
  13102. */
  13103. constructor(jointData: PhysicsJointData);
  13104. /**
  13105. * Set the motor values.
  13106. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13107. * @param {number} force the force to apply
  13108. * @param {number} maxForce max force for this motor.
  13109. */
  13110. setMotor(force?: number, maxForce?: number): void;
  13111. /**
  13112. * Set the motor's limits.
  13113. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13114. * @param upperLimit The upper limit of the motor
  13115. * @param lowerLimit The lower limit of the motor
  13116. */
  13117. setLimit(upperLimit: number, lowerLimit?: number): void;
  13118. }
  13119. /**
  13120. * This class represents a dual hinge physics joint (same as wheel joint)
  13121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13122. */
  13123. export class Hinge2Joint extends MotorEnabledJoint {
  13124. /**
  13125. * Initializes the Hinge2-Joint
  13126. * @param jointData The joint data for the Hinge2-Joint
  13127. */
  13128. constructor(jointData: PhysicsJointData);
  13129. /**
  13130. * Set the motor values.
  13131. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13132. * @param {number} targetSpeed the speed the motor is to reach
  13133. * @param {number} maxForce max force for this motor.
  13134. * @param {motorIndex} the motor's index, 0 or 1.
  13135. */
  13136. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13137. /**
  13138. * Set the motor limits.
  13139. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13140. * @param {number} upperLimit the upper limit
  13141. * @param {number} lowerLimit lower limit
  13142. * @param {motorIndex} the motor's index, 0 or 1.
  13143. */
  13144. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13145. }
  13146. /**
  13147. * Interface for a motor enabled joint
  13148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13149. */
  13150. export interface IMotorEnabledJoint {
  13151. /**
  13152. * Physics joint
  13153. */
  13154. physicsJoint: any;
  13155. /**
  13156. * Sets the motor of the motor-enabled joint
  13157. * @param force The force of the motor
  13158. * @param maxForce The maximum force of the motor
  13159. * @param motorIndex The index of the motor
  13160. */
  13161. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13162. /**
  13163. * Sets the limit of the motor
  13164. * @param upperLimit The upper limit of the motor
  13165. * @param lowerLimit The lower limit of the motor
  13166. * @param motorIndex The index of the motor
  13167. */
  13168. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13169. }
  13170. /**
  13171. * Joint data for a Distance-Joint
  13172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13173. */
  13174. export interface DistanceJointData extends PhysicsJointData {
  13175. /**
  13176. * Max distance the 2 joint objects can be apart
  13177. */
  13178. maxDistance: number;
  13179. }
  13180. /**
  13181. * Joint data from a spring joint
  13182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13183. */
  13184. export interface SpringJointData extends PhysicsJointData {
  13185. /**
  13186. * Length of the spring
  13187. */
  13188. length: number;
  13189. /**
  13190. * Stiffness of the spring
  13191. */
  13192. stiffness: number;
  13193. /**
  13194. * Damping of the spring
  13195. */
  13196. damping: number;
  13197. /** this callback will be called when applying the force to the impostors. */
  13198. forceApplicationCallback: () => void;
  13199. }
  13200. }
  13201. declare module "babylonjs/Physics/physicsRaycastResult" {
  13202. import { Vector3 } from "babylonjs/Maths/math";
  13203. /**
  13204. * Holds the data for the raycast result
  13205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13206. */
  13207. export class PhysicsRaycastResult {
  13208. private _hasHit;
  13209. private _hitDistance;
  13210. private _hitNormalWorld;
  13211. private _hitPointWorld;
  13212. private _rayFromWorld;
  13213. private _rayToWorld;
  13214. /**
  13215. * Gets if there was a hit
  13216. */
  13217. readonly hasHit: boolean;
  13218. /**
  13219. * Gets the distance from the hit
  13220. */
  13221. readonly hitDistance: number;
  13222. /**
  13223. * Gets the hit normal/direction in the world
  13224. */
  13225. readonly hitNormalWorld: Vector3;
  13226. /**
  13227. * Gets the hit point in the world
  13228. */
  13229. readonly hitPointWorld: Vector3;
  13230. /**
  13231. * Gets the ray "start point" of the ray in the world
  13232. */
  13233. readonly rayFromWorld: Vector3;
  13234. /**
  13235. * Gets the ray "end point" of the ray in the world
  13236. */
  13237. readonly rayToWorld: Vector3;
  13238. /**
  13239. * Sets the hit data (normal & point in world space)
  13240. * @param hitNormalWorld defines the normal in world space
  13241. * @param hitPointWorld defines the point in world space
  13242. */
  13243. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13244. /**
  13245. * Sets the distance from the start point to the hit point
  13246. * @param distance
  13247. */
  13248. setHitDistance(distance: number): void;
  13249. /**
  13250. * Calculates the distance manually
  13251. */
  13252. calculateHitDistance(): void;
  13253. /**
  13254. * Resets all the values to default
  13255. * @param from The from point on world space
  13256. * @param to The to point on world space
  13257. */
  13258. reset(from?: Vector3, to?: Vector3): void;
  13259. }
  13260. /**
  13261. * Interface for the size containing width and height
  13262. */
  13263. interface IXYZ {
  13264. /**
  13265. * X
  13266. */
  13267. x: number;
  13268. /**
  13269. * Y
  13270. */
  13271. y: number;
  13272. /**
  13273. * Z
  13274. */
  13275. z: number;
  13276. }
  13277. }
  13278. declare module "babylonjs/Physics/IPhysicsEngine" {
  13279. import { Nullable } from "babylonjs/types";
  13280. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13282. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13283. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13284. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13285. /**
  13286. * Interface used to describe a physics joint
  13287. */
  13288. export interface PhysicsImpostorJoint {
  13289. /** Defines the main impostor to which the joint is linked */
  13290. mainImpostor: PhysicsImpostor;
  13291. /** Defines the impostor that is connected to the main impostor using this joint */
  13292. connectedImpostor: PhysicsImpostor;
  13293. /** Defines the joint itself */
  13294. joint: PhysicsJoint;
  13295. }
  13296. /** @hidden */
  13297. export interface IPhysicsEnginePlugin {
  13298. world: any;
  13299. name: string;
  13300. setGravity(gravity: Vector3): void;
  13301. setTimeStep(timeStep: number): void;
  13302. getTimeStep(): number;
  13303. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13304. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13305. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13306. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13307. removePhysicsBody(impostor: PhysicsImpostor): void;
  13308. generateJoint(joint: PhysicsImpostorJoint): void;
  13309. removeJoint(joint: PhysicsImpostorJoint): void;
  13310. isSupported(): boolean;
  13311. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13312. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13314. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13315. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13316. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13317. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13318. getBodyMass(impostor: PhysicsImpostor): number;
  13319. getBodyFriction(impostor: PhysicsImpostor): number;
  13320. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13321. getBodyRestitution(impostor: PhysicsImpostor): number;
  13322. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13323. getBodyPressure?(impostor: PhysicsImpostor): number;
  13324. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13325. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13326. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13327. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13328. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13329. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13330. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13331. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13332. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13333. sleepBody(impostor: PhysicsImpostor): void;
  13334. wakeUpBody(impostor: PhysicsImpostor): void;
  13335. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13336. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13337. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13338. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13339. getRadius(impostor: PhysicsImpostor): number;
  13340. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13341. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13342. dispose(): void;
  13343. }
  13344. /**
  13345. * Interface used to define a physics engine
  13346. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13347. */
  13348. export interface IPhysicsEngine {
  13349. /**
  13350. * Gets the gravity vector used by the simulation
  13351. */
  13352. gravity: Vector3;
  13353. /**
  13354. * Sets the gravity vector used by the simulation
  13355. * @param gravity defines the gravity vector to use
  13356. */
  13357. setGravity(gravity: Vector3): void;
  13358. /**
  13359. * Set the time step of the physics engine.
  13360. * Default is 1/60.
  13361. * To slow it down, enter 1/600 for example.
  13362. * To speed it up, 1/30
  13363. * @param newTimeStep the new timestep to apply to this world.
  13364. */
  13365. setTimeStep(newTimeStep: number): void;
  13366. /**
  13367. * Get the time step of the physics engine.
  13368. * @returns the current time step
  13369. */
  13370. getTimeStep(): number;
  13371. /**
  13372. * Release all resources
  13373. */
  13374. dispose(): void;
  13375. /**
  13376. * Gets the name of the current physics plugin
  13377. * @returns the name of the plugin
  13378. */
  13379. getPhysicsPluginName(): string;
  13380. /**
  13381. * Adding a new impostor for the impostor tracking.
  13382. * This will be done by the impostor itself.
  13383. * @param impostor the impostor to add
  13384. */
  13385. addImpostor(impostor: PhysicsImpostor): void;
  13386. /**
  13387. * Remove an impostor from the engine.
  13388. * This impostor and its mesh will not longer be updated by the physics engine.
  13389. * @param impostor the impostor to remove
  13390. */
  13391. removeImpostor(impostor: PhysicsImpostor): void;
  13392. /**
  13393. * Add a joint to the physics engine
  13394. * @param mainImpostor defines the main impostor to which the joint is added.
  13395. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13396. * @param joint defines the joint that will connect both impostors.
  13397. */
  13398. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13399. /**
  13400. * Removes a joint from the simulation
  13401. * @param mainImpostor defines the impostor used with the joint
  13402. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13403. * @param joint defines the joint to remove
  13404. */
  13405. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13406. /**
  13407. * Gets the current plugin used to run the simulation
  13408. * @returns current plugin
  13409. */
  13410. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13411. /**
  13412. * Gets the list of physic impostors
  13413. * @returns an array of PhysicsImpostor
  13414. */
  13415. getImpostors(): Array<PhysicsImpostor>;
  13416. /**
  13417. * Gets the impostor for a physics enabled object
  13418. * @param object defines the object impersonated by the impostor
  13419. * @returns the PhysicsImpostor or null if not found
  13420. */
  13421. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13422. /**
  13423. * Gets the impostor for a physics body object
  13424. * @param body defines physics body used by the impostor
  13425. * @returns the PhysicsImpostor or null if not found
  13426. */
  13427. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13428. /**
  13429. * Does a raycast in the physics world
  13430. * @param from when should the ray start?
  13431. * @param to when should the ray end?
  13432. * @returns PhysicsRaycastResult
  13433. */
  13434. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13435. /**
  13436. * Called by the scene. No need to call it.
  13437. * @param delta defines the timespam between frames
  13438. */
  13439. _step(delta: number): void;
  13440. }
  13441. }
  13442. declare module "babylonjs/Physics/physicsImpostor" {
  13443. import { Nullable, IndicesArray } from "babylonjs/types";
  13444. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13447. import { Scene } from "babylonjs/scene";
  13448. import { Bone } from "babylonjs/Bones/bone";
  13449. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13450. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13451. /**
  13452. * The interface for the physics imposter parameters
  13453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13454. */
  13455. export interface PhysicsImpostorParameters {
  13456. /**
  13457. * The mass of the physics imposter
  13458. */
  13459. mass: number;
  13460. /**
  13461. * The friction of the physics imposter
  13462. */
  13463. friction?: number;
  13464. /**
  13465. * The coefficient of restitution of the physics imposter
  13466. */
  13467. restitution?: number;
  13468. /**
  13469. * The native options of the physics imposter
  13470. */
  13471. nativeOptions?: any;
  13472. /**
  13473. * Specifies if the parent should be ignored
  13474. */
  13475. ignoreParent?: boolean;
  13476. /**
  13477. * Specifies if bi-directional transformations should be disabled
  13478. */
  13479. disableBidirectionalTransformation?: boolean;
  13480. /**
  13481. * The pressure inside the physics imposter, soft object only
  13482. */
  13483. pressure?: number;
  13484. /**
  13485. * The stiffness the physics imposter, soft object only
  13486. */
  13487. stiffness?: number;
  13488. /**
  13489. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13490. */
  13491. velocityIterations?: number;
  13492. /**
  13493. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13494. */
  13495. positionIterations?: number;
  13496. /**
  13497. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13498. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13499. * Add to fix multiple points
  13500. */
  13501. fixedPoints?: number;
  13502. /**
  13503. * The collision margin around a soft object
  13504. */
  13505. margin?: number;
  13506. /**
  13507. * The collision margin around a soft object
  13508. */
  13509. damping?: number;
  13510. /**
  13511. * The path for a rope based on an extrusion
  13512. */
  13513. path?: any;
  13514. /**
  13515. * The shape of an extrusion used for a rope based on an extrusion
  13516. */
  13517. shape?: any;
  13518. }
  13519. /**
  13520. * Interface for a physics-enabled object
  13521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13522. */
  13523. export interface IPhysicsEnabledObject {
  13524. /**
  13525. * The position of the physics-enabled object
  13526. */
  13527. position: Vector3;
  13528. /**
  13529. * The rotation of the physics-enabled object
  13530. */
  13531. rotationQuaternion: Nullable<Quaternion>;
  13532. /**
  13533. * The scale of the physics-enabled object
  13534. */
  13535. scaling: Vector3;
  13536. /**
  13537. * The rotation of the physics-enabled object
  13538. */
  13539. rotation?: Vector3;
  13540. /**
  13541. * The parent of the physics-enabled object
  13542. */
  13543. parent?: any;
  13544. /**
  13545. * The bounding info of the physics-enabled object
  13546. * @returns The bounding info of the physics-enabled object
  13547. */
  13548. getBoundingInfo(): BoundingInfo;
  13549. /**
  13550. * Computes the world matrix
  13551. * @param force Specifies if the world matrix should be computed by force
  13552. * @returns A world matrix
  13553. */
  13554. computeWorldMatrix(force: boolean): Matrix;
  13555. /**
  13556. * Gets the world matrix
  13557. * @returns A world matrix
  13558. */
  13559. getWorldMatrix?(): Matrix;
  13560. /**
  13561. * Gets the child meshes
  13562. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13563. * @returns An array of abstract meshes
  13564. */
  13565. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13566. /**
  13567. * Gets the vertex data
  13568. * @param kind The type of vertex data
  13569. * @returns A nullable array of numbers, or a float32 array
  13570. */
  13571. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13572. /**
  13573. * Gets the indices from the mesh
  13574. * @returns A nullable array of index arrays
  13575. */
  13576. getIndices?(): Nullable<IndicesArray>;
  13577. /**
  13578. * Gets the scene from the mesh
  13579. * @returns the indices array or null
  13580. */
  13581. getScene?(): Scene;
  13582. /**
  13583. * Gets the absolute position from the mesh
  13584. * @returns the absolute position
  13585. */
  13586. getAbsolutePosition(): Vector3;
  13587. /**
  13588. * Gets the absolute pivot point from the mesh
  13589. * @returns the absolute pivot point
  13590. */
  13591. getAbsolutePivotPoint(): Vector3;
  13592. /**
  13593. * Rotates the mesh
  13594. * @param axis The axis of rotation
  13595. * @param amount The amount of rotation
  13596. * @param space The space of the rotation
  13597. * @returns The rotation transform node
  13598. */
  13599. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13600. /**
  13601. * Translates the mesh
  13602. * @param axis The axis of translation
  13603. * @param distance The distance of translation
  13604. * @param space The space of the translation
  13605. * @returns The transform node
  13606. */
  13607. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13608. /**
  13609. * Sets the absolute position of the mesh
  13610. * @param absolutePosition The absolute position of the mesh
  13611. * @returns The transform node
  13612. */
  13613. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13614. /**
  13615. * Gets the class name of the mesh
  13616. * @returns The class name
  13617. */
  13618. getClassName(): string;
  13619. }
  13620. /**
  13621. * Represents a physics imposter
  13622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13623. */
  13624. export class PhysicsImpostor {
  13625. /**
  13626. * The physics-enabled object used as the physics imposter
  13627. */
  13628. object: IPhysicsEnabledObject;
  13629. /**
  13630. * The type of the physics imposter
  13631. */
  13632. type: number;
  13633. private _options;
  13634. private _scene?;
  13635. /**
  13636. * The default object size of the imposter
  13637. */
  13638. static DEFAULT_OBJECT_SIZE: Vector3;
  13639. /**
  13640. * The identity quaternion of the imposter
  13641. */
  13642. static IDENTITY_QUATERNION: Quaternion;
  13643. /** @hidden */
  13644. _pluginData: any;
  13645. private _physicsEngine;
  13646. private _physicsBody;
  13647. private _bodyUpdateRequired;
  13648. private _onBeforePhysicsStepCallbacks;
  13649. private _onAfterPhysicsStepCallbacks;
  13650. /** @hidden */
  13651. _onPhysicsCollideCallbacks: Array<{
  13652. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13653. otherImpostors: Array<PhysicsImpostor>;
  13654. }>;
  13655. private _deltaPosition;
  13656. private _deltaRotation;
  13657. private _deltaRotationConjugated;
  13658. /** @hidden */
  13659. _isFromLine: boolean;
  13660. private _parent;
  13661. private _isDisposed;
  13662. private static _tmpVecs;
  13663. private static _tmpQuat;
  13664. /**
  13665. * Specifies if the physics imposter is disposed
  13666. */
  13667. readonly isDisposed: boolean;
  13668. /**
  13669. * Gets the mass of the physics imposter
  13670. */
  13671. mass: number;
  13672. /**
  13673. * Gets the coefficient of friction
  13674. */
  13675. /**
  13676. * Sets the coefficient of friction
  13677. */
  13678. friction: number;
  13679. /**
  13680. * Gets the coefficient of restitution
  13681. */
  13682. /**
  13683. * Sets the coefficient of restitution
  13684. */
  13685. restitution: number;
  13686. /**
  13687. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13688. */
  13689. /**
  13690. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13691. */
  13692. pressure: number;
  13693. /**
  13694. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13695. */
  13696. /**
  13697. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13698. */
  13699. stiffness: number;
  13700. /**
  13701. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13702. */
  13703. /**
  13704. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13705. */
  13706. velocityIterations: number;
  13707. /**
  13708. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13709. */
  13710. /**
  13711. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13712. */
  13713. positionIterations: number;
  13714. /**
  13715. * The unique id of the physics imposter
  13716. * set by the physics engine when adding this impostor to the array
  13717. */
  13718. uniqueId: number;
  13719. /**
  13720. * @hidden
  13721. */
  13722. soft: boolean;
  13723. /**
  13724. * @hidden
  13725. */
  13726. segments: number;
  13727. private _joints;
  13728. /**
  13729. * Initializes the physics imposter
  13730. * @param object The physics-enabled object used as the physics imposter
  13731. * @param type The type of the physics imposter
  13732. * @param _options The options for the physics imposter
  13733. * @param _scene The Babylon scene
  13734. */
  13735. constructor(
  13736. /**
  13737. * The physics-enabled object used as the physics imposter
  13738. */
  13739. object: IPhysicsEnabledObject,
  13740. /**
  13741. * The type of the physics imposter
  13742. */
  13743. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13744. /**
  13745. * This function will completly initialize this impostor.
  13746. * It will create a new body - but only if this mesh has no parent.
  13747. * If it has, this impostor will not be used other than to define the impostor
  13748. * of the child mesh.
  13749. * @hidden
  13750. */
  13751. _init(): void;
  13752. private _getPhysicsParent;
  13753. /**
  13754. * Should a new body be generated.
  13755. * @returns boolean specifying if body initialization is required
  13756. */
  13757. isBodyInitRequired(): boolean;
  13758. /**
  13759. * Sets the updated scaling
  13760. * @param updated Specifies if the scaling is updated
  13761. */
  13762. setScalingUpdated(): void;
  13763. /**
  13764. * Force a regeneration of this or the parent's impostor's body.
  13765. * Use under cautious - This will remove all joints already implemented.
  13766. */
  13767. forceUpdate(): void;
  13768. /**
  13769. * Gets the body that holds this impostor. Either its own, or its parent.
  13770. */
  13771. /**
  13772. * Set the physics body. Used mainly by the physics engine/plugin
  13773. */
  13774. physicsBody: any;
  13775. /**
  13776. * Get the parent of the physics imposter
  13777. * @returns Physics imposter or null
  13778. */
  13779. /**
  13780. * Sets the parent of the physics imposter
  13781. */
  13782. parent: Nullable<PhysicsImpostor>;
  13783. /**
  13784. * Resets the update flags
  13785. */
  13786. resetUpdateFlags(): void;
  13787. /**
  13788. * Gets the object extend size
  13789. * @returns the object extend size
  13790. */
  13791. getObjectExtendSize(): Vector3;
  13792. /**
  13793. * Gets the object center
  13794. * @returns The object center
  13795. */
  13796. getObjectCenter(): Vector3;
  13797. /**
  13798. * Get a specific parametes from the options parameter
  13799. * @param paramName The object parameter name
  13800. * @returns The object parameter
  13801. */
  13802. getParam(paramName: string): any;
  13803. /**
  13804. * Sets a specific parameter in the options given to the physics plugin
  13805. * @param paramName The parameter name
  13806. * @param value The value of the parameter
  13807. */
  13808. setParam(paramName: string, value: number): void;
  13809. /**
  13810. * Specifically change the body's mass option. Won't recreate the physics body object
  13811. * @param mass The mass of the physics imposter
  13812. */
  13813. setMass(mass: number): void;
  13814. /**
  13815. * Gets the linear velocity
  13816. * @returns linear velocity or null
  13817. */
  13818. getLinearVelocity(): Nullable<Vector3>;
  13819. /**
  13820. * Sets the linear velocity
  13821. * @param velocity linear velocity or null
  13822. */
  13823. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13824. /**
  13825. * Gets the angular velocity
  13826. * @returns angular velocity or null
  13827. */
  13828. getAngularVelocity(): Nullable<Vector3>;
  13829. /**
  13830. * Sets the angular velocity
  13831. * @param velocity The velocity or null
  13832. */
  13833. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13834. /**
  13835. * Execute a function with the physics plugin native code
  13836. * Provide a function the will have two variables - the world object and the physics body object
  13837. * @param func The function to execute with the physics plugin native code
  13838. */
  13839. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13840. /**
  13841. * Register a function that will be executed before the physics world is stepping forward
  13842. * @param func The function to execute before the physics world is stepped forward
  13843. */
  13844. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13845. /**
  13846. * Unregister a function that will be executed before the physics world is stepping forward
  13847. * @param func The function to execute before the physics world is stepped forward
  13848. */
  13849. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13850. /**
  13851. * Register a function that will be executed after the physics step
  13852. * @param func The function to execute after physics step
  13853. */
  13854. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13855. /**
  13856. * Unregisters a function that will be executed after the physics step
  13857. * @param func The function to execute after physics step
  13858. */
  13859. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13860. /**
  13861. * register a function that will be executed when this impostor collides against a different body
  13862. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13863. * @param func Callback that is executed on collision
  13864. */
  13865. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13866. /**
  13867. * Unregisters the physics imposter on contact
  13868. * @param collideAgainst The physics object to collide against
  13869. * @param func Callback to execute on collision
  13870. */
  13871. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13872. private _tmpQuat;
  13873. private _tmpQuat2;
  13874. /**
  13875. * Get the parent rotation
  13876. * @returns The parent rotation
  13877. */
  13878. getParentsRotation(): Quaternion;
  13879. /**
  13880. * this function is executed by the physics engine.
  13881. */
  13882. beforeStep: () => void;
  13883. /**
  13884. * this function is executed by the physics engine
  13885. */
  13886. afterStep: () => void;
  13887. /**
  13888. * Legacy collision detection event support
  13889. */
  13890. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13891. /**
  13892. * event and body object due to cannon's event-based architecture.
  13893. */
  13894. onCollide: (e: {
  13895. body: any;
  13896. }) => void;
  13897. /**
  13898. * Apply a force
  13899. * @param force The force to apply
  13900. * @param contactPoint The contact point for the force
  13901. * @returns The physics imposter
  13902. */
  13903. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13904. /**
  13905. * Apply an impulse
  13906. * @param force The impulse force
  13907. * @param contactPoint The contact point for the impulse force
  13908. * @returns The physics imposter
  13909. */
  13910. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13911. /**
  13912. * A help function to create a joint
  13913. * @param otherImpostor A physics imposter used to create a joint
  13914. * @param jointType The type of joint
  13915. * @param jointData The data for the joint
  13916. * @returns The physics imposter
  13917. */
  13918. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13919. /**
  13920. * Add a joint to this impostor with a different impostor
  13921. * @param otherImpostor A physics imposter used to add a joint
  13922. * @param joint The joint to add
  13923. * @returns The physics imposter
  13924. */
  13925. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13926. /**
  13927. * Add an anchor to a cloth impostor
  13928. * @param otherImpostor rigid impostor to anchor to
  13929. * @param width ratio across width from 0 to 1
  13930. * @param height ratio up height from 0 to 1
  13931. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13932. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13933. * @returns impostor the soft imposter
  13934. */
  13935. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13936. /**
  13937. * Add a hook to a rope impostor
  13938. * @param otherImpostor rigid impostor to anchor to
  13939. * @param length ratio across rope from 0 to 1
  13940. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13941. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13942. * @returns impostor the rope imposter
  13943. */
  13944. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13945. /**
  13946. * Will keep this body still, in a sleep mode.
  13947. * @returns the physics imposter
  13948. */
  13949. sleep(): PhysicsImpostor;
  13950. /**
  13951. * Wake the body up.
  13952. * @returns The physics imposter
  13953. */
  13954. wakeUp(): PhysicsImpostor;
  13955. /**
  13956. * Clones the physics imposter
  13957. * @param newObject The physics imposter clones to this physics-enabled object
  13958. * @returns A nullable physics imposter
  13959. */
  13960. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13961. /**
  13962. * Disposes the physics imposter
  13963. */
  13964. dispose(): void;
  13965. /**
  13966. * Sets the delta position
  13967. * @param position The delta position amount
  13968. */
  13969. setDeltaPosition(position: Vector3): void;
  13970. /**
  13971. * Sets the delta rotation
  13972. * @param rotation The delta rotation amount
  13973. */
  13974. setDeltaRotation(rotation: Quaternion): void;
  13975. /**
  13976. * Gets the box size of the physics imposter and stores the result in the input parameter
  13977. * @param result Stores the box size
  13978. * @returns The physics imposter
  13979. */
  13980. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13981. /**
  13982. * Gets the radius of the physics imposter
  13983. * @returns Radius of the physics imposter
  13984. */
  13985. getRadius(): number;
  13986. /**
  13987. * Sync a bone with this impostor
  13988. * @param bone The bone to sync to the impostor.
  13989. * @param boneMesh The mesh that the bone is influencing.
  13990. * @param jointPivot The pivot of the joint / bone in local space.
  13991. * @param distToJoint Optional distance from the impostor to the joint.
  13992. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13993. */
  13994. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13995. /**
  13996. * Sync impostor to a bone
  13997. * @param bone The bone that the impostor will be synced to.
  13998. * @param boneMesh The mesh that the bone is influencing.
  13999. * @param jointPivot The pivot of the joint / bone in local space.
  14000. * @param distToJoint Optional distance from the impostor to the joint.
  14001. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14002. * @param boneAxis Optional vector3 axis the bone is aligned with
  14003. */
  14004. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14005. /**
  14006. * No-Imposter type
  14007. */
  14008. static NoImpostor: number;
  14009. /**
  14010. * Sphere-Imposter type
  14011. */
  14012. static SphereImpostor: number;
  14013. /**
  14014. * Box-Imposter type
  14015. */
  14016. static BoxImpostor: number;
  14017. /**
  14018. * Plane-Imposter type
  14019. */
  14020. static PlaneImpostor: number;
  14021. /**
  14022. * Mesh-imposter type
  14023. */
  14024. static MeshImpostor: number;
  14025. /**
  14026. * Cylinder-Imposter type
  14027. */
  14028. static CylinderImpostor: number;
  14029. /**
  14030. * Particle-Imposter type
  14031. */
  14032. static ParticleImpostor: number;
  14033. /**
  14034. * Heightmap-Imposter type
  14035. */
  14036. static HeightmapImpostor: number;
  14037. /**
  14038. * ConvexHull-Impostor type (Ammo.js plugin only)
  14039. */
  14040. static ConvexHullImpostor: number;
  14041. /**
  14042. * Rope-Imposter type
  14043. */
  14044. static RopeImpostor: number;
  14045. /**
  14046. * Cloth-Imposter type
  14047. */
  14048. static ClothImpostor: number;
  14049. /**
  14050. * Softbody-Imposter type
  14051. */
  14052. static SoftbodyImpostor: number;
  14053. }
  14054. }
  14055. declare module "babylonjs/Meshes/mesh" {
  14056. import { Observable } from "babylonjs/Misc/observable";
  14057. import { IAnimatable } from "babylonjs/Misc/tools";
  14058. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14059. import { Camera } from "babylonjs/Cameras/camera";
  14060. import { Scene } from "babylonjs/scene";
  14061. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14062. import { Engine } from "babylonjs/Engines/engine";
  14063. import { Node } from "babylonjs/node";
  14064. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14065. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14066. import { Buffer } from "babylonjs/Meshes/buffer";
  14067. import { Geometry } from "babylonjs/Meshes/geometry";
  14068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14070. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14071. import { Effect } from "babylonjs/Materials/effect";
  14072. import { Material } from "babylonjs/Materials/material";
  14073. import { Skeleton } from "babylonjs/Bones/skeleton";
  14074. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14075. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14076. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14077. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14078. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14079. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14080. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14081. /**
  14082. * @hidden
  14083. **/
  14084. export class _CreationDataStorage {
  14085. closePath?: boolean;
  14086. closeArray?: boolean;
  14087. idx: number[];
  14088. dashSize: number;
  14089. gapSize: number;
  14090. path3D: Path3D;
  14091. pathArray: Vector3[][];
  14092. arc: number;
  14093. radius: number;
  14094. cap: number;
  14095. tessellation: number;
  14096. }
  14097. /**
  14098. * @hidden
  14099. **/
  14100. class _InstanceDataStorage {
  14101. visibleInstances: any;
  14102. batchCache: _InstancesBatch;
  14103. instancesBufferSize: number;
  14104. instancesBuffer: Nullable<Buffer>;
  14105. instancesData: Float32Array;
  14106. overridenInstanceCount: number;
  14107. isFrozen: boolean;
  14108. previousBatch: _InstancesBatch;
  14109. hardwareInstancedRendering: boolean;
  14110. sideOrientation: number;
  14111. }
  14112. /**
  14113. * @hidden
  14114. **/
  14115. export class _InstancesBatch {
  14116. mustReturn: boolean;
  14117. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14118. renderSelf: boolean[];
  14119. hardwareInstancedRendering: boolean[];
  14120. }
  14121. /**
  14122. * Class used to represent renderable models
  14123. */
  14124. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14125. /**
  14126. * Mesh side orientation : usually the external or front surface
  14127. */
  14128. static readonly FRONTSIDE: number;
  14129. /**
  14130. * Mesh side orientation : usually the internal or back surface
  14131. */
  14132. static readonly BACKSIDE: number;
  14133. /**
  14134. * Mesh side orientation : both internal and external or front and back surfaces
  14135. */
  14136. static readonly DOUBLESIDE: number;
  14137. /**
  14138. * Mesh side orientation : by default, `FRONTSIDE`
  14139. */
  14140. static readonly DEFAULTSIDE: number;
  14141. /**
  14142. * Mesh cap setting : no cap
  14143. */
  14144. static readonly NO_CAP: number;
  14145. /**
  14146. * Mesh cap setting : one cap at the beginning of the mesh
  14147. */
  14148. static readonly CAP_START: number;
  14149. /**
  14150. * Mesh cap setting : one cap at the end of the mesh
  14151. */
  14152. static readonly CAP_END: number;
  14153. /**
  14154. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14155. */
  14156. static readonly CAP_ALL: number;
  14157. /**
  14158. * Mesh pattern setting : no flip or rotate
  14159. */
  14160. static readonly NO_FLIP: number;
  14161. /**
  14162. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14163. */
  14164. static readonly FLIP_TILE: number;
  14165. /**
  14166. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14167. */
  14168. static readonly ROTATE_TILE: number;
  14169. /**
  14170. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14171. */
  14172. static readonly FLIP_ROW: number;
  14173. /**
  14174. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14175. */
  14176. static readonly ROTATE_ROW: number;
  14177. /**
  14178. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14179. */
  14180. static readonly FLIP_N_ROTATE_TILE: number;
  14181. /**
  14182. * Mesh pattern setting : rotate pattern and rotate
  14183. */
  14184. static readonly FLIP_N_ROTATE_ROW: number;
  14185. /**
  14186. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14187. */
  14188. static readonly CENTER: number;
  14189. /**
  14190. * Mesh tile positioning : part tiles on left
  14191. */
  14192. static readonly LEFT: number;
  14193. /**
  14194. * Mesh tile positioning : part tiles on right
  14195. */
  14196. static readonly RIGHT: number;
  14197. /**
  14198. * Mesh tile positioning : part tiles on top
  14199. */
  14200. static readonly TOP: number;
  14201. /**
  14202. * Mesh tile positioning : part tiles on bottom
  14203. */
  14204. static readonly BOTTOM: number;
  14205. /**
  14206. * Gets the default side orientation.
  14207. * @param orientation the orientation to value to attempt to get
  14208. * @returns the default orientation
  14209. * @hidden
  14210. */
  14211. static _GetDefaultSideOrientation(orientation?: number): number;
  14212. private _internalMeshDataInfo;
  14213. /**
  14214. * An event triggered before rendering the mesh
  14215. */
  14216. readonly onBeforeRenderObservable: Observable<Mesh>;
  14217. /**
  14218. * An event triggered before binding the mesh
  14219. */
  14220. readonly onBeforeBindObservable: Observable<Mesh>;
  14221. /**
  14222. * An event triggered after rendering the mesh
  14223. */
  14224. readonly onAfterRenderObservable: Observable<Mesh>;
  14225. /**
  14226. * An event triggered before drawing the mesh
  14227. */
  14228. readonly onBeforeDrawObservable: Observable<Mesh>;
  14229. private _onBeforeDrawObserver;
  14230. /**
  14231. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14232. */
  14233. onBeforeDraw: () => void;
  14234. /**
  14235. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14236. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14237. */
  14238. delayLoadState: number;
  14239. /**
  14240. * Gets the list of instances created from this mesh
  14241. * it is not supposed to be modified manually.
  14242. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14243. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14244. */
  14245. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14246. /**
  14247. * Gets the file containing delay loading data for this mesh
  14248. */
  14249. delayLoadingFile: string;
  14250. /** @hidden */
  14251. _binaryInfo: any;
  14252. /**
  14253. * User defined function used to change how LOD level selection is done
  14254. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14255. */
  14256. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14257. /**
  14258. * Gets or sets the morph target manager
  14259. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14260. */
  14261. morphTargetManager: Nullable<MorphTargetManager>;
  14262. /** @hidden */
  14263. _creationDataStorage: Nullable<_CreationDataStorage>;
  14264. /** @hidden */
  14265. _geometry: Nullable<Geometry>;
  14266. /** @hidden */
  14267. _delayInfo: Array<string>;
  14268. /** @hidden */
  14269. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14270. /** @hidden */
  14271. _instanceDataStorage: _InstanceDataStorage;
  14272. private _effectiveMaterial;
  14273. /** @hidden */
  14274. _shouldGenerateFlatShading: boolean;
  14275. /** @hidden */
  14276. _originalBuilderSideOrientation: number;
  14277. /**
  14278. * Use this property to change the original side orientation defined at construction time
  14279. */
  14280. overrideMaterialSideOrientation: Nullable<number>;
  14281. /**
  14282. * Gets the source mesh (the one used to clone this one from)
  14283. */
  14284. readonly source: Nullable<Mesh>;
  14285. /**
  14286. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14287. */
  14288. isUnIndexed: boolean;
  14289. /**
  14290. * @constructor
  14291. * @param name The value used by scene.getMeshByName() to do a lookup.
  14292. * @param scene The scene to add this mesh to.
  14293. * @param parent The parent of this mesh, if it has one
  14294. * @param source An optional Mesh from which geometry is shared, cloned.
  14295. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14296. * When false, achieved by calling a clone(), also passing False.
  14297. * This will make creation of children, recursive.
  14298. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14299. */
  14300. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14301. /**
  14302. * Gets the class name
  14303. * @returns the string "Mesh".
  14304. */
  14305. getClassName(): string;
  14306. /** @hidden */
  14307. readonly _isMesh: boolean;
  14308. /**
  14309. * Returns a description of this mesh
  14310. * @param fullDetails define if full details about this mesh must be used
  14311. * @returns a descriptive string representing this mesh
  14312. */
  14313. toString(fullDetails?: boolean): string;
  14314. /** @hidden */
  14315. _unBindEffect(): void;
  14316. /**
  14317. * Gets a boolean indicating if this mesh has LOD
  14318. */
  14319. readonly hasLODLevels: boolean;
  14320. /**
  14321. * Gets the list of MeshLODLevel associated with the current mesh
  14322. * @returns an array of MeshLODLevel
  14323. */
  14324. getLODLevels(): MeshLODLevel[];
  14325. private _sortLODLevels;
  14326. /**
  14327. * Add a mesh as LOD level triggered at the given distance.
  14328. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14329. * @param distance The distance from the center of the object to show this level
  14330. * @param mesh The mesh to be added as LOD level (can be null)
  14331. * @return This mesh (for chaining)
  14332. */
  14333. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14334. /**
  14335. * Returns the LOD level mesh at the passed distance or null if not found.
  14336. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14337. * @param distance The distance from the center of the object to show this level
  14338. * @returns a Mesh or `null`
  14339. */
  14340. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14341. /**
  14342. * Remove a mesh from the LOD array
  14343. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14344. * @param mesh defines the mesh to be removed
  14345. * @return This mesh (for chaining)
  14346. */
  14347. removeLODLevel(mesh: Mesh): Mesh;
  14348. /**
  14349. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14350. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14351. * @param camera defines the camera to use to compute distance
  14352. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14353. * @return This mesh (for chaining)
  14354. */
  14355. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14356. /**
  14357. * Gets the mesh internal Geometry object
  14358. */
  14359. readonly geometry: Nullable<Geometry>;
  14360. /**
  14361. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14362. * @returns the total number of vertices
  14363. */
  14364. getTotalVertices(): number;
  14365. /**
  14366. * Returns the content of an associated vertex buffer
  14367. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14368. * - VertexBuffer.PositionKind
  14369. * - VertexBuffer.UVKind
  14370. * - VertexBuffer.UV2Kind
  14371. * - VertexBuffer.UV3Kind
  14372. * - VertexBuffer.UV4Kind
  14373. * - VertexBuffer.UV5Kind
  14374. * - VertexBuffer.UV6Kind
  14375. * - VertexBuffer.ColorKind
  14376. * - VertexBuffer.MatricesIndicesKind
  14377. * - VertexBuffer.MatricesIndicesExtraKind
  14378. * - VertexBuffer.MatricesWeightsKind
  14379. * - VertexBuffer.MatricesWeightsExtraKind
  14380. * @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
  14381. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14382. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14383. */
  14384. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14385. /**
  14386. * Returns the mesh VertexBuffer object from the requested `kind`
  14387. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14388. * - VertexBuffer.PositionKind
  14389. * - VertexBuffer.NormalKind
  14390. * - VertexBuffer.UVKind
  14391. * - VertexBuffer.UV2Kind
  14392. * - VertexBuffer.UV3Kind
  14393. * - VertexBuffer.UV4Kind
  14394. * - VertexBuffer.UV5Kind
  14395. * - VertexBuffer.UV6Kind
  14396. * - VertexBuffer.ColorKind
  14397. * - VertexBuffer.MatricesIndicesKind
  14398. * - VertexBuffer.MatricesIndicesExtraKind
  14399. * - VertexBuffer.MatricesWeightsKind
  14400. * - VertexBuffer.MatricesWeightsExtraKind
  14401. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14402. */
  14403. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14404. /**
  14405. * Tests if a specific vertex buffer is associated with this mesh
  14406. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14407. * - VertexBuffer.PositionKind
  14408. * - VertexBuffer.NormalKind
  14409. * - VertexBuffer.UVKind
  14410. * - VertexBuffer.UV2Kind
  14411. * - VertexBuffer.UV3Kind
  14412. * - VertexBuffer.UV4Kind
  14413. * - VertexBuffer.UV5Kind
  14414. * - VertexBuffer.UV6Kind
  14415. * - VertexBuffer.ColorKind
  14416. * - VertexBuffer.MatricesIndicesKind
  14417. * - VertexBuffer.MatricesIndicesExtraKind
  14418. * - VertexBuffer.MatricesWeightsKind
  14419. * - VertexBuffer.MatricesWeightsExtraKind
  14420. * @returns a boolean
  14421. */
  14422. isVerticesDataPresent(kind: string): boolean;
  14423. /**
  14424. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14425. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14426. * - VertexBuffer.PositionKind
  14427. * - VertexBuffer.UVKind
  14428. * - VertexBuffer.UV2Kind
  14429. * - VertexBuffer.UV3Kind
  14430. * - VertexBuffer.UV4Kind
  14431. * - VertexBuffer.UV5Kind
  14432. * - VertexBuffer.UV6Kind
  14433. * - VertexBuffer.ColorKind
  14434. * - VertexBuffer.MatricesIndicesKind
  14435. * - VertexBuffer.MatricesIndicesExtraKind
  14436. * - VertexBuffer.MatricesWeightsKind
  14437. * - VertexBuffer.MatricesWeightsExtraKind
  14438. * @returns a boolean
  14439. */
  14440. isVertexBufferUpdatable(kind: string): boolean;
  14441. /**
  14442. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14443. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14444. * - VertexBuffer.PositionKind
  14445. * - VertexBuffer.NormalKind
  14446. * - VertexBuffer.UVKind
  14447. * - VertexBuffer.UV2Kind
  14448. * - VertexBuffer.UV3Kind
  14449. * - VertexBuffer.UV4Kind
  14450. * - VertexBuffer.UV5Kind
  14451. * - VertexBuffer.UV6Kind
  14452. * - VertexBuffer.ColorKind
  14453. * - VertexBuffer.MatricesIndicesKind
  14454. * - VertexBuffer.MatricesIndicesExtraKind
  14455. * - VertexBuffer.MatricesWeightsKind
  14456. * - VertexBuffer.MatricesWeightsExtraKind
  14457. * @returns an array of strings
  14458. */
  14459. getVerticesDataKinds(): string[];
  14460. /**
  14461. * Returns a positive integer : the total number of indices in this mesh geometry.
  14462. * @returns the numner of indices or zero if the mesh has no geometry.
  14463. */
  14464. getTotalIndices(): number;
  14465. /**
  14466. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14467. * @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.
  14468. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14469. * @returns the indices array or an empty array if the mesh has no geometry
  14470. */
  14471. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14472. readonly isBlocked: boolean;
  14473. /**
  14474. * Determine if the current mesh is ready to be rendered
  14475. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14476. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14477. * @returns true if all associated assets are ready (material, textures, shaders)
  14478. */
  14479. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14480. /**
  14481. * 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.
  14482. */
  14483. readonly areNormalsFrozen: boolean;
  14484. /**
  14485. * 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.
  14486. * @returns the current mesh
  14487. */
  14488. freezeNormals(): Mesh;
  14489. /**
  14490. * 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
  14491. * @returns the current mesh
  14492. */
  14493. unfreezeNormals(): Mesh;
  14494. /**
  14495. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14496. */
  14497. overridenInstanceCount: number;
  14498. /** @hidden */
  14499. _preActivate(): Mesh;
  14500. /** @hidden */
  14501. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14502. /** @hidden */
  14503. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14504. /**
  14505. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14506. * This means the mesh underlying bounding box and sphere are recomputed.
  14507. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14508. * @returns the current mesh
  14509. */
  14510. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14511. /** @hidden */
  14512. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14513. /**
  14514. * This function will subdivide the mesh into multiple submeshes
  14515. * @param count defines the expected number of submeshes
  14516. */
  14517. subdivide(count: number): void;
  14518. /**
  14519. * Copy a FloatArray into a specific associated vertex buffer
  14520. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14521. * - VertexBuffer.PositionKind
  14522. * - VertexBuffer.UVKind
  14523. * - VertexBuffer.UV2Kind
  14524. * - VertexBuffer.UV3Kind
  14525. * - VertexBuffer.UV4Kind
  14526. * - VertexBuffer.UV5Kind
  14527. * - VertexBuffer.UV6Kind
  14528. * - VertexBuffer.ColorKind
  14529. * - VertexBuffer.MatricesIndicesKind
  14530. * - VertexBuffer.MatricesIndicesExtraKind
  14531. * - VertexBuffer.MatricesWeightsKind
  14532. * - VertexBuffer.MatricesWeightsExtraKind
  14533. * @param data defines the data source
  14534. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14535. * @param stride defines the data stride size (can be null)
  14536. * @returns the current mesh
  14537. */
  14538. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14539. /**
  14540. * Flags an associated vertex buffer as updatable
  14541. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14542. * - VertexBuffer.PositionKind
  14543. * - VertexBuffer.UVKind
  14544. * - VertexBuffer.UV2Kind
  14545. * - VertexBuffer.UV3Kind
  14546. * - VertexBuffer.UV4Kind
  14547. * - VertexBuffer.UV5Kind
  14548. * - VertexBuffer.UV6Kind
  14549. * - VertexBuffer.ColorKind
  14550. * - VertexBuffer.MatricesIndicesKind
  14551. * - VertexBuffer.MatricesIndicesExtraKind
  14552. * - VertexBuffer.MatricesWeightsKind
  14553. * - VertexBuffer.MatricesWeightsExtraKind
  14554. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14555. */
  14556. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14557. /**
  14558. * Sets the mesh global Vertex Buffer
  14559. * @param buffer defines the buffer to use
  14560. * @returns the current mesh
  14561. */
  14562. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14563. /**
  14564. * Update a specific associated vertex buffer
  14565. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14566. * - VertexBuffer.PositionKind
  14567. * - VertexBuffer.UVKind
  14568. * - VertexBuffer.UV2Kind
  14569. * - VertexBuffer.UV3Kind
  14570. * - VertexBuffer.UV4Kind
  14571. * - VertexBuffer.UV5Kind
  14572. * - VertexBuffer.UV6Kind
  14573. * - VertexBuffer.ColorKind
  14574. * - VertexBuffer.MatricesIndicesKind
  14575. * - VertexBuffer.MatricesIndicesExtraKind
  14576. * - VertexBuffer.MatricesWeightsKind
  14577. * - VertexBuffer.MatricesWeightsExtraKind
  14578. * @param data defines the data source
  14579. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14580. * @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)
  14581. * @returns the current mesh
  14582. */
  14583. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14584. /**
  14585. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14586. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14587. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14588. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14589. * @returns the current mesh
  14590. */
  14591. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14592. /**
  14593. * Creates a un-shared specific occurence of the geometry for the mesh.
  14594. * @returns the current mesh
  14595. */
  14596. makeGeometryUnique(): Mesh;
  14597. /**
  14598. * Set the index buffer of this mesh
  14599. * @param indices defines the source data
  14600. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14601. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14602. * @returns the current mesh
  14603. */
  14604. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14605. /**
  14606. * Update the current index buffer
  14607. * @param indices defines the source data
  14608. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14609. * @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)
  14610. * @returns the current mesh
  14611. */
  14612. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14613. /**
  14614. * Invert the geometry to move from a right handed system to a left handed one.
  14615. * @returns the current mesh
  14616. */
  14617. toLeftHanded(): Mesh;
  14618. /** @hidden */
  14619. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14620. /** @hidden */
  14621. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14622. /**
  14623. * Registers for this mesh a javascript function called just before the rendering process
  14624. * @param func defines the function to call before rendering this mesh
  14625. * @returns the current mesh
  14626. */
  14627. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14628. /**
  14629. * Disposes a previously registered javascript function called before the rendering
  14630. * @param func defines the function to remove
  14631. * @returns the current mesh
  14632. */
  14633. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14634. /**
  14635. * Registers for this mesh a javascript function called just after the rendering is complete
  14636. * @param func defines the function to call after rendering this mesh
  14637. * @returns the current mesh
  14638. */
  14639. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14640. /**
  14641. * Disposes a previously registered javascript function called after the rendering.
  14642. * @param func defines the function to remove
  14643. * @returns the current mesh
  14644. */
  14645. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14646. /** @hidden */
  14647. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14648. /** @hidden */
  14649. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14650. /** @hidden */
  14651. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14652. /** @hidden */
  14653. _freeze(): void;
  14654. /** @hidden */
  14655. _unFreeze(): void;
  14656. /**
  14657. * 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
  14658. * @param subMesh defines the subMesh to render
  14659. * @param enableAlphaMode defines if alpha mode can be changed
  14660. * @returns the current mesh
  14661. */
  14662. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14663. private _onBeforeDraw;
  14664. /**
  14665. * Renormalize the mesh and patch it up if there are no weights
  14666. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14667. * However in the case of zero weights then we set just a single influence to 1.
  14668. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14669. */
  14670. cleanMatrixWeights(): void;
  14671. private normalizeSkinFourWeights;
  14672. private normalizeSkinWeightsAndExtra;
  14673. /**
  14674. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14675. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14676. * the user know there was an issue with importing the mesh
  14677. * @returns a validation object with skinned, valid and report string
  14678. */
  14679. validateSkinning(): {
  14680. skinned: boolean;
  14681. valid: boolean;
  14682. report: string;
  14683. };
  14684. /** @hidden */
  14685. _checkDelayState(): Mesh;
  14686. private _queueLoad;
  14687. /**
  14688. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14689. * A mesh is in the frustum if its bounding box intersects the frustum
  14690. * @param frustumPlanes defines the frustum to test
  14691. * @returns true if the mesh is in the frustum planes
  14692. */
  14693. isInFrustum(frustumPlanes: Plane[]): boolean;
  14694. /**
  14695. * Sets the mesh material by the material or multiMaterial `id` property
  14696. * @param id is a string identifying the material or the multiMaterial
  14697. * @returns the current mesh
  14698. */
  14699. setMaterialByID(id: string): Mesh;
  14700. /**
  14701. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14702. * @returns an array of IAnimatable
  14703. */
  14704. getAnimatables(): IAnimatable[];
  14705. /**
  14706. * Modifies the mesh geometry according to the passed transformation matrix.
  14707. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14708. * The mesh normals are modified using the same transformation.
  14709. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14710. * @param transform defines the transform matrix to use
  14711. * @see http://doc.babylonjs.com/resources/baking_transformations
  14712. * @returns the current mesh
  14713. */
  14714. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14715. /**
  14716. * Modifies the mesh geometry according to its own current World Matrix.
  14717. * The mesh World Matrix is then reset.
  14718. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14719. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14720. * @see http://doc.babylonjs.com/resources/baking_transformations
  14721. * @returns the current mesh
  14722. */
  14723. bakeCurrentTransformIntoVertices(): Mesh;
  14724. /** @hidden */
  14725. readonly _positions: Nullable<Vector3[]>;
  14726. /** @hidden */
  14727. _resetPointsArrayCache(): Mesh;
  14728. /** @hidden */
  14729. _generatePointsArray(): boolean;
  14730. /**
  14731. * Returns a new Mesh object generated from the current mesh properties.
  14732. * This method must not get confused with createInstance()
  14733. * @param name is a string, the name given to the new mesh
  14734. * @param newParent can be any Node object (default `null`)
  14735. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14736. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14737. * @returns a new mesh
  14738. */
  14739. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14740. /**
  14741. * Releases resources associated with this mesh.
  14742. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14743. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14744. */
  14745. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14746. /**
  14747. * Modifies the mesh geometry according to a displacement map.
  14748. * 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.
  14749. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14750. * @param url is a string, the URL from the image file is to be downloaded.
  14751. * @param minHeight is the lower limit of the displacement.
  14752. * @param maxHeight is the upper limit of the displacement.
  14753. * @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.
  14754. * @param uvOffset is an optional vector2 used to offset UV.
  14755. * @param uvScale is an optional vector2 used to scale UV.
  14756. * @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.
  14757. * @returns the Mesh.
  14758. */
  14759. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14760. /**
  14761. * Modifies the mesh geometry according to a displacementMap buffer.
  14762. * 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.
  14763. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14764. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14765. * @param heightMapWidth is the width of the buffer image.
  14766. * @param heightMapHeight is the height of the buffer image.
  14767. * @param minHeight is the lower limit of the displacement.
  14768. * @param maxHeight is the upper limit of the displacement.
  14769. * @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.
  14770. * @param uvOffset is an optional vector2 used to offset UV.
  14771. * @param uvScale is an optional vector2 used to scale UV.
  14772. * @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.
  14773. * @returns the Mesh.
  14774. */
  14775. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14776. /**
  14777. * Modify the mesh to get a flat shading rendering.
  14778. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14779. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14780. * @returns current mesh
  14781. */
  14782. convertToFlatShadedMesh(): Mesh;
  14783. /**
  14784. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14785. * In other words, more vertices, no more indices and a single bigger VBO.
  14786. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14787. * @returns current mesh
  14788. */
  14789. convertToUnIndexedMesh(): Mesh;
  14790. /**
  14791. * Inverses facet orientations.
  14792. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14793. * @param flipNormals will also inverts the normals
  14794. * @returns current mesh
  14795. */
  14796. flipFaces(flipNormals?: boolean): Mesh;
  14797. /**
  14798. * Increase the number of facets and hence vertices in a mesh
  14799. * Vertex normals are interpolated from existing vertex normals
  14800. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14801. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14802. */
  14803. increaseVertices(numberPerEdge: number): void;
  14804. /**
  14805. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14806. * This will undo any application of covertToFlatShadedMesh
  14807. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14808. */
  14809. forceSharedVertices(): void;
  14810. /** @hidden */
  14811. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14812. /** @hidden */
  14813. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14814. /**
  14815. * Creates a new InstancedMesh object from the mesh model.
  14816. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14817. * @param name defines the name of the new instance
  14818. * @returns a new InstancedMesh
  14819. */
  14820. createInstance(name: string): InstancedMesh;
  14821. /**
  14822. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14823. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14824. * @returns the current mesh
  14825. */
  14826. synchronizeInstances(): Mesh;
  14827. /**
  14828. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14829. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14830. * This should be used together with the simplification to avoid disappearing triangles.
  14831. * @param successCallback an optional success callback to be called after the optimization finished.
  14832. * @returns the current mesh
  14833. */
  14834. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14835. /**
  14836. * Serialize current mesh
  14837. * @param serializationObject defines the object which will receive the serialization data
  14838. */
  14839. serialize(serializationObject: any): void;
  14840. /** @hidden */
  14841. _syncGeometryWithMorphTargetManager(): void;
  14842. /** @hidden */
  14843. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14844. /**
  14845. * Returns a new Mesh object parsed from the source provided.
  14846. * @param parsedMesh is the source
  14847. * @param scene defines the hosting scene
  14848. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14849. * @returns a new Mesh
  14850. */
  14851. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14852. /**
  14853. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14854. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14855. * @param name defines the name of the mesh to create
  14856. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14857. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14858. * @param closePath creates a seam between the first and the last points of each path of the path array
  14859. * @param offset is taken in account only if the `pathArray` is containing a single path
  14860. * @param scene defines the hosting scene
  14861. * @param updatable defines if the mesh must be flagged as updatable
  14862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14863. * @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)
  14864. * @returns a new Mesh
  14865. */
  14866. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14867. /**
  14868. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14869. * @param name defines the name of the mesh to create
  14870. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14871. * @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
  14872. * @param scene defines the hosting scene
  14873. * @param updatable defines if the mesh must be flagged as updatable
  14874. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14875. * @returns a new Mesh
  14876. */
  14877. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14878. /**
  14879. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14880. * @param name defines the name of the mesh to create
  14881. * @param size sets the size (float) of each box side (default 1)
  14882. * @param scene defines the hosting scene
  14883. * @param updatable defines if the mesh must be flagged as updatable
  14884. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14885. * @returns a new Mesh
  14886. */
  14887. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14888. /**
  14889. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14890. * @param name defines the name of the mesh to create
  14891. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14892. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14893. * @param scene defines the hosting scene
  14894. * @param updatable defines if the mesh must be flagged as updatable
  14895. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14896. * @returns a new Mesh
  14897. */
  14898. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14899. /**
  14900. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14901. * @param name defines the name of the mesh to create
  14902. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14903. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14904. * @param scene defines the hosting scene
  14905. * @returns a new Mesh
  14906. */
  14907. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14908. /**
  14909. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14910. * @param name defines the name of the mesh to create
  14911. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14912. * @param diameterTop set the top cap diameter (floats, default 1)
  14913. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14914. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14915. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14916. * @param scene defines the hosting scene
  14917. * @param updatable defines if the mesh must be flagged as updatable
  14918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14919. * @returns a new Mesh
  14920. */
  14921. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14922. /**
  14923. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14924. * @param name defines the name of the mesh to create
  14925. * @param diameter sets the diameter size (float) of the torus (default 1)
  14926. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14927. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14928. * @param scene defines the hosting scene
  14929. * @param updatable defines if the mesh must be flagged as updatable
  14930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14931. * @returns a new Mesh
  14932. */
  14933. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14934. /**
  14935. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14936. * @param name defines the name of the mesh to create
  14937. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14938. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14939. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14940. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14941. * @param p the number of windings on X axis (positive integers, default 2)
  14942. * @param q the number of windings on Y axis (positive integers, default 3)
  14943. * @param scene defines the hosting scene
  14944. * @param updatable defines if the mesh must be flagged as updatable
  14945. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14946. * @returns a new Mesh
  14947. */
  14948. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14949. /**
  14950. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14951. * @param name defines the name of the mesh to create
  14952. * @param points is an array successive Vector3
  14953. * @param scene defines the hosting scene
  14954. * @param updatable defines if the mesh must be flagged as updatable
  14955. * @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).
  14956. * @returns a new Mesh
  14957. */
  14958. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14959. /**
  14960. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14961. * @param name defines the name of the mesh to create
  14962. * @param points is an array successive Vector3
  14963. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14964. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14965. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14966. * @param scene defines the hosting scene
  14967. * @param updatable defines if the mesh must be flagged as updatable
  14968. * @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)
  14969. * @returns a new Mesh
  14970. */
  14971. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14972. /**
  14973. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14974. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14975. * 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.
  14976. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14977. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14978. * Remember you can only change the shape positions, not their number when updating a polygon.
  14979. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14980. * @param name defines the name of the mesh to create
  14981. * @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
  14982. * @param scene defines the hosting scene
  14983. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14984. * @param updatable defines if the mesh must be flagged as updatable
  14985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14986. * @param earcutInjection can be used to inject your own earcut reference
  14987. * @returns a new Mesh
  14988. */
  14989. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14990. /**
  14991. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14992. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14993. * @param name defines the name of the mesh to create
  14994. * @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
  14995. * @param depth defines the height of extrusion
  14996. * @param scene defines the hosting scene
  14997. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14998. * @param updatable defines if the mesh must be flagged as updatable
  14999. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15000. * @param earcutInjection can be used to inject your own earcut reference
  15001. * @returns a new Mesh
  15002. */
  15003. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15004. /**
  15005. * Creates an extruded shape mesh.
  15006. * 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
  15007. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15008. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15009. * @param name defines the name of the mesh to create
  15010. * @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
  15011. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15012. * @param scale is the value to scale the shape
  15013. * @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
  15014. * @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
  15015. * @param scene defines the hosting scene
  15016. * @param updatable defines if the mesh must be flagged as updatable
  15017. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15018. * @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)
  15019. * @returns a new Mesh
  15020. */
  15021. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15022. /**
  15023. * Creates an custom extruded shape mesh.
  15024. * The custom extrusion is a parametric shape.
  15025. * It has no predefined shape. Its final shape will depend on the input parameters.
  15026. * Please consider using the same method from the MeshBuilder class instead
  15027. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15028. * @param name defines the name of the mesh to create
  15029. * @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
  15030. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15031. * @param scaleFunction is a custom Javascript function called on each path point
  15032. * @param rotationFunction is a custom Javascript function called on each path point
  15033. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15034. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15035. * @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
  15036. * @param scene defines the hosting scene
  15037. * @param updatable defines if the mesh must be flagged as updatable
  15038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15039. * @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)
  15040. * @returns a new Mesh
  15041. */
  15042. 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;
  15043. /**
  15044. * Creates lathe mesh.
  15045. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15046. * Please consider using the same method from the MeshBuilder class instead
  15047. * @param name defines the name of the mesh to create
  15048. * @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
  15049. * @param radius is the radius value of the lathe
  15050. * @param tessellation is the side number of the lathe.
  15051. * @param scene defines the hosting scene
  15052. * @param updatable defines if the mesh must be flagged as updatable
  15053. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15054. * @returns a new Mesh
  15055. */
  15056. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15057. /**
  15058. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15059. * @param name defines the name of the mesh to create
  15060. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15061. * @param scene defines the hosting scene
  15062. * @param updatable defines if the mesh must be flagged as updatable
  15063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15064. * @returns a new Mesh
  15065. */
  15066. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15067. /**
  15068. * Creates a ground mesh.
  15069. * Please consider using the same method from the MeshBuilder class instead
  15070. * @param name defines the name of the mesh to create
  15071. * @param width set the width of the ground
  15072. * @param height set the height of the ground
  15073. * @param subdivisions sets the number of subdivisions per side
  15074. * @param scene defines the hosting scene
  15075. * @param updatable defines if the mesh must be flagged as updatable
  15076. * @returns a new Mesh
  15077. */
  15078. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15079. /**
  15080. * Creates a tiled ground mesh.
  15081. * Please consider using the same method from the MeshBuilder class instead
  15082. * @param name defines the name of the mesh to create
  15083. * @param xmin set the ground minimum X coordinate
  15084. * @param zmin set the ground minimum Y coordinate
  15085. * @param xmax set the ground maximum X coordinate
  15086. * @param zmax set the ground maximum Z coordinate
  15087. * @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
  15088. * @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
  15089. * @param scene defines the hosting scene
  15090. * @param updatable defines if the mesh must be flagged as updatable
  15091. * @returns a new Mesh
  15092. */
  15093. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15094. w: number;
  15095. h: number;
  15096. }, precision: {
  15097. w: number;
  15098. h: number;
  15099. }, scene: Scene, updatable?: boolean): Mesh;
  15100. /**
  15101. * Creates a ground mesh from a height map.
  15102. * Please consider using the same method from the MeshBuilder class instead
  15103. * @see http://doc.babylonjs.com/babylon101/height_map
  15104. * @param name defines the name of the mesh to create
  15105. * @param url sets the URL of the height map image resource
  15106. * @param width set the ground width size
  15107. * @param height set the ground height size
  15108. * @param subdivisions sets the number of subdivision per side
  15109. * @param minHeight is the minimum altitude on the ground
  15110. * @param maxHeight is the maximum altitude on the ground
  15111. * @param scene defines the hosting scene
  15112. * @param updatable defines if the mesh must be flagged as updatable
  15113. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15114. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15115. * @returns a new Mesh
  15116. */
  15117. 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;
  15118. /**
  15119. * Creates a tube mesh.
  15120. * The tube is a parametric shape.
  15121. * It has no predefined shape. Its final shape will depend on the input parameters.
  15122. * Please consider using the same method from the MeshBuilder class instead
  15123. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15124. * @param name defines the name of the mesh to create
  15125. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15126. * @param radius sets the tube radius size
  15127. * @param tessellation is the number of sides on the tubular surface
  15128. * @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
  15129. * @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
  15130. * @param scene defines the hosting scene
  15131. * @param updatable defines if the mesh must be flagged as updatable
  15132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15133. * @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)
  15134. * @returns a new Mesh
  15135. */
  15136. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15137. (i: number, distance: number): number;
  15138. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15139. /**
  15140. * Creates a polyhedron mesh.
  15141. * Please consider using the same method from the MeshBuilder class instead.
  15142. * * 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
  15143. * * The parameter `size` (positive float, default 1) sets the polygon size
  15144. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15145. * * 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`
  15146. * * 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
  15147. * * 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)`)
  15148. * * 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
  15149. * * 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
  15150. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15151. * * If you create a double-sided mesh, you can choose what parts of 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
  15152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15153. * @param name defines the name of the mesh to create
  15154. * @param options defines the options used to create the mesh
  15155. * @param scene defines the hosting scene
  15156. * @returns a new Mesh
  15157. */
  15158. static CreatePolyhedron(name: string, options: {
  15159. type?: number;
  15160. size?: number;
  15161. sizeX?: number;
  15162. sizeY?: number;
  15163. sizeZ?: number;
  15164. custom?: any;
  15165. faceUV?: Vector4[];
  15166. faceColors?: Color4[];
  15167. updatable?: boolean;
  15168. sideOrientation?: number;
  15169. }, scene: Scene): Mesh;
  15170. /**
  15171. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15172. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15173. * * 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`)
  15174. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15175. * * 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
  15176. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15177. * * If you create a double-sided mesh, you can choose what parts of 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
  15178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15179. * @param name defines the name of the mesh
  15180. * @param options defines the options used to create the mesh
  15181. * @param scene defines the hosting scene
  15182. * @returns a new Mesh
  15183. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15184. */
  15185. static CreateIcoSphere(name: string, options: {
  15186. radius?: number;
  15187. flat?: boolean;
  15188. subdivisions?: number;
  15189. sideOrientation?: number;
  15190. updatable?: boolean;
  15191. }, scene: Scene): Mesh;
  15192. /**
  15193. * Creates a decal mesh.
  15194. * Please consider using the same method from the MeshBuilder class instead.
  15195. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15196. * @param name defines the name of the mesh
  15197. * @param sourceMesh defines the mesh receiving the decal
  15198. * @param position sets the position of the decal in world coordinates
  15199. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15200. * @param size sets the decal scaling
  15201. * @param angle sets the angle to rotate the decal
  15202. * @returns a new Mesh
  15203. */
  15204. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15205. /**
  15206. * Prepare internal position array for software CPU skinning
  15207. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15208. */
  15209. setPositionsForCPUSkinning(): Float32Array;
  15210. /**
  15211. * Prepare internal normal array for software CPU skinning
  15212. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15213. */
  15214. setNormalsForCPUSkinning(): Float32Array;
  15215. /**
  15216. * Updates the vertex buffer by applying transformation from the bones
  15217. * @param skeleton defines the skeleton to apply to current mesh
  15218. * @returns the current mesh
  15219. */
  15220. applySkeleton(skeleton: Skeleton): Mesh;
  15221. /**
  15222. * 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
  15223. * @param meshes defines the list of meshes to scan
  15224. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15225. */
  15226. static MinMax(meshes: AbstractMesh[]): {
  15227. min: Vector3;
  15228. max: Vector3;
  15229. };
  15230. /**
  15231. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15232. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15233. * @returns a vector3
  15234. */
  15235. static Center(meshesOrMinMaxVector: {
  15236. min: Vector3;
  15237. max: Vector3;
  15238. } | AbstractMesh[]): Vector3;
  15239. /**
  15240. * Merge the array of meshes into a single mesh for performance reasons.
  15241. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15242. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15243. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15244. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15245. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15246. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15247. * @returns a new mesh
  15248. */
  15249. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15250. /** @hidden */
  15251. addInstance(instance: InstancedMesh): void;
  15252. /** @hidden */
  15253. removeInstance(instance: InstancedMesh): void;
  15254. }
  15255. }
  15256. declare module "babylonjs/Actions/action" {
  15257. import { Observable } from "babylonjs/Misc/observable";
  15258. import { Condition } from "babylonjs/Actions/condition";
  15259. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15260. import { ActionManager } from "babylonjs/Actions/actionManager";
  15261. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15262. /**
  15263. * Interface used to define Action
  15264. */
  15265. export interface IAction {
  15266. /**
  15267. * Trigger for the action
  15268. */
  15269. trigger: number;
  15270. /** Options of the trigger */
  15271. triggerOptions: any;
  15272. /**
  15273. * Gets the trigger parameters
  15274. * @returns the trigger parameters
  15275. */
  15276. getTriggerParameter(): any;
  15277. /**
  15278. * Internal only - executes current action event
  15279. * @hidden
  15280. */
  15281. _executeCurrent(evt?: ActionEvent): void;
  15282. /**
  15283. * Serialize placeholder for child classes
  15284. * @param parent of child
  15285. * @returns the serialized object
  15286. */
  15287. serialize(parent: any): any;
  15288. /**
  15289. * Internal only
  15290. * @hidden
  15291. */
  15292. _prepare(): void;
  15293. /**
  15294. * Internal only - manager for action
  15295. * @hidden
  15296. */
  15297. _actionManager: AbstractActionManager;
  15298. /**
  15299. * Adds action to chain of actions, may be a DoNothingAction
  15300. * @param action defines the next action to execute
  15301. * @returns The action passed in
  15302. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15303. */
  15304. then(action: IAction): IAction;
  15305. }
  15306. /**
  15307. * The action to be carried out following a trigger
  15308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15309. */
  15310. export class Action implements IAction {
  15311. /** the trigger, with or without parameters, for the action */
  15312. triggerOptions: any;
  15313. /**
  15314. * Trigger for the action
  15315. */
  15316. trigger: number;
  15317. /**
  15318. * Internal only - manager for action
  15319. * @hidden
  15320. */
  15321. _actionManager: ActionManager;
  15322. private _nextActiveAction;
  15323. private _child;
  15324. private _condition?;
  15325. private _triggerParameter;
  15326. /**
  15327. * An event triggered prior to action being executed.
  15328. */
  15329. onBeforeExecuteObservable: Observable<Action>;
  15330. /**
  15331. * Creates a new Action
  15332. * @param triggerOptions the trigger, with or without parameters, for the action
  15333. * @param condition an optional determinant of action
  15334. */
  15335. constructor(
  15336. /** the trigger, with or without parameters, for the action */
  15337. triggerOptions: any, condition?: Condition);
  15338. /**
  15339. * Internal only
  15340. * @hidden
  15341. */
  15342. _prepare(): void;
  15343. /**
  15344. * Gets the trigger parameters
  15345. * @returns the trigger parameters
  15346. */
  15347. getTriggerParameter(): any;
  15348. /**
  15349. * Internal only - executes current action event
  15350. * @hidden
  15351. */
  15352. _executeCurrent(evt?: ActionEvent): void;
  15353. /**
  15354. * Execute placeholder for child classes
  15355. * @param evt optional action event
  15356. */
  15357. execute(evt?: ActionEvent): void;
  15358. /**
  15359. * Skips to next active action
  15360. */
  15361. skipToNextActiveAction(): void;
  15362. /**
  15363. * Adds action to chain of actions, may be a DoNothingAction
  15364. * @param action defines the next action to execute
  15365. * @returns The action passed in
  15366. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15367. */
  15368. then(action: Action): Action;
  15369. /**
  15370. * Internal only
  15371. * @hidden
  15372. */
  15373. _getProperty(propertyPath: string): string;
  15374. /**
  15375. * Internal only
  15376. * @hidden
  15377. */
  15378. _getEffectiveTarget(target: any, propertyPath: string): any;
  15379. /**
  15380. * Serialize placeholder for child classes
  15381. * @param parent of child
  15382. * @returns the serialized object
  15383. */
  15384. serialize(parent: any): any;
  15385. /**
  15386. * Internal only called by serialize
  15387. * @hidden
  15388. */
  15389. protected _serialize(serializedAction: any, parent?: any): any;
  15390. /**
  15391. * Internal only
  15392. * @hidden
  15393. */
  15394. static _SerializeValueAsString: (value: any) => string;
  15395. /**
  15396. * Internal only
  15397. * @hidden
  15398. */
  15399. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15400. name: string;
  15401. targetType: string;
  15402. value: string;
  15403. };
  15404. }
  15405. }
  15406. declare module "babylonjs/Actions/condition" {
  15407. import { ActionManager } from "babylonjs/Actions/actionManager";
  15408. /**
  15409. * A Condition applied to an Action
  15410. */
  15411. export class Condition {
  15412. /**
  15413. * Internal only - manager for action
  15414. * @hidden
  15415. */
  15416. _actionManager: ActionManager;
  15417. /**
  15418. * Internal only
  15419. * @hidden
  15420. */
  15421. _evaluationId: number;
  15422. /**
  15423. * Internal only
  15424. * @hidden
  15425. */
  15426. _currentResult: boolean;
  15427. /**
  15428. * Creates a new Condition
  15429. * @param actionManager the manager of the action the condition is applied to
  15430. */
  15431. constructor(actionManager: ActionManager);
  15432. /**
  15433. * Check if the current condition is valid
  15434. * @returns a boolean
  15435. */
  15436. isValid(): boolean;
  15437. /**
  15438. * Internal only
  15439. * @hidden
  15440. */
  15441. _getProperty(propertyPath: string): string;
  15442. /**
  15443. * Internal only
  15444. * @hidden
  15445. */
  15446. _getEffectiveTarget(target: any, propertyPath: string): any;
  15447. /**
  15448. * Serialize placeholder for child classes
  15449. * @returns the serialized object
  15450. */
  15451. serialize(): any;
  15452. /**
  15453. * Internal only
  15454. * @hidden
  15455. */
  15456. protected _serialize(serializedCondition: any): any;
  15457. }
  15458. /**
  15459. * Defines specific conditional operators as extensions of Condition
  15460. */
  15461. export class ValueCondition extends Condition {
  15462. /** path to specify the property of the target the conditional operator uses */
  15463. propertyPath: string;
  15464. /** the value compared by the conditional operator against the current value of the property */
  15465. value: any;
  15466. /** the conditional operator, default ValueCondition.IsEqual */
  15467. operator: number;
  15468. /**
  15469. * Internal only
  15470. * @hidden
  15471. */
  15472. private static _IsEqual;
  15473. /**
  15474. * Internal only
  15475. * @hidden
  15476. */
  15477. private static _IsDifferent;
  15478. /**
  15479. * Internal only
  15480. * @hidden
  15481. */
  15482. private static _IsGreater;
  15483. /**
  15484. * Internal only
  15485. * @hidden
  15486. */
  15487. private static _IsLesser;
  15488. /**
  15489. * returns the number for IsEqual
  15490. */
  15491. static readonly IsEqual: number;
  15492. /**
  15493. * Returns the number for IsDifferent
  15494. */
  15495. static readonly IsDifferent: number;
  15496. /**
  15497. * Returns the number for IsGreater
  15498. */
  15499. static readonly IsGreater: number;
  15500. /**
  15501. * Returns the number for IsLesser
  15502. */
  15503. static readonly IsLesser: number;
  15504. /**
  15505. * Internal only The action manager for the condition
  15506. * @hidden
  15507. */
  15508. _actionManager: ActionManager;
  15509. /**
  15510. * Internal only
  15511. * @hidden
  15512. */
  15513. private _target;
  15514. /**
  15515. * Internal only
  15516. * @hidden
  15517. */
  15518. private _effectiveTarget;
  15519. /**
  15520. * Internal only
  15521. * @hidden
  15522. */
  15523. private _property;
  15524. /**
  15525. * Creates a new ValueCondition
  15526. * @param actionManager manager for the action the condition applies to
  15527. * @param target for the action
  15528. * @param propertyPath path to specify the property of the target the conditional operator uses
  15529. * @param value the value compared by the conditional operator against the current value of the property
  15530. * @param operator the conditional operator, default ValueCondition.IsEqual
  15531. */
  15532. constructor(actionManager: ActionManager, target: any,
  15533. /** path to specify the property of the target the conditional operator uses */
  15534. propertyPath: string,
  15535. /** the value compared by the conditional operator against the current value of the property */
  15536. value: any,
  15537. /** the conditional operator, default ValueCondition.IsEqual */
  15538. operator?: number);
  15539. /**
  15540. * Compares the given value with the property value for the specified conditional operator
  15541. * @returns the result of the comparison
  15542. */
  15543. isValid(): boolean;
  15544. /**
  15545. * Serialize the ValueCondition into a JSON compatible object
  15546. * @returns serialization object
  15547. */
  15548. serialize(): any;
  15549. /**
  15550. * Gets the name of the conditional operator for the ValueCondition
  15551. * @param operator the conditional operator
  15552. * @returns the name
  15553. */
  15554. static GetOperatorName(operator: number): string;
  15555. }
  15556. /**
  15557. * Defines a predicate condition as an extension of Condition
  15558. */
  15559. export class PredicateCondition extends Condition {
  15560. /** defines the predicate function used to validate the condition */
  15561. predicate: () => boolean;
  15562. /**
  15563. * Internal only - manager for action
  15564. * @hidden
  15565. */
  15566. _actionManager: ActionManager;
  15567. /**
  15568. * Creates a new PredicateCondition
  15569. * @param actionManager manager for the action the condition applies to
  15570. * @param predicate defines the predicate function used to validate the condition
  15571. */
  15572. constructor(actionManager: ActionManager,
  15573. /** defines the predicate function used to validate the condition */
  15574. predicate: () => boolean);
  15575. /**
  15576. * @returns the validity of the predicate condition
  15577. */
  15578. isValid(): boolean;
  15579. }
  15580. /**
  15581. * Defines a state condition as an extension of Condition
  15582. */
  15583. export class StateCondition extends Condition {
  15584. /** Value to compare with target state */
  15585. value: string;
  15586. /**
  15587. * Internal only - manager for action
  15588. * @hidden
  15589. */
  15590. _actionManager: ActionManager;
  15591. /**
  15592. * Internal only
  15593. * @hidden
  15594. */
  15595. private _target;
  15596. /**
  15597. * Creates a new StateCondition
  15598. * @param actionManager manager for the action the condition applies to
  15599. * @param target of the condition
  15600. * @param value to compare with target state
  15601. */
  15602. constructor(actionManager: ActionManager, target: any,
  15603. /** Value to compare with target state */
  15604. value: string);
  15605. /**
  15606. * Gets a boolean indicating if the current condition is met
  15607. * @returns the validity of the state
  15608. */
  15609. isValid(): boolean;
  15610. /**
  15611. * Serialize the StateCondition into a JSON compatible object
  15612. * @returns serialization object
  15613. */
  15614. serialize(): any;
  15615. }
  15616. }
  15617. declare module "babylonjs/Actions/directActions" {
  15618. import { Action } from "babylonjs/Actions/action";
  15619. import { Condition } from "babylonjs/Actions/condition";
  15620. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15621. /**
  15622. * This defines an action responsible to toggle a boolean once triggered.
  15623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15624. */
  15625. export class SwitchBooleanAction extends Action {
  15626. /**
  15627. * The path to the boolean property in the target object
  15628. */
  15629. propertyPath: string;
  15630. private _target;
  15631. private _effectiveTarget;
  15632. private _property;
  15633. /**
  15634. * Instantiate the action
  15635. * @param triggerOptions defines the trigger options
  15636. * @param target defines the object containing the boolean
  15637. * @param propertyPath defines the path to the boolean property in the target object
  15638. * @param condition defines the trigger related conditions
  15639. */
  15640. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15641. /** @hidden */
  15642. _prepare(): void;
  15643. /**
  15644. * Execute the action toggle the boolean value.
  15645. */
  15646. execute(): void;
  15647. /**
  15648. * Serializes the actions and its related information.
  15649. * @param parent defines the object to serialize in
  15650. * @returns the serialized object
  15651. */
  15652. serialize(parent: any): any;
  15653. }
  15654. /**
  15655. * This defines an action responsible to set a the state field of the target
  15656. * to a desired value once triggered.
  15657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15658. */
  15659. export class SetStateAction extends Action {
  15660. /**
  15661. * The value to store in the state field.
  15662. */
  15663. value: string;
  15664. private _target;
  15665. /**
  15666. * Instantiate the action
  15667. * @param triggerOptions defines the trigger options
  15668. * @param target defines the object containing the state property
  15669. * @param value defines the value to store in the state field
  15670. * @param condition defines the trigger related conditions
  15671. */
  15672. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15673. /**
  15674. * Execute the action and store the value on the target state property.
  15675. */
  15676. execute(): void;
  15677. /**
  15678. * Serializes the actions and its related information.
  15679. * @param parent defines the object to serialize in
  15680. * @returns the serialized object
  15681. */
  15682. serialize(parent: any): any;
  15683. }
  15684. /**
  15685. * This defines an action responsible to set a property of the target
  15686. * to a desired value once triggered.
  15687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15688. */
  15689. export class SetValueAction extends Action {
  15690. /**
  15691. * The path of the property to set in the target.
  15692. */
  15693. propertyPath: string;
  15694. /**
  15695. * The value to set in the property
  15696. */
  15697. value: any;
  15698. private _target;
  15699. private _effectiveTarget;
  15700. private _property;
  15701. /**
  15702. * Instantiate the action
  15703. * @param triggerOptions defines the trigger options
  15704. * @param target defines the object containing the property
  15705. * @param propertyPath defines the path of the property to set in the target
  15706. * @param value defines the value to set in the property
  15707. * @param condition defines the trigger related conditions
  15708. */
  15709. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15710. /** @hidden */
  15711. _prepare(): void;
  15712. /**
  15713. * Execute the action and set the targetted property to the desired value.
  15714. */
  15715. execute(): void;
  15716. /**
  15717. * Serializes the actions and its related information.
  15718. * @param parent defines the object to serialize in
  15719. * @returns the serialized object
  15720. */
  15721. serialize(parent: any): any;
  15722. }
  15723. /**
  15724. * This defines an action responsible to increment the target value
  15725. * to a desired value once triggered.
  15726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15727. */
  15728. export class IncrementValueAction extends Action {
  15729. /**
  15730. * The path of the property to increment in the target.
  15731. */
  15732. propertyPath: string;
  15733. /**
  15734. * The value we should increment the property by.
  15735. */
  15736. value: any;
  15737. private _target;
  15738. private _effectiveTarget;
  15739. private _property;
  15740. /**
  15741. * Instantiate the action
  15742. * @param triggerOptions defines the trigger options
  15743. * @param target defines the object containing the property
  15744. * @param propertyPath defines the path of the property to increment in the target
  15745. * @param value defines the value value we should increment the property by
  15746. * @param condition defines the trigger related conditions
  15747. */
  15748. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15749. /** @hidden */
  15750. _prepare(): void;
  15751. /**
  15752. * Execute the action and increment the target of the value amount.
  15753. */
  15754. execute(): void;
  15755. /**
  15756. * Serializes the actions and its related information.
  15757. * @param parent defines the object to serialize in
  15758. * @returns the serialized object
  15759. */
  15760. serialize(parent: any): any;
  15761. }
  15762. /**
  15763. * This defines an action responsible to start an animation once triggered.
  15764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15765. */
  15766. export class PlayAnimationAction extends Action {
  15767. /**
  15768. * Where the animation should start (animation frame)
  15769. */
  15770. from: number;
  15771. /**
  15772. * Where the animation should stop (animation frame)
  15773. */
  15774. to: number;
  15775. /**
  15776. * Define if the animation should loop or stop after the first play.
  15777. */
  15778. loop?: boolean;
  15779. private _target;
  15780. /**
  15781. * Instantiate the action
  15782. * @param triggerOptions defines the trigger options
  15783. * @param target defines the target animation or animation name
  15784. * @param from defines from where the animation should start (animation frame)
  15785. * @param end defines where the animation should stop (animation frame)
  15786. * @param loop defines if the animation should loop or stop after the first play
  15787. * @param condition defines the trigger related conditions
  15788. */
  15789. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15790. /** @hidden */
  15791. _prepare(): void;
  15792. /**
  15793. * Execute the action and play the animation.
  15794. */
  15795. execute(): void;
  15796. /**
  15797. * Serializes the actions and its related information.
  15798. * @param parent defines the object to serialize in
  15799. * @returns the serialized object
  15800. */
  15801. serialize(parent: any): any;
  15802. }
  15803. /**
  15804. * This defines an action responsible to stop an animation once triggered.
  15805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15806. */
  15807. export class StopAnimationAction extends Action {
  15808. private _target;
  15809. /**
  15810. * Instantiate the action
  15811. * @param triggerOptions defines the trigger options
  15812. * @param target defines the target animation or animation name
  15813. * @param condition defines the trigger related conditions
  15814. */
  15815. constructor(triggerOptions: any, target: any, condition?: Condition);
  15816. /** @hidden */
  15817. _prepare(): void;
  15818. /**
  15819. * Execute the action and stop the animation.
  15820. */
  15821. execute(): void;
  15822. /**
  15823. * Serializes the actions and its related information.
  15824. * @param parent defines the object to serialize in
  15825. * @returns the serialized object
  15826. */
  15827. serialize(parent: any): any;
  15828. }
  15829. /**
  15830. * This defines an action responsible that does nothing once triggered.
  15831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15832. */
  15833. export class DoNothingAction extends Action {
  15834. /**
  15835. * Instantiate the action
  15836. * @param triggerOptions defines the trigger options
  15837. * @param condition defines the trigger related conditions
  15838. */
  15839. constructor(triggerOptions?: any, condition?: Condition);
  15840. /**
  15841. * Execute the action and do nothing.
  15842. */
  15843. execute(): void;
  15844. /**
  15845. * Serializes the actions and its related information.
  15846. * @param parent defines the object to serialize in
  15847. * @returns the serialized object
  15848. */
  15849. serialize(parent: any): any;
  15850. }
  15851. /**
  15852. * This defines an action responsible to trigger several actions once triggered.
  15853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15854. */
  15855. export class CombineAction extends Action {
  15856. /**
  15857. * The list of aggregated animations to run.
  15858. */
  15859. children: Action[];
  15860. /**
  15861. * Instantiate the action
  15862. * @param triggerOptions defines the trigger options
  15863. * @param children defines the list of aggregated animations to run
  15864. * @param condition defines the trigger related conditions
  15865. */
  15866. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15867. /** @hidden */
  15868. _prepare(): void;
  15869. /**
  15870. * Execute the action and executes all the aggregated actions.
  15871. */
  15872. execute(evt: ActionEvent): void;
  15873. /**
  15874. * Serializes the actions and its related information.
  15875. * @param parent defines the object to serialize in
  15876. * @returns the serialized object
  15877. */
  15878. serialize(parent: any): any;
  15879. }
  15880. /**
  15881. * This defines an action responsible to run code (external event) once triggered.
  15882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15883. */
  15884. export class ExecuteCodeAction extends Action {
  15885. /**
  15886. * The callback function to run.
  15887. */
  15888. func: (evt: ActionEvent) => void;
  15889. /**
  15890. * Instantiate the action
  15891. * @param triggerOptions defines the trigger options
  15892. * @param func defines the callback function to run
  15893. * @param condition defines the trigger related conditions
  15894. */
  15895. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15896. /**
  15897. * Execute the action and run the attached code.
  15898. */
  15899. execute(evt: ActionEvent): void;
  15900. }
  15901. /**
  15902. * This defines an action responsible to set the parent property of the target once triggered.
  15903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15904. */
  15905. export class SetParentAction extends Action {
  15906. private _parent;
  15907. private _target;
  15908. /**
  15909. * Instantiate the action
  15910. * @param triggerOptions defines the trigger options
  15911. * @param target defines the target containing the parent property
  15912. * @param parent defines from where the animation should start (animation frame)
  15913. * @param condition defines the trigger related conditions
  15914. */
  15915. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15916. /** @hidden */
  15917. _prepare(): void;
  15918. /**
  15919. * Execute the action and set the parent property.
  15920. */
  15921. execute(): void;
  15922. /**
  15923. * Serializes the actions and its related information.
  15924. * @param parent defines the object to serialize in
  15925. * @returns the serialized object
  15926. */
  15927. serialize(parent: any): any;
  15928. }
  15929. }
  15930. declare module "babylonjs/Actions/actionManager" {
  15931. import { Nullable } from "babylonjs/types";
  15932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15933. import { Scene } from "babylonjs/scene";
  15934. import { IAction } from "babylonjs/Actions/action";
  15935. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  15936. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15937. /**
  15938. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15939. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15941. */
  15942. export class ActionManager extends AbstractActionManager {
  15943. /**
  15944. * Nothing
  15945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15946. */
  15947. static readonly NothingTrigger: number;
  15948. /**
  15949. * On pick
  15950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15951. */
  15952. static readonly OnPickTrigger: number;
  15953. /**
  15954. * On left pick
  15955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15956. */
  15957. static readonly OnLeftPickTrigger: number;
  15958. /**
  15959. * On right pick
  15960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15961. */
  15962. static readonly OnRightPickTrigger: number;
  15963. /**
  15964. * On center pick
  15965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15966. */
  15967. static readonly OnCenterPickTrigger: number;
  15968. /**
  15969. * On pick down
  15970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15971. */
  15972. static readonly OnPickDownTrigger: number;
  15973. /**
  15974. * On double pick
  15975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15976. */
  15977. static readonly OnDoublePickTrigger: number;
  15978. /**
  15979. * On pick up
  15980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15981. */
  15982. static readonly OnPickUpTrigger: number;
  15983. /**
  15984. * On pick out.
  15985. * This trigger will only be raised if you also declared a OnPickDown
  15986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15987. */
  15988. static readonly OnPickOutTrigger: number;
  15989. /**
  15990. * On long press
  15991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15992. */
  15993. static readonly OnLongPressTrigger: number;
  15994. /**
  15995. * On pointer over
  15996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15997. */
  15998. static readonly OnPointerOverTrigger: number;
  15999. /**
  16000. * On pointer out
  16001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16002. */
  16003. static readonly OnPointerOutTrigger: number;
  16004. /**
  16005. * On every frame
  16006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16007. */
  16008. static readonly OnEveryFrameTrigger: number;
  16009. /**
  16010. * On intersection enter
  16011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16012. */
  16013. static readonly OnIntersectionEnterTrigger: number;
  16014. /**
  16015. * On intersection exit
  16016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16017. */
  16018. static readonly OnIntersectionExitTrigger: number;
  16019. /**
  16020. * On key down
  16021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16022. */
  16023. static readonly OnKeyDownTrigger: number;
  16024. /**
  16025. * On key up
  16026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16027. */
  16028. static readonly OnKeyUpTrigger: number;
  16029. private _scene;
  16030. /**
  16031. * Creates a new action manager
  16032. * @param scene defines the hosting scene
  16033. */
  16034. constructor(scene: Scene);
  16035. /**
  16036. * Releases all associated resources
  16037. */
  16038. dispose(): void;
  16039. /**
  16040. * Gets hosting scene
  16041. * @returns the hosting scene
  16042. */
  16043. getScene(): Scene;
  16044. /**
  16045. * Does this action manager handles actions of any of the given triggers
  16046. * @param triggers defines the triggers to be tested
  16047. * @return a boolean indicating whether one (or more) of the triggers is handled
  16048. */
  16049. hasSpecificTriggers(triggers: number[]): boolean;
  16050. /**
  16051. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16052. * speed.
  16053. * @param triggerA defines the trigger to be tested
  16054. * @param triggerB defines the trigger to be tested
  16055. * @return a boolean indicating whether one (or more) of the triggers is handled
  16056. */
  16057. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16058. /**
  16059. * Does this action manager handles actions of a given trigger
  16060. * @param trigger defines the trigger to be tested
  16061. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16062. * @return whether the trigger is handled
  16063. */
  16064. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16065. /**
  16066. * Does this action manager has pointer triggers
  16067. */
  16068. readonly hasPointerTriggers: boolean;
  16069. /**
  16070. * Does this action manager has pick triggers
  16071. */
  16072. readonly hasPickTriggers: boolean;
  16073. /**
  16074. * Registers an action to this action manager
  16075. * @param action defines the action to be registered
  16076. * @return the action amended (prepared) after registration
  16077. */
  16078. registerAction(action: IAction): Nullable<IAction>;
  16079. /**
  16080. * Unregisters an action to this action manager
  16081. * @param action defines the action to be unregistered
  16082. * @return a boolean indicating whether the action has been unregistered
  16083. */
  16084. unregisterAction(action: IAction): Boolean;
  16085. /**
  16086. * Process a specific trigger
  16087. * @param trigger defines the trigger to process
  16088. * @param evt defines the event details to be processed
  16089. */
  16090. processTrigger(trigger: number, evt?: IActionEvent): void;
  16091. /** @hidden */
  16092. _getEffectiveTarget(target: any, propertyPath: string): any;
  16093. /** @hidden */
  16094. _getProperty(propertyPath: string): string;
  16095. /**
  16096. * Serialize this manager to a JSON object
  16097. * @param name defines the property name to store this manager
  16098. * @returns a JSON representation of this manager
  16099. */
  16100. serialize(name: string): any;
  16101. /**
  16102. * Creates a new ActionManager from a JSON data
  16103. * @param parsedActions defines the JSON data to read from
  16104. * @param object defines the hosting mesh
  16105. * @param scene defines the hosting scene
  16106. */
  16107. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16108. /**
  16109. * Get a trigger name by index
  16110. * @param trigger defines the trigger index
  16111. * @returns a trigger name
  16112. */
  16113. static GetTriggerName(trigger: number): string;
  16114. }
  16115. }
  16116. declare module "babylonjs/Culling/ray" {
  16117. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16118. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16120. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16121. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16122. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16123. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16124. /**
  16125. * Class representing a ray with position and direction
  16126. */
  16127. export class Ray {
  16128. /** origin point */
  16129. origin: Vector3;
  16130. /** direction */
  16131. direction: Vector3;
  16132. /** length of the ray */
  16133. length: number;
  16134. private static readonly TmpVector3;
  16135. private _tmpRay;
  16136. /**
  16137. * Creates a new ray
  16138. * @param origin origin point
  16139. * @param direction direction
  16140. * @param length length of the ray
  16141. */
  16142. constructor(
  16143. /** origin point */
  16144. origin: Vector3,
  16145. /** direction */
  16146. direction: Vector3,
  16147. /** length of the ray */
  16148. length?: number);
  16149. /**
  16150. * Checks if the ray intersects a box
  16151. * @param minimum bound of the box
  16152. * @param maximum bound of the box
  16153. * @param intersectionTreshold extra extend to be added to the box in all direction
  16154. * @returns if the box was hit
  16155. */
  16156. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16157. /**
  16158. * Checks if the ray intersects a box
  16159. * @param box the bounding box to check
  16160. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16161. * @returns if the box was hit
  16162. */
  16163. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16164. /**
  16165. * If the ray hits a sphere
  16166. * @param sphere the bounding sphere to check
  16167. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16168. * @returns true if it hits the sphere
  16169. */
  16170. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16171. /**
  16172. * If the ray hits a triange
  16173. * @param vertex0 triangle vertex
  16174. * @param vertex1 triangle vertex
  16175. * @param vertex2 triangle vertex
  16176. * @returns intersection information if hit
  16177. */
  16178. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16179. /**
  16180. * Checks if ray intersects a plane
  16181. * @param plane the plane to check
  16182. * @returns the distance away it was hit
  16183. */
  16184. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16185. /**
  16186. * Checks if ray intersects a mesh
  16187. * @param mesh the mesh to check
  16188. * @param fastCheck if only the bounding box should checked
  16189. * @returns picking info of the intersecton
  16190. */
  16191. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16192. /**
  16193. * Checks if ray intersects a mesh
  16194. * @param meshes the meshes to check
  16195. * @param fastCheck if only the bounding box should checked
  16196. * @param results array to store result in
  16197. * @returns Array of picking infos
  16198. */
  16199. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16200. private _comparePickingInfo;
  16201. private static smallnum;
  16202. private static rayl;
  16203. /**
  16204. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16205. * @param sega the first point of the segment to test the intersection against
  16206. * @param segb the second point of the segment to test the intersection against
  16207. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16208. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16209. */
  16210. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16211. /**
  16212. * Update the ray from viewport position
  16213. * @param x position
  16214. * @param y y position
  16215. * @param viewportWidth viewport width
  16216. * @param viewportHeight viewport height
  16217. * @param world world matrix
  16218. * @param view view matrix
  16219. * @param projection projection matrix
  16220. * @returns this ray updated
  16221. */
  16222. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16223. /**
  16224. * Creates a ray with origin and direction of 0,0,0
  16225. * @returns the new ray
  16226. */
  16227. static Zero(): Ray;
  16228. /**
  16229. * Creates a new ray from screen space and viewport
  16230. * @param x position
  16231. * @param y y position
  16232. * @param viewportWidth viewport width
  16233. * @param viewportHeight viewport height
  16234. * @param world world matrix
  16235. * @param view view matrix
  16236. * @param projection projection matrix
  16237. * @returns new ray
  16238. */
  16239. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16240. /**
  16241. * 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
  16242. * transformed to the given world matrix.
  16243. * @param origin The origin point
  16244. * @param end The end point
  16245. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16246. * @returns the new ray
  16247. */
  16248. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16249. /**
  16250. * Transforms a ray by a matrix
  16251. * @param ray ray to transform
  16252. * @param matrix matrix to apply
  16253. * @returns the resulting new ray
  16254. */
  16255. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16256. /**
  16257. * Transforms a ray by a matrix
  16258. * @param ray ray to transform
  16259. * @param matrix matrix to apply
  16260. * @param result ray to store result in
  16261. */
  16262. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16263. /**
  16264. * Unproject a ray from screen space to object space
  16265. * @param sourceX defines the screen space x coordinate to use
  16266. * @param sourceY defines the screen space y coordinate to use
  16267. * @param viewportWidth defines the current width of the viewport
  16268. * @param viewportHeight defines the current height of the viewport
  16269. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16270. * @param view defines the view matrix to use
  16271. * @param projection defines the projection matrix to use
  16272. */
  16273. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16274. }
  16275. /**
  16276. * Type used to define predicate used to select faces when a mesh intersection is detected
  16277. */
  16278. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16279. module "babylonjs/scene" {
  16280. interface Scene {
  16281. /** @hidden */
  16282. _tempPickingRay: Nullable<Ray>;
  16283. /** @hidden */
  16284. _cachedRayForTransform: Ray;
  16285. /** @hidden */
  16286. _pickWithRayInverseMatrix: Matrix;
  16287. /** @hidden */
  16288. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16289. /** @hidden */
  16290. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16291. }
  16292. }
  16293. }
  16294. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16295. import { Nullable } from "babylonjs/types";
  16296. import { Observable } from "babylonjs/Misc/observable";
  16297. import { Scene } from "babylonjs/scene";
  16298. import { Sprite } from "babylonjs/Sprites/sprite";
  16299. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16300. import { Ray } from "babylonjs/Culling/ray";
  16301. import { Camera } from "babylonjs/Cameras/camera";
  16302. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16303. import { ISceneComponent } from "babylonjs/sceneComponent";
  16304. module "babylonjs/scene" {
  16305. interface Scene {
  16306. /** @hidden */
  16307. _pointerOverSprite: Nullable<Sprite>;
  16308. /** @hidden */
  16309. _pickedDownSprite: Nullable<Sprite>;
  16310. /** @hidden */
  16311. _tempSpritePickingRay: Nullable<Ray>;
  16312. /**
  16313. * All of the sprite managers added to this scene
  16314. * @see http://doc.babylonjs.com/babylon101/sprites
  16315. */
  16316. spriteManagers: Array<ISpriteManager>;
  16317. /**
  16318. * An event triggered when sprites rendering is about to start
  16319. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16320. */
  16321. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16322. /**
  16323. * An event triggered when sprites rendering is done
  16324. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16325. */
  16326. onAfterSpritesRenderingObservable: Observable<Scene>;
  16327. /** @hidden */
  16328. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16329. /** Launch a ray to try to pick a sprite in the scene
  16330. * @param x position on screen
  16331. * @param y position on screen
  16332. * @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
  16333. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16334. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16335. * @returns a PickingInfo
  16336. */
  16337. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16338. /** Use the given ray to pick a sprite in the scene
  16339. * @param ray The ray (in world space) to use to pick meshes
  16340. * @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
  16341. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16342. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16343. * @returns a PickingInfo
  16344. */
  16345. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16346. /**
  16347. * Force the sprite under the pointer
  16348. * @param sprite defines the sprite to use
  16349. */
  16350. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16351. /**
  16352. * Gets the sprite under the pointer
  16353. * @returns a Sprite or null if no sprite is under the pointer
  16354. */
  16355. getPointerOverSprite(): Nullable<Sprite>;
  16356. }
  16357. }
  16358. /**
  16359. * Defines the sprite scene component responsible to manage sprites
  16360. * in a given scene.
  16361. */
  16362. export class SpriteSceneComponent implements ISceneComponent {
  16363. /**
  16364. * The component name helpfull to identify the component in the list of scene components.
  16365. */
  16366. readonly name: string;
  16367. /**
  16368. * The scene the component belongs to.
  16369. */
  16370. scene: Scene;
  16371. /** @hidden */
  16372. private _spritePredicate;
  16373. /**
  16374. * Creates a new instance of the component for the given scene
  16375. * @param scene Defines the scene to register the component in
  16376. */
  16377. constructor(scene: Scene);
  16378. /**
  16379. * Registers the component in a given scene
  16380. */
  16381. register(): void;
  16382. /**
  16383. * Rebuilds the elements related to this component in case of
  16384. * context lost for instance.
  16385. */
  16386. rebuild(): void;
  16387. /**
  16388. * Disposes the component and the associated ressources.
  16389. */
  16390. dispose(): void;
  16391. private _pickSpriteButKeepRay;
  16392. private _pointerMove;
  16393. private _pointerDown;
  16394. private _pointerUp;
  16395. }
  16396. }
  16397. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16398. /** @hidden */
  16399. export var fogFragmentDeclaration: {
  16400. name: string;
  16401. shader: string;
  16402. };
  16403. }
  16404. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16405. /** @hidden */
  16406. export var fogFragment: {
  16407. name: string;
  16408. shader: string;
  16409. };
  16410. }
  16411. declare module "babylonjs/Shaders/sprites.fragment" {
  16412. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16413. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16414. /** @hidden */
  16415. export var spritesPixelShader: {
  16416. name: string;
  16417. shader: string;
  16418. };
  16419. }
  16420. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16421. /** @hidden */
  16422. export var fogVertexDeclaration: {
  16423. name: string;
  16424. shader: string;
  16425. };
  16426. }
  16427. declare module "babylonjs/Shaders/sprites.vertex" {
  16428. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16429. /** @hidden */
  16430. export var spritesVertexShader: {
  16431. name: string;
  16432. shader: string;
  16433. };
  16434. }
  16435. declare module "babylonjs/Sprites/spriteManager" {
  16436. import { IDisposable, Scene } from "babylonjs/scene";
  16437. import { Nullable } from "babylonjs/types";
  16438. import { Observable } from "babylonjs/Misc/observable";
  16439. import { Sprite } from "babylonjs/Sprites/sprite";
  16440. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16441. import { Camera } from "babylonjs/Cameras/camera";
  16442. import { Texture } from "babylonjs/Materials/Textures/texture";
  16443. import "babylonjs/Shaders/sprites.fragment";
  16444. import "babylonjs/Shaders/sprites.vertex";
  16445. import { Ray } from "babylonjs/Culling/ray";
  16446. /**
  16447. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16448. */
  16449. export interface ISpriteManager extends IDisposable {
  16450. /**
  16451. * Restricts the camera to viewing objects with the same layerMask.
  16452. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16453. */
  16454. layerMask: number;
  16455. /**
  16456. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16457. */
  16458. isPickable: boolean;
  16459. /**
  16460. * Specifies the rendering group id for this mesh (0 by default)
  16461. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16462. */
  16463. renderingGroupId: number;
  16464. /**
  16465. * Defines the list of sprites managed by the manager.
  16466. */
  16467. sprites: Array<Sprite>;
  16468. /**
  16469. * Tests the intersection of a sprite with a specific ray.
  16470. * @param ray The ray we are sending to test the collision
  16471. * @param camera The camera space we are sending rays in
  16472. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16473. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16474. * @returns picking info or null.
  16475. */
  16476. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16477. /**
  16478. * Renders the list of sprites on screen.
  16479. */
  16480. render(): void;
  16481. }
  16482. /**
  16483. * Class used to manage multiple sprites on the same spritesheet
  16484. * @see http://doc.babylonjs.com/babylon101/sprites
  16485. */
  16486. export class SpriteManager implements ISpriteManager {
  16487. /** defines the manager's name */
  16488. name: string;
  16489. /** Gets the list of sprites */
  16490. sprites: Sprite[];
  16491. /** Gets or sets the rendering group id (0 by default) */
  16492. renderingGroupId: number;
  16493. /** Gets or sets camera layer mask */
  16494. layerMask: number;
  16495. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16496. fogEnabled: boolean;
  16497. /** Gets or sets a boolean indicating if the sprites are pickable */
  16498. isPickable: boolean;
  16499. /** Defines the default width of a cell in the spritesheet */
  16500. cellWidth: number;
  16501. /** Defines the default height of a cell in the spritesheet */
  16502. cellHeight: number;
  16503. /**
  16504. * An event triggered when the manager is disposed.
  16505. */
  16506. onDisposeObservable: Observable<SpriteManager>;
  16507. private _onDisposeObserver;
  16508. /**
  16509. * Callback called when the manager is disposed
  16510. */
  16511. onDispose: () => void;
  16512. private _capacity;
  16513. private _spriteTexture;
  16514. private _epsilon;
  16515. private _scene;
  16516. private _vertexData;
  16517. private _buffer;
  16518. private _vertexBuffers;
  16519. private _indexBuffer;
  16520. private _effectBase;
  16521. private _effectFog;
  16522. /**
  16523. * Gets or sets the spritesheet texture
  16524. */
  16525. texture: Texture;
  16526. /**
  16527. * Creates a new sprite manager
  16528. * @param name defines the manager's name
  16529. * @param imgUrl defines the sprite sheet url
  16530. * @param capacity defines the maximum allowed number of sprites
  16531. * @param cellSize defines the size of a sprite cell
  16532. * @param scene defines the hosting scene
  16533. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16534. * @param samplingMode defines the smapling mode to use with spritesheet
  16535. */
  16536. constructor(
  16537. /** defines the manager's name */
  16538. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16539. private _appendSpriteVertex;
  16540. /**
  16541. * Intersects the sprites with a ray
  16542. * @param ray defines the ray to intersect with
  16543. * @param camera defines the current active camera
  16544. * @param predicate defines a predicate used to select candidate sprites
  16545. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16546. * @returns null if no hit or a PickingInfo
  16547. */
  16548. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16549. /**
  16550. * Render all child sprites
  16551. */
  16552. render(): void;
  16553. /**
  16554. * Release associated resources
  16555. */
  16556. dispose(): void;
  16557. }
  16558. }
  16559. declare module "babylonjs/Sprites/sprite" {
  16560. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16561. import { Nullable } from "babylonjs/types";
  16562. import { ActionManager } from "babylonjs/Actions/actionManager";
  16563. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16564. /**
  16565. * Class used to represent a sprite
  16566. * @see http://doc.babylonjs.com/babylon101/sprites
  16567. */
  16568. export class Sprite {
  16569. /** defines the name */
  16570. name: string;
  16571. /** Gets or sets the current world position */
  16572. position: Vector3;
  16573. /** Gets or sets the main color */
  16574. color: Color4;
  16575. /** Gets or sets the width */
  16576. width: number;
  16577. /** Gets or sets the height */
  16578. height: number;
  16579. /** Gets or sets rotation angle */
  16580. angle: number;
  16581. /** Gets or sets the cell index in the sprite sheet */
  16582. cellIndex: number;
  16583. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16584. invertU: number;
  16585. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16586. invertV: number;
  16587. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16588. disposeWhenFinishedAnimating: boolean;
  16589. /** Gets the list of attached animations */
  16590. animations: Animation[];
  16591. /** Gets or sets a boolean indicating if the sprite can be picked */
  16592. isPickable: boolean;
  16593. /**
  16594. * Gets or sets the associated action manager
  16595. */
  16596. actionManager: Nullable<ActionManager>;
  16597. private _animationStarted;
  16598. private _loopAnimation;
  16599. private _fromIndex;
  16600. private _toIndex;
  16601. private _delay;
  16602. private _direction;
  16603. private _manager;
  16604. private _time;
  16605. private _onAnimationEnd;
  16606. /**
  16607. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16608. */
  16609. isVisible: boolean;
  16610. /**
  16611. * Gets or sets the sprite size
  16612. */
  16613. size: number;
  16614. /**
  16615. * Creates a new Sprite
  16616. * @param name defines the name
  16617. * @param manager defines the manager
  16618. */
  16619. constructor(
  16620. /** defines the name */
  16621. name: string, manager: ISpriteManager);
  16622. /**
  16623. * Starts an animation
  16624. * @param from defines the initial key
  16625. * @param to defines the end key
  16626. * @param loop defines if the animation must loop
  16627. * @param delay defines the start delay (in ms)
  16628. * @param onAnimationEnd defines a callback to call when animation ends
  16629. */
  16630. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16631. /** Stops current animation (if any) */
  16632. stopAnimation(): void;
  16633. /** @hidden */
  16634. _animate(deltaTime: number): void;
  16635. /** Release associated resources */
  16636. dispose(): void;
  16637. }
  16638. }
  16639. declare module "babylonjs/Collisions/pickingInfo" {
  16640. import { Nullable } from "babylonjs/types";
  16641. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16643. import { Sprite } from "babylonjs/Sprites/sprite";
  16644. import { Ray } from "babylonjs/Culling/ray";
  16645. /**
  16646. * Information about the result of picking within a scene
  16647. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16648. */
  16649. export class PickingInfo {
  16650. /** @hidden */
  16651. _pickingUnavailable: boolean;
  16652. /**
  16653. * If the pick collided with an object
  16654. */
  16655. hit: boolean;
  16656. /**
  16657. * Distance away where the pick collided
  16658. */
  16659. distance: number;
  16660. /**
  16661. * The location of pick collision
  16662. */
  16663. pickedPoint: Nullable<Vector3>;
  16664. /**
  16665. * The mesh corresponding the the pick collision
  16666. */
  16667. pickedMesh: Nullable<AbstractMesh>;
  16668. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16669. bu: number;
  16670. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16671. bv: number;
  16672. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16673. faceId: number;
  16674. /** Id of the the submesh that was picked */
  16675. subMeshId: number;
  16676. /** If a sprite was picked, this will be the sprite the pick collided with */
  16677. pickedSprite: Nullable<Sprite>;
  16678. /**
  16679. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16680. */
  16681. originMesh: Nullable<AbstractMesh>;
  16682. /**
  16683. * The ray that was used to perform the picking.
  16684. */
  16685. ray: Nullable<Ray>;
  16686. /**
  16687. * Gets the normal correspodning to the face the pick collided with
  16688. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16689. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16690. * @returns The normal correspodning to the face the pick collided with
  16691. */
  16692. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16693. /**
  16694. * Gets the texture coordinates of where the pick occured
  16695. * @returns the vector containing the coordnates of the texture
  16696. */
  16697. getTextureCoordinates(): Nullable<Vector2>;
  16698. }
  16699. }
  16700. declare module "babylonjs/Events/pointerEvents" {
  16701. import { Nullable } from "babylonjs/types";
  16702. import { Vector2 } from "babylonjs/Maths/math";
  16703. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16704. import { Ray } from "babylonjs/Culling/ray";
  16705. /**
  16706. * Gather the list of pointer event types as constants.
  16707. */
  16708. export class PointerEventTypes {
  16709. /**
  16710. * 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.
  16711. */
  16712. static readonly POINTERDOWN: number;
  16713. /**
  16714. * The pointerup event is fired when a pointer is no longer active.
  16715. */
  16716. static readonly POINTERUP: number;
  16717. /**
  16718. * The pointermove event is fired when a pointer changes coordinates.
  16719. */
  16720. static readonly POINTERMOVE: number;
  16721. /**
  16722. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16723. */
  16724. static readonly POINTERWHEEL: number;
  16725. /**
  16726. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16727. */
  16728. static readonly POINTERPICK: number;
  16729. /**
  16730. * The pointertap event is fired when a the object has been touched and released without drag.
  16731. */
  16732. static readonly POINTERTAP: number;
  16733. /**
  16734. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16735. */
  16736. static readonly POINTERDOUBLETAP: number;
  16737. }
  16738. /**
  16739. * Base class of pointer info types.
  16740. */
  16741. export class PointerInfoBase {
  16742. /**
  16743. * Defines the type of event (PointerEventTypes)
  16744. */
  16745. type: number;
  16746. /**
  16747. * Defines the related dom event
  16748. */
  16749. event: PointerEvent | MouseWheelEvent;
  16750. /**
  16751. * Instantiates the base class of pointers info.
  16752. * @param type Defines the type of event (PointerEventTypes)
  16753. * @param event Defines the related dom event
  16754. */
  16755. constructor(
  16756. /**
  16757. * Defines the type of event (PointerEventTypes)
  16758. */
  16759. type: number,
  16760. /**
  16761. * Defines the related dom event
  16762. */
  16763. event: PointerEvent | MouseWheelEvent);
  16764. }
  16765. /**
  16766. * This class is used to store pointer related info for the onPrePointerObservable event.
  16767. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16768. */
  16769. export class PointerInfoPre extends PointerInfoBase {
  16770. /**
  16771. * Ray from a pointer if availible (eg. 6dof controller)
  16772. */
  16773. ray: Nullable<Ray>;
  16774. /**
  16775. * Defines the local position of the pointer on the canvas.
  16776. */
  16777. localPosition: Vector2;
  16778. /**
  16779. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16780. */
  16781. skipOnPointerObservable: boolean;
  16782. /**
  16783. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16784. * @param type Defines the type of event (PointerEventTypes)
  16785. * @param event Defines the related dom event
  16786. * @param localX Defines the local x coordinates of the pointer when the event occured
  16787. * @param localY Defines the local y coordinates of the pointer when the event occured
  16788. */
  16789. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16790. }
  16791. /**
  16792. * This type contains all the data related to a pointer event in Babylon.js.
  16793. * 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.
  16794. */
  16795. export class PointerInfo extends PointerInfoBase {
  16796. /**
  16797. * Defines the picking info associated to the info (if any)\
  16798. */
  16799. pickInfo: Nullable<PickingInfo>;
  16800. /**
  16801. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16802. * @param type Defines the type of event (PointerEventTypes)
  16803. * @param event Defines the related dom event
  16804. * @param pickInfo Defines the picking info associated to the info (if any)\
  16805. */
  16806. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16807. /**
  16808. * Defines the picking info associated to the info (if any)\
  16809. */
  16810. pickInfo: Nullable<PickingInfo>);
  16811. }
  16812. /**
  16813. * Data relating to a touch event on the screen.
  16814. */
  16815. export interface PointerTouch {
  16816. /**
  16817. * X coordinate of touch.
  16818. */
  16819. x: number;
  16820. /**
  16821. * Y coordinate of touch.
  16822. */
  16823. y: number;
  16824. /**
  16825. * Id of touch. Unique for each finger.
  16826. */
  16827. pointerId: number;
  16828. /**
  16829. * Event type passed from DOM.
  16830. */
  16831. type: any;
  16832. }
  16833. }
  16834. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16835. import { Observable } from "babylonjs/Misc/observable";
  16836. import { Nullable } from "babylonjs/types";
  16837. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16838. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16839. /**
  16840. * Manage the mouse inputs to control the movement of a free camera.
  16841. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16842. */
  16843. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16844. /**
  16845. * Define if touch is enabled in the mouse input
  16846. */
  16847. touchEnabled: boolean;
  16848. /**
  16849. * Defines the camera the input is attached to.
  16850. */
  16851. camera: FreeCamera;
  16852. /**
  16853. * Defines the buttons associated with the input to handle camera move.
  16854. */
  16855. buttons: number[];
  16856. /**
  16857. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16858. */
  16859. angularSensibility: number;
  16860. private _pointerInput;
  16861. private _onMouseMove;
  16862. private _observer;
  16863. private previousPosition;
  16864. /**
  16865. * Observable for when a pointer move event occurs containing the move offset
  16866. */
  16867. onPointerMovedObservable: Observable<{
  16868. offsetX: number;
  16869. offsetY: number;
  16870. }>;
  16871. /**
  16872. * @hidden
  16873. * If the camera should be rotated automatically based on pointer movement
  16874. */
  16875. _allowCameraRotation: boolean;
  16876. /**
  16877. * Manage the mouse inputs to control the movement of a free camera.
  16878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16879. * @param touchEnabled Defines if touch is enabled or not
  16880. */
  16881. constructor(
  16882. /**
  16883. * Define if touch is enabled in the mouse input
  16884. */
  16885. touchEnabled?: boolean);
  16886. /**
  16887. * Attach the input controls to a specific dom element to get the input from.
  16888. * @param element Defines the element the controls should be listened from
  16889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16890. */
  16891. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16892. /**
  16893. * Called on JS contextmenu event.
  16894. * Override this method to provide functionality.
  16895. */
  16896. protected onContextMenu(evt: PointerEvent): void;
  16897. /**
  16898. * Detach the current controls from the specified dom element.
  16899. * @param element Defines the element to stop listening the inputs from
  16900. */
  16901. detachControl(element: Nullable<HTMLElement>): void;
  16902. /**
  16903. * Gets the class name of the current intput.
  16904. * @returns the class name
  16905. */
  16906. getClassName(): string;
  16907. /**
  16908. * Get the friendly name associated with the input class.
  16909. * @returns the input friendly name
  16910. */
  16911. getSimpleName(): string;
  16912. }
  16913. }
  16914. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  16915. import { Nullable } from "babylonjs/types";
  16916. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16917. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16918. /**
  16919. * Manage the touch inputs to control the movement of a free camera.
  16920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16921. */
  16922. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16923. /**
  16924. * Defines the camera the input is attached to.
  16925. */
  16926. camera: FreeCamera;
  16927. /**
  16928. * Defines the touch sensibility for rotation.
  16929. * The higher the faster.
  16930. */
  16931. touchAngularSensibility: number;
  16932. /**
  16933. * Defines the touch sensibility for move.
  16934. * The higher the faster.
  16935. */
  16936. touchMoveSensibility: number;
  16937. private _offsetX;
  16938. private _offsetY;
  16939. private _pointerPressed;
  16940. private _pointerInput;
  16941. private _observer;
  16942. private _onLostFocus;
  16943. /**
  16944. * Attach the input controls to a specific dom element to get the input from.
  16945. * @param element Defines the element the controls should be listened from
  16946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16947. */
  16948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16949. /**
  16950. * Detach the current controls from the specified dom element.
  16951. * @param element Defines the element to stop listening the inputs from
  16952. */
  16953. detachControl(element: Nullable<HTMLElement>): void;
  16954. /**
  16955. * Update the current camera state depending on the inputs that have been used this frame.
  16956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16957. */
  16958. checkInputs(): void;
  16959. /**
  16960. * Gets the class name of the current intput.
  16961. * @returns the class name
  16962. */
  16963. getClassName(): string;
  16964. /**
  16965. * Get the friendly name associated with the input class.
  16966. * @returns the input friendly name
  16967. */
  16968. getSimpleName(): string;
  16969. }
  16970. }
  16971. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  16972. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16973. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  16974. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  16975. import { Nullable } from "babylonjs/types";
  16976. /**
  16977. * Default Inputs manager for the FreeCamera.
  16978. * It groups all the default supported inputs for ease of use.
  16979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16980. */
  16981. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16982. /**
  16983. * @hidden
  16984. */
  16985. _mouseInput: Nullable<FreeCameraMouseInput>;
  16986. /**
  16987. * Instantiates a new FreeCameraInputsManager.
  16988. * @param camera Defines the camera the inputs belong to
  16989. */
  16990. constructor(camera: FreeCamera);
  16991. /**
  16992. * Add keyboard input support to the input manager.
  16993. * @returns the current input manager
  16994. */
  16995. addKeyboard(): FreeCameraInputsManager;
  16996. /**
  16997. * Add mouse input support to the input manager.
  16998. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16999. * @returns the current input manager
  17000. */
  17001. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17002. /**
  17003. * Removes the mouse input support from the manager
  17004. * @returns the current input manager
  17005. */
  17006. removeMouse(): FreeCameraInputsManager;
  17007. /**
  17008. * Add touch input support to the input manager.
  17009. * @returns the current input manager
  17010. */
  17011. addTouch(): FreeCameraInputsManager;
  17012. /**
  17013. * Remove all attached input methods from a camera
  17014. */
  17015. clear(): void;
  17016. }
  17017. }
  17018. declare module "babylonjs/Cameras/freeCamera" {
  17019. import { Vector3 } from "babylonjs/Maths/math";
  17020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17021. import { Scene } from "babylonjs/scene";
  17022. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17023. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17024. /**
  17025. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17026. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17027. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17028. */
  17029. export class FreeCamera extends TargetCamera {
  17030. /**
  17031. * Define the collision ellipsoid of the camera.
  17032. * This is helpful to simulate a camera body like the player body around the camera
  17033. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17034. */
  17035. ellipsoid: Vector3;
  17036. /**
  17037. * Define an offset for the position of the ellipsoid around the camera.
  17038. * This can be helpful to determine the center of the body near the gravity center of the body
  17039. * instead of its head.
  17040. */
  17041. ellipsoidOffset: Vector3;
  17042. /**
  17043. * Enable or disable collisions of the camera with the rest of the scene objects.
  17044. */
  17045. checkCollisions: boolean;
  17046. /**
  17047. * Enable or disable gravity on the camera.
  17048. */
  17049. applyGravity: boolean;
  17050. /**
  17051. * Define the input manager associated to the camera.
  17052. */
  17053. inputs: FreeCameraInputsManager;
  17054. /**
  17055. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17056. * Higher values reduce sensitivity.
  17057. */
  17058. /**
  17059. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17060. * Higher values reduce sensitivity.
  17061. */
  17062. angularSensibility: number;
  17063. /**
  17064. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17065. */
  17066. keysUp: number[];
  17067. /**
  17068. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17069. */
  17070. keysDown: number[];
  17071. /**
  17072. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17073. */
  17074. keysLeft: number[];
  17075. /**
  17076. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17077. */
  17078. keysRight: number[];
  17079. /**
  17080. * Event raised when the camera collide with a mesh in the scene.
  17081. */
  17082. onCollide: (collidedMesh: AbstractMesh) => void;
  17083. private _collider;
  17084. private _needMoveForGravity;
  17085. private _oldPosition;
  17086. private _diffPosition;
  17087. private _newPosition;
  17088. /** @hidden */
  17089. _localDirection: Vector3;
  17090. /** @hidden */
  17091. _transformedDirection: Vector3;
  17092. /**
  17093. * Instantiates a Free Camera.
  17094. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17095. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17096. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17097. * @param name Define the name of the camera in the scene
  17098. * @param position Define the start position of the camera in the scene
  17099. * @param scene Define the scene the camera belongs to
  17100. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17101. */
  17102. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17103. /**
  17104. * Attached controls to the current camera.
  17105. * @param element Defines the element the controls should be listened from
  17106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17107. */
  17108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17109. /**
  17110. * Detach the current controls from the camera.
  17111. * The camera will stop reacting to inputs.
  17112. * @param element Defines the element to stop listening the inputs from
  17113. */
  17114. detachControl(element: HTMLElement): void;
  17115. private _collisionMask;
  17116. /**
  17117. * Define a collision mask to limit the list of object the camera can collide with
  17118. */
  17119. collisionMask: number;
  17120. /** @hidden */
  17121. _collideWithWorld(displacement: Vector3): void;
  17122. private _onCollisionPositionChange;
  17123. /** @hidden */
  17124. _checkInputs(): void;
  17125. /** @hidden */
  17126. _decideIfNeedsToMove(): boolean;
  17127. /** @hidden */
  17128. _updatePosition(): void;
  17129. /**
  17130. * Destroy the camera and release the current resources hold by it.
  17131. */
  17132. dispose(): void;
  17133. /**
  17134. * Gets the current object class name.
  17135. * @return the class name
  17136. */
  17137. getClassName(): string;
  17138. }
  17139. }
  17140. declare module "babylonjs/Gamepads/gamepad" {
  17141. import { Observable } from "babylonjs/Misc/observable";
  17142. /**
  17143. * Represents a gamepad control stick position
  17144. */
  17145. export class StickValues {
  17146. /**
  17147. * The x component of the control stick
  17148. */
  17149. x: number;
  17150. /**
  17151. * The y component of the control stick
  17152. */
  17153. y: number;
  17154. /**
  17155. * Initializes the gamepad x and y control stick values
  17156. * @param x The x component of the gamepad control stick value
  17157. * @param y The y component of the gamepad control stick value
  17158. */
  17159. constructor(
  17160. /**
  17161. * The x component of the control stick
  17162. */
  17163. x: number,
  17164. /**
  17165. * The y component of the control stick
  17166. */
  17167. y: number);
  17168. }
  17169. /**
  17170. * An interface which manages callbacks for gamepad button changes
  17171. */
  17172. export interface GamepadButtonChanges {
  17173. /**
  17174. * Called when a gamepad has been changed
  17175. */
  17176. changed: boolean;
  17177. /**
  17178. * Called when a gamepad press event has been triggered
  17179. */
  17180. pressChanged: boolean;
  17181. /**
  17182. * Called when a touch event has been triggered
  17183. */
  17184. touchChanged: boolean;
  17185. /**
  17186. * Called when a value has changed
  17187. */
  17188. valueChanged: boolean;
  17189. }
  17190. /**
  17191. * Represents a gamepad
  17192. */
  17193. export class Gamepad {
  17194. /**
  17195. * The id of the gamepad
  17196. */
  17197. id: string;
  17198. /**
  17199. * The index of the gamepad
  17200. */
  17201. index: number;
  17202. /**
  17203. * The browser gamepad
  17204. */
  17205. browserGamepad: any;
  17206. /**
  17207. * Specifies what type of gamepad this represents
  17208. */
  17209. type: number;
  17210. private _leftStick;
  17211. private _rightStick;
  17212. /** @hidden */
  17213. _isConnected: boolean;
  17214. private _leftStickAxisX;
  17215. private _leftStickAxisY;
  17216. private _rightStickAxisX;
  17217. private _rightStickAxisY;
  17218. /**
  17219. * Triggered when the left control stick has been changed
  17220. */
  17221. private _onleftstickchanged;
  17222. /**
  17223. * Triggered when the right control stick has been changed
  17224. */
  17225. private _onrightstickchanged;
  17226. /**
  17227. * Represents a gamepad controller
  17228. */
  17229. static GAMEPAD: number;
  17230. /**
  17231. * Represents a generic controller
  17232. */
  17233. static GENERIC: number;
  17234. /**
  17235. * Represents an XBox controller
  17236. */
  17237. static XBOX: number;
  17238. /**
  17239. * Represents a pose-enabled controller
  17240. */
  17241. static POSE_ENABLED: number;
  17242. /**
  17243. * Specifies whether the left control stick should be Y-inverted
  17244. */
  17245. protected _invertLeftStickY: boolean;
  17246. /**
  17247. * Specifies if the gamepad has been connected
  17248. */
  17249. readonly isConnected: boolean;
  17250. /**
  17251. * Initializes the gamepad
  17252. * @param id The id of the gamepad
  17253. * @param index The index of the gamepad
  17254. * @param browserGamepad The browser gamepad
  17255. * @param leftStickX The x component of the left joystick
  17256. * @param leftStickY The y component of the left joystick
  17257. * @param rightStickX The x component of the right joystick
  17258. * @param rightStickY The y component of the right joystick
  17259. */
  17260. constructor(
  17261. /**
  17262. * The id of the gamepad
  17263. */
  17264. id: string,
  17265. /**
  17266. * The index of the gamepad
  17267. */
  17268. index: number,
  17269. /**
  17270. * The browser gamepad
  17271. */
  17272. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17273. /**
  17274. * Callback triggered when the left joystick has changed
  17275. * @param callback
  17276. */
  17277. onleftstickchanged(callback: (values: StickValues) => void): void;
  17278. /**
  17279. * Callback triggered when the right joystick has changed
  17280. * @param callback
  17281. */
  17282. onrightstickchanged(callback: (values: StickValues) => void): void;
  17283. /**
  17284. * Gets the left joystick
  17285. */
  17286. /**
  17287. * Sets the left joystick values
  17288. */
  17289. leftStick: StickValues;
  17290. /**
  17291. * Gets the right joystick
  17292. */
  17293. /**
  17294. * Sets the right joystick value
  17295. */
  17296. rightStick: StickValues;
  17297. /**
  17298. * Updates the gamepad joystick positions
  17299. */
  17300. update(): void;
  17301. /**
  17302. * Disposes the gamepad
  17303. */
  17304. dispose(): void;
  17305. }
  17306. /**
  17307. * Represents a generic gamepad
  17308. */
  17309. export class GenericPad extends Gamepad {
  17310. private _buttons;
  17311. private _onbuttondown;
  17312. private _onbuttonup;
  17313. /**
  17314. * Observable triggered when a button has been pressed
  17315. */
  17316. onButtonDownObservable: Observable<number>;
  17317. /**
  17318. * Observable triggered when a button has been released
  17319. */
  17320. onButtonUpObservable: Observable<number>;
  17321. /**
  17322. * Callback triggered when a button has been pressed
  17323. * @param callback Called when a button has been pressed
  17324. */
  17325. onbuttondown(callback: (buttonPressed: number) => void): void;
  17326. /**
  17327. * Callback triggered when a button has been released
  17328. * @param callback Called when a button has been released
  17329. */
  17330. onbuttonup(callback: (buttonReleased: number) => void): void;
  17331. /**
  17332. * Initializes the generic gamepad
  17333. * @param id The id of the generic gamepad
  17334. * @param index The index of the generic gamepad
  17335. * @param browserGamepad The browser gamepad
  17336. */
  17337. constructor(id: string, index: number, browserGamepad: any);
  17338. private _setButtonValue;
  17339. /**
  17340. * Updates the generic gamepad
  17341. */
  17342. update(): void;
  17343. /**
  17344. * Disposes the generic gamepad
  17345. */
  17346. dispose(): void;
  17347. }
  17348. }
  17349. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17350. import { Observable } from "babylonjs/Misc/observable";
  17351. import { Nullable } from "babylonjs/types";
  17352. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17353. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17355. import { Ray } from "babylonjs/Culling/ray";
  17356. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17357. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17358. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17359. /**
  17360. * Defines the types of pose enabled controllers that are supported
  17361. */
  17362. export enum PoseEnabledControllerType {
  17363. /**
  17364. * HTC Vive
  17365. */
  17366. VIVE = 0,
  17367. /**
  17368. * Oculus Rift
  17369. */
  17370. OCULUS = 1,
  17371. /**
  17372. * Windows mixed reality
  17373. */
  17374. WINDOWS = 2,
  17375. /**
  17376. * Samsung gear VR
  17377. */
  17378. GEAR_VR = 3,
  17379. /**
  17380. * Google Daydream
  17381. */
  17382. DAYDREAM = 4,
  17383. /**
  17384. * Generic
  17385. */
  17386. GENERIC = 5
  17387. }
  17388. /**
  17389. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17390. */
  17391. export interface MutableGamepadButton {
  17392. /**
  17393. * Value of the button/trigger
  17394. */
  17395. value: number;
  17396. /**
  17397. * If the button/trigger is currently touched
  17398. */
  17399. touched: boolean;
  17400. /**
  17401. * If the button/trigger is currently pressed
  17402. */
  17403. pressed: boolean;
  17404. }
  17405. /**
  17406. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17407. * @hidden
  17408. */
  17409. export interface ExtendedGamepadButton extends GamepadButton {
  17410. /**
  17411. * If the button/trigger is currently pressed
  17412. */
  17413. readonly pressed: boolean;
  17414. /**
  17415. * If the button/trigger is currently touched
  17416. */
  17417. readonly touched: boolean;
  17418. /**
  17419. * Value of the button/trigger
  17420. */
  17421. readonly value: number;
  17422. }
  17423. /** @hidden */
  17424. export interface _GamePadFactory {
  17425. /**
  17426. * Returns wether or not the current gamepad can be created for this type of controller.
  17427. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17428. * @returns true if it can be created, otherwise false
  17429. */
  17430. canCreate(gamepadInfo: any): boolean;
  17431. /**
  17432. * Creates a new instance of the Gamepad.
  17433. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17434. * @returns the new gamepad instance
  17435. */
  17436. create(gamepadInfo: any): Gamepad;
  17437. }
  17438. /**
  17439. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17440. */
  17441. export class PoseEnabledControllerHelper {
  17442. /** @hidden */
  17443. static _ControllerFactories: _GamePadFactory[];
  17444. /** @hidden */
  17445. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17446. /**
  17447. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17448. * @param vrGamepad the gamepad to initialized
  17449. * @returns a vr controller of the type the gamepad identified as
  17450. */
  17451. static InitiateController(vrGamepad: any): Gamepad;
  17452. }
  17453. /**
  17454. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17455. */
  17456. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17457. private _deviceRoomPosition;
  17458. private _deviceRoomRotationQuaternion;
  17459. /**
  17460. * The device position in babylon space
  17461. */
  17462. devicePosition: Vector3;
  17463. /**
  17464. * The device rotation in babylon space
  17465. */
  17466. deviceRotationQuaternion: Quaternion;
  17467. /**
  17468. * The scale factor of the device in babylon space
  17469. */
  17470. deviceScaleFactor: number;
  17471. /**
  17472. * (Likely devicePosition should be used instead) The device position in its room space
  17473. */
  17474. position: Vector3;
  17475. /**
  17476. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17477. */
  17478. rotationQuaternion: Quaternion;
  17479. /**
  17480. * The type of controller (Eg. Windows mixed reality)
  17481. */
  17482. controllerType: PoseEnabledControllerType;
  17483. protected _calculatedPosition: Vector3;
  17484. private _calculatedRotation;
  17485. /**
  17486. * The raw pose from the device
  17487. */
  17488. rawPose: DevicePose;
  17489. private _trackPosition;
  17490. private _maxRotationDistFromHeadset;
  17491. private _draggedRoomRotation;
  17492. /**
  17493. * @hidden
  17494. */
  17495. _disableTrackPosition(fixedPosition: Vector3): void;
  17496. /**
  17497. * Internal, the mesh attached to the controller
  17498. * @hidden
  17499. */
  17500. _mesh: Nullable<AbstractMesh>;
  17501. private _poseControlledCamera;
  17502. private _leftHandSystemQuaternion;
  17503. /**
  17504. * Internal, matrix used to convert room space to babylon space
  17505. * @hidden
  17506. */
  17507. _deviceToWorld: Matrix;
  17508. /**
  17509. * Node to be used when casting a ray from the controller
  17510. * @hidden
  17511. */
  17512. _pointingPoseNode: Nullable<TransformNode>;
  17513. /**
  17514. * Name of the child mesh that can be used to cast a ray from the controller
  17515. */
  17516. static readonly POINTING_POSE: string;
  17517. /**
  17518. * Creates a new PoseEnabledController from a gamepad
  17519. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17520. */
  17521. constructor(browserGamepad: any);
  17522. private _workingMatrix;
  17523. /**
  17524. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17525. */
  17526. update(): void;
  17527. /**
  17528. * Updates only the pose device and mesh without doing any button event checking
  17529. */
  17530. protected _updatePoseAndMesh(): void;
  17531. /**
  17532. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17533. * @param poseData raw pose fromthe device
  17534. */
  17535. updateFromDevice(poseData: DevicePose): void;
  17536. /**
  17537. * @hidden
  17538. */
  17539. _meshAttachedObservable: Observable<AbstractMesh>;
  17540. /**
  17541. * Attaches a mesh to the controller
  17542. * @param mesh the mesh to be attached
  17543. */
  17544. attachToMesh(mesh: AbstractMesh): void;
  17545. /**
  17546. * Attaches the controllers mesh to a camera
  17547. * @param camera the camera the mesh should be attached to
  17548. */
  17549. attachToPoseControlledCamera(camera: TargetCamera): void;
  17550. /**
  17551. * Disposes of the controller
  17552. */
  17553. dispose(): void;
  17554. /**
  17555. * The mesh that is attached to the controller
  17556. */
  17557. readonly mesh: Nullable<AbstractMesh>;
  17558. /**
  17559. * Gets the ray of the controller in the direction the controller is pointing
  17560. * @param length the length the resulting ray should be
  17561. * @returns a ray in the direction the controller is pointing
  17562. */
  17563. getForwardRay(length?: number): Ray;
  17564. }
  17565. }
  17566. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17567. import { Observable } from "babylonjs/Misc/observable";
  17568. import { Scene } from "babylonjs/scene";
  17569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17570. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17571. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17572. /**
  17573. * Defines the WebVRController object that represents controllers tracked in 3D space
  17574. */
  17575. export abstract class WebVRController extends PoseEnabledController {
  17576. /**
  17577. * Internal, the default controller model for the controller
  17578. */
  17579. protected _defaultModel: AbstractMesh;
  17580. /**
  17581. * Fired when the trigger state has changed
  17582. */
  17583. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17584. /**
  17585. * Fired when the main button state has changed
  17586. */
  17587. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17588. /**
  17589. * Fired when the secondary button state has changed
  17590. */
  17591. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17592. /**
  17593. * Fired when the pad state has changed
  17594. */
  17595. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17596. /**
  17597. * Fired when controllers stick values have changed
  17598. */
  17599. onPadValuesChangedObservable: Observable<StickValues>;
  17600. /**
  17601. * Array of button availible on the controller
  17602. */
  17603. protected _buttons: Array<MutableGamepadButton>;
  17604. private _onButtonStateChange;
  17605. /**
  17606. * Fired when a controller button's state has changed
  17607. * @param callback the callback containing the button that was modified
  17608. */
  17609. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17610. /**
  17611. * X and Y axis corresponding to the controllers joystick
  17612. */
  17613. pad: StickValues;
  17614. /**
  17615. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17616. */
  17617. hand: string;
  17618. /**
  17619. * The default controller model for the controller
  17620. */
  17621. readonly defaultModel: AbstractMesh;
  17622. /**
  17623. * Creates a new WebVRController from a gamepad
  17624. * @param vrGamepad the gamepad that the WebVRController should be created from
  17625. */
  17626. constructor(vrGamepad: any);
  17627. /**
  17628. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17629. */
  17630. update(): void;
  17631. /**
  17632. * Function to be called when a button is modified
  17633. */
  17634. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17635. /**
  17636. * Loads a mesh and attaches it to the controller
  17637. * @param scene the scene the mesh should be added to
  17638. * @param meshLoaded callback for when the mesh has been loaded
  17639. */
  17640. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17641. private _setButtonValue;
  17642. private _changes;
  17643. private _checkChanges;
  17644. /**
  17645. * Disposes of th webVRCOntroller
  17646. */
  17647. dispose(): void;
  17648. }
  17649. }
  17650. declare module "babylonjs/Lights/hemisphericLight" {
  17651. import { Nullable } from "babylonjs/types";
  17652. import { Scene } from "babylonjs/scene";
  17653. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17654. import { Effect } from "babylonjs/Materials/effect";
  17655. import { Light } from "babylonjs/Lights/light";
  17656. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17657. /**
  17658. * The HemisphericLight simulates the ambient environment light,
  17659. * so the passed direction is the light reflection direction, not the incoming direction.
  17660. */
  17661. export class HemisphericLight extends Light {
  17662. /**
  17663. * The groundColor is the light in the opposite direction to the one specified during creation.
  17664. * 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.
  17665. */
  17666. groundColor: Color3;
  17667. /**
  17668. * The light reflection direction, not the incoming direction.
  17669. */
  17670. direction: Vector3;
  17671. /**
  17672. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17673. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17674. * The HemisphericLight can't cast shadows.
  17675. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17676. * @param name The friendly name of the light
  17677. * @param direction The direction of the light reflection
  17678. * @param scene The scene the light belongs to
  17679. */
  17680. constructor(name: string, direction: Vector3, scene: Scene);
  17681. protected _buildUniformLayout(): void;
  17682. /**
  17683. * Returns the string "HemisphericLight".
  17684. * @return The class name
  17685. */
  17686. getClassName(): string;
  17687. /**
  17688. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17689. * Returns the updated direction.
  17690. * @param target The target the direction should point to
  17691. * @return The computed direction
  17692. */
  17693. setDirectionToTarget(target: Vector3): Vector3;
  17694. /**
  17695. * Returns the shadow generator associated to the light.
  17696. * @returns Always null for hemispheric lights because it does not support shadows.
  17697. */
  17698. getShadowGenerator(): Nullable<IShadowGenerator>;
  17699. /**
  17700. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17701. * @param effect The effect to update
  17702. * @param lightIndex The index of the light in the effect to update
  17703. * @returns The hemispheric light
  17704. */
  17705. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17706. /**
  17707. * Computes the world matrix of the node
  17708. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17709. * @param useWasUpdatedFlag defines a reserved property
  17710. * @returns the world matrix
  17711. */
  17712. computeWorldMatrix(): Matrix;
  17713. /**
  17714. * Returns the integer 3.
  17715. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17716. */
  17717. getTypeID(): number;
  17718. /**
  17719. * Prepares the list of defines specific to the light type.
  17720. * @param defines the list of defines
  17721. * @param lightIndex defines the index of the light for the effect
  17722. */
  17723. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17724. }
  17725. }
  17726. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17727. /** @hidden */
  17728. export var vrMultiviewToSingleviewPixelShader: {
  17729. name: string;
  17730. shader: string;
  17731. };
  17732. }
  17733. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17734. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17735. import { Scene } from "babylonjs/scene";
  17736. /**
  17737. * Renders to multiple views with a single draw call
  17738. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17739. */
  17740. export class MultiviewRenderTarget extends RenderTargetTexture {
  17741. /**
  17742. * Creates a multiview render target
  17743. * @param scene scene used with the render target
  17744. * @param size the size of the render target (used for each view)
  17745. */
  17746. constructor(scene: Scene, size?: number | {
  17747. width: number;
  17748. height: number;
  17749. } | {
  17750. ratio: number;
  17751. });
  17752. /**
  17753. * @hidden
  17754. * @param faceIndex the face index, if its a cube texture
  17755. */
  17756. _bindFrameBuffer(faceIndex?: number): void;
  17757. /**
  17758. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17759. * @returns the view count
  17760. */
  17761. getViewCount(): number;
  17762. }
  17763. }
  17764. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17765. import { Camera } from "babylonjs/Cameras/camera";
  17766. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17767. import { Nullable } from "babylonjs/types";
  17768. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17769. import { Matrix } from "babylonjs/Maths/math";
  17770. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17771. module "babylonjs/Engines/engine" {
  17772. interface Engine {
  17773. /**
  17774. * Creates a new multiview render target
  17775. * @param width defines the width of the texture
  17776. * @param height defines the height of the texture
  17777. * @returns the created multiview texture
  17778. */
  17779. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17780. /**
  17781. * Binds a multiview framebuffer to be drawn to
  17782. * @param multiviewTexture texture to bind
  17783. */
  17784. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17785. }
  17786. }
  17787. module "babylonjs/Cameras/camera" {
  17788. interface Camera {
  17789. /**
  17790. * @hidden
  17791. * 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)
  17792. */
  17793. _useMultiviewToSingleView: boolean;
  17794. /**
  17795. * @hidden
  17796. * 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)
  17797. */
  17798. _multiviewTexture: Nullable<RenderTargetTexture>;
  17799. /**
  17800. * @hidden
  17801. * ensures the multiview texture of the camera exists and has the specified width/height
  17802. * @param width height to set on the multiview texture
  17803. * @param height width to set on the multiview texture
  17804. */
  17805. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17806. }
  17807. }
  17808. module "babylonjs/scene" {
  17809. interface Scene {
  17810. /** @hidden */
  17811. _transformMatrixR: Matrix;
  17812. /** @hidden */
  17813. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17814. /** @hidden */
  17815. _createMultiviewUbo(): void;
  17816. /** @hidden */
  17817. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17818. /** @hidden */
  17819. _renderMultiviewToSingleView(camera: Camera): void;
  17820. }
  17821. }
  17822. }
  17823. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17824. import { Camera } from "babylonjs/Cameras/camera";
  17825. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17826. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17827. import "babylonjs/Engines/Extensions/engine.multiview";
  17828. /**
  17829. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17830. * This will not be used for webXR as it supports displaying texture arrays directly
  17831. */
  17832. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17833. /**
  17834. * Initializes a VRMultiviewToSingleview
  17835. * @param name name of the post process
  17836. * @param camera camera to be applied to
  17837. * @param scaleFactor scaling factor to the size of the output texture
  17838. */
  17839. constructor(name: string, camera: Camera, scaleFactor: number);
  17840. }
  17841. }
  17842. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17843. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17844. import { Nullable } from "babylonjs/types";
  17845. import { Size } from "babylonjs/Maths/math";
  17846. import { Observable } from "babylonjs/Misc/observable";
  17847. module "babylonjs/Engines/engine" {
  17848. interface Engine {
  17849. /** @hidden */
  17850. _vrDisplay: any;
  17851. /** @hidden */
  17852. _vrSupported: boolean;
  17853. /** @hidden */
  17854. _oldSize: Size;
  17855. /** @hidden */
  17856. _oldHardwareScaleFactor: number;
  17857. /** @hidden */
  17858. _vrExclusivePointerMode: boolean;
  17859. /** @hidden */
  17860. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17861. /** @hidden */
  17862. _onVRDisplayPointerRestricted: () => void;
  17863. /** @hidden */
  17864. _onVRDisplayPointerUnrestricted: () => void;
  17865. /** @hidden */
  17866. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17867. /** @hidden */
  17868. _onVrDisplayDisconnect: Nullable<() => void>;
  17869. /** @hidden */
  17870. _onVrDisplayPresentChange: Nullable<() => void>;
  17871. /**
  17872. * Observable signaled when VR display mode changes
  17873. */
  17874. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17875. /**
  17876. * Observable signaled when VR request present is complete
  17877. */
  17878. onVRRequestPresentComplete: Observable<boolean>;
  17879. /**
  17880. * Observable signaled when VR request present starts
  17881. */
  17882. onVRRequestPresentStart: Observable<Engine>;
  17883. /**
  17884. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17885. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17886. */
  17887. isInVRExclusivePointerMode: boolean;
  17888. /**
  17889. * Gets a boolean indicating if a webVR device was detected
  17890. * @returns true if a webVR device was detected
  17891. */
  17892. isVRDevicePresent(): boolean;
  17893. /**
  17894. * Gets the current webVR device
  17895. * @returns the current webVR device (or null)
  17896. */
  17897. getVRDevice(): any;
  17898. /**
  17899. * Initializes a webVR display and starts listening to display change events
  17900. * The onVRDisplayChangedObservable will be notified upon these changes
  17901. * @returns A promise containing a VRDisplay and if vr is supported
  17902. */
  17903. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17904. /** @hidden */
  17905. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17906. /**
  17907. * Call this function to switch to webVR mode
  17908. * Will do nothing if webVR is not supported or if there is no webVR device
  17909. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17910. */
  17911. enableVR(): void;
  17912. /** @hidden */
  17913. _onVRFullScreenTriggered(): void;
  17914. }
  17915. }
  17916. }
  17917. declare module "babylonjs/Cameras/VR/webVRCamera" {
  17918. import { Nullable } from "babylonjs/types";
  17919. import { Observable } from "babylonjs/Misc/observable";
  17920. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17921. import { Scene } from "babylonjs/scene";
  17922. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17923. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  17924. import { Node } from "babylonjs/node";
  17925. import { Ray } from "babylonjs/Culling/ray";
  17926. import "babylonjs/Cameras/RigModes/webVRRigMode";
  17927. import "babylonjs/Engines/Extensions/engine.webVR";
  17928. /**
  17929. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17930. * IMPORTANT!! The data is right-hand data.
  17931. * @export
  17932. * @interface DevicePose
  17933. */
  17934. export interface DevicePose {
  17935. /**
  17936. * The position of the device, values in array are [x,y,z].
  17937. */
  17938. readonly position: Nullable<Float32Array>;
  17939. /**
  17940. * The linearVelocity of the device, values in array are [x,y,z].
  17941. */
  17942. readonly linearVelocity: Nullable<Float32Array>;
  17943. /**
  17944. * The linearAcceleration of the device, values in array are [x,y,z].
  17945. */
  17946. readonly linearAcceleration: Nullable<Float32Array>;
  17947. /**
  17948. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17949. */
  17950. readonly orientation: Nullable<Float32Array>;
  17951. /**
  17952. * The angularVelocity of the device, values in array are [x,y,z].
  17953. */
  17954. readonly angularVelocity: Nullable<Float32Array>;
  17955. /**
  17956. * The angularAcceleration of the device, values in array are [x,y,z].
  17957. */
  17958. readonly angularAcceleration: Nullable<Float32Array>;
  17959. }
  17960. /**
  17961. * Interface representing a pose controlled object in Babylon.
  17962. * A pose controlled object has both regular pose values as well as pose values
  17963. * from an external device such as a VR head mounted display
  17964. */
  17965. export interface PoseControlled {
  17966. /**
  17967. * The position of the object in babylon space.
  17968. */
  17969. position: Vector3;
  17970. /**
  17971. * The rotation quaternion of the object in babylon space.
  17972. */
  17973. rotationQuaternion: Quaternion;
  17974. /**
  17975. * The position of the device in babylon space.
  17976. */
  17977. devicePosition?: Vector3;
  17978. /**
  17979. * The rotation quaternion of the device in babylon space.
  17980. */
  17981. deviceRotationQuaternion: Quaternion;
  17982. /**
  17983. * The raw pose coming from the device.
  17984. */
  17985. rawPose: Nullable<DevicePose>;
  17986. /**
  17987. * The scale of the device to be used when translating from device space to babylon space.
  17988. */
  17989. deviceScaleFactor: number;
  17990. /**
  17991. * Updates the poseControlled values based on the input device pose.
  17992. * @param poseData the pose data to update the object with
  17993. */
  17994. updateFromDevice(poseData: DevicePose): void;
  17995. }
  17996. /**
  17997. * Set of options to customize the webVRCamera
  17998. */
  17999. export interface WebVROptions {
  18000. /**
  18001. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18002. */
  18003. trackPosition?: boolean;
  18004. /**
  18005. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18006. */
  18007. positionScale?: number;
  18008. /**
  18009. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18010. */
  18011. displayName?: string;
  18012. /**
  18013. * Should the native controller meshes be initialized. (default: true)
  18014. */
  18015. controllerMeshes?: boolean;
  18016. /**
  18017. * Creating a default HemiLight only on controllers. (default: true)
  18018. */
  18019. defaultLightingOnControllers?: boolean;
  18020. /**
  18021. * If you don't want to use the default VR button of the helper. (default: false)
  18022. */
  18023. useCustomVRButton?: boolean;
  18024. /**
  18025. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18026. */
  18027. customVRButton?: HTMLButtonElement;
  18028. /**
  18029. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18030. */
  18031. rayLength?: number;
  18032. /**
  18033. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18034. */
  18035. defaultHeight?: number;
  18036. /**
  18037. * If multiview should be used if availible (default: false)
  18038. */
  18039. useMultiview?: boolean;
  18040. }
  18041. /**
  18042. * This represents a WebVR camera.
  18043. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18044. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18045. */
  18046. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18047. private webVROptions;
  18048. /**
  18049. * @hidden
  18050. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18051. */
  18052. _vrDevice: any;
  18053. /**
  18054. * The rawPose of the vrDevice.
  18055. */
  18056. rawPose: Nullable<DevicePose>;
  18057. private _onVREnabled;
  18058. private _specsVersion;
  18059. private _attached;
  18060. private _frameData;
  18061. protected _descendants: Array<Node>;
  18062. private _deviceRoomPosition;
  18063. /** @hidden */
  18064. _deviceRoomRotationQuaternion: Quaternion;
  18065. private _standingMatrix;
  18066. /**
  18067. * Represents device position in babylon space.
  18068. */
  18069. devicePosition: Vector3;
  18070. /**
  18071. * Represents device rotation in babylon space.
  18072. */
  18073. deviceRotationQuaternion: Quaternion;
  18074. /**
  18075. * The scale of the device to be used when translating from device space to babylon space.
  18076. */
  18077. deviceScaleFactor: number;
  18078. private _deviceToWorld;
  18079. private _worldToDevice;
  18080. /**
  18081. * References to the webVR controllers for the vrDevice.
  18082. */
  18083. controllers: Array<WebVRController>;
  18084. /**
  18085. * Emits an event when a controller is attached.
  18086. */
  18087. onControllersAttachedObservable: Observable<WebVRController[]>;
  18088. /**
  18089. * Emits an event when a controller's mesh has been loaded;
  18090. */
  18091. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18092. /**
  18093. * Emits an event when the HMD's pose has been updated.
  18094. */
  18095. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18096. private _poseSet;
  18097. /**
  18098. * If the rig cameras be used as parent instead of this camera.
  18099. */
  18100. rigParenting: boolean;
  18101. private _lightOnControllers;
  18102. private _defaultHeight?;
  18103. /**
  18104. * Instantiates a WebVRFreeCamera.
  18105. * @param name The name of the WebVRFreeCamera
  18106. * @param position The starting anchor position for the camera
  18107. * @param scene The scene the camera belongs to
  18108. * @param webVROptions a set of customizable options for the webVRCamera
  18109. */
  18110. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18111. /**
  18112. * Gets the device distance from the ground in meters.
  18113. * @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.
  18114. */
  18115. deviceDistanceToRoomGround(): number;
  18116. /**
  18117. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18118. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18119. */
  18120. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18121. /**
  18122. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18123. * @returns A promise with a boolean set to if the standing matrix is supported.
  18124. */
  18125. useStandingMatrixAsync(): Promise<boolean>;
  18126. /**
  18127. * Disposes the camera
  18128. */
  18129. dispose(): void;
  18130. /**
  18131. * Gets a vrController by name.
  18132. * @param name The name of the controller to retreive
  18133. * @returns the controller matching the name specified or null if not found
  18134. */
  18135. getControllerByName(name: string): Nullable<WebVRController>;
  18136. private _leftController;
  18137. /**
  18138. * The controller corresponding to the users left hand.
  18139. */
  18140. readonly leftController: Nullable<WebVRController>;
  18141. private _rightController;
  18142. /**
  18143. * The controller corresponding to the users right hand.
  18144. */
  18145. readonly rightController: Nullable<WebVRController>;
  18146. /**
  18147. * Casts a ray forward from the vrCamera's gaze.
  18148. * @param length Length of the ray (default: 100)
  18149. * @returns the ray corresponding to the gaze
  18150. */
  18151. getForwardRay(length?: number): Ray;
  18152. /**
  18153. * @hidden
  18154. * Updates the camera based on device's frame data
  18155. */
  18156. _checkInputs(): void;
  18157. /**
  18158. * Updates the poseControlled values based on the input device pose.
  18159. * @param poseData Pose coming from the device
  18160. */
  18161. updateFromDevice(poseData: DevicePose): void;
  18162. private _htmlElementAttached;
  18163. private _detachIfAttached;
  18164. /**
  18165. * WebVR's attach control will start broadcasting frames to the device.
  18166. * Note that in certain browsers (chrome for example) this function must be called
  18167. * within a user-interaction callback. Example:
  18168. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18169. *
  18170. * @param element html element to attach the vrDevice to
  18171. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18172. */
  18173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18174. /**
  18175. * Detaches the camera from the html element and disables VR
  18176. *
  18177. * @param element html element to detach from
  18178. */
  18179. detachControl(element: HTMLElement): void;
  18180. /**
  18181. * @returns the name of this class
  18182. */
  18183. getClassName(): string;
  18184. /**
  18185. * Calls resetPose on the vrDisplay
  18186. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18187. */
  18188. resetToCurrentRotation(): void;
  18189. /**
  18190. * @hidden
  18191. * Updates the rig cameras (left and right eye)
  18192. */
  18193. _updateRigCameras(): void;
  18194. private _workingVector;
  18195. private _oneVector;
  18196. private _workingMatrix;
  18197. private updateCacheCalled;
  18198. private _correctPositionIfNotTrackPosition;
  18199. /**
  18200. * @hidden
  18201. * Updates the cached values of the camera
  18202. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18203. */
  18204. _updateCache(ignoreParentClass?: boolean): void;
  18205. /**
  18206. * @hidden
  18207. * Get current device position in babylon world
  18208. */
  18209. _computeDevicePosition(): void;
  18210. /**
  18211. * Updates the current device position and rotation in the babylon world
  18212. */
  18213. update(): void;
  18214. /**
  18215. * @hidden
  18216. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18217. * @returns an identity matrix
  18218. */
  18219. _getViewMatrix(): Matrix;
  18220. private _tmpMatrix;
  18221. /**
  18222. * This function is called by the two RIG cameras.
  18223. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18224. * @hidden
  18225. */
  18226. _getWebVRViewMatrix(): Matrix;
  18227. /** @hidden */
  18228. _getWebVRProjectionMatrix(): Matrix;
  18229. private _onGamepadConnectedObserver;
  18230. private _onGamepadDisconnectedObserver;
  18231. private _updateCacheWhenTrackingDisabledObserver;
  18232. /**
  18233. * Initializes the controllers and their meshes
  18234. */
  18235. initControllers(): void;
  18236. }
  18237. }
  18238. declare module "babylonjs/PostProcesses/postProcess" {
  18239. import { Nullable } from "babylonjs/types";
  18240. import { SmartArray } from "babylonjs/Misc/smartArray";
  18241. import { Observable } from "babylonjs/Misc/observable";
  18242. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18243. import { Camera } from "babylonjs/Cameras/camera";
  18244. import { Effect } from "babylonjs/Materials/effect";
  18245. import "babylonjs/Shaders/postprocess.vertex";
  18246. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18247. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18248. import { Engine } from "babylonjs/Engines/engine";
  18249. /**
  18250. * Size options for a post process
  18251. */
  18252. export type PostProcessOptions = {
  18253. width: number;
  18254. height: number;
  18255. };
  18256. /**
  18257. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18258. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18259. */
  18260. export class PostProcess {
  18261. /** Name of the PostProcess. */
  18262. name: string;
  18263. /**
  18264. * Gets or sets the unique id of the post process
  18265. */
  18266. uniqueId: number;
  18267. /**
  18268. * Width of the texture to apply the post process on
  18269. */
  18270. width: number;
  18271. /**
  18272. * Height of the texture to apply the post process on
  18273. */
  18274. height: number;
  18275. /**
  18276. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18277. * @hidden
  18278. */
  18279. _outputTexture: Nullable<InternalTexture>;
  18280. /**
  18281. * Sampling mode used by the shader
  18282. * See https://doc.babylonjs.com/classes/3.1/texture
  18283. */
  18284. renderTargetSamplingMode: number;
  18285. /**
  18286. * Clear color to use when screen clearing
  18287. */
  18288. clearColor: Color4;
  18289. /**
  18290. * If the buffer needs to be cleared before applying the post process. (default: true)
  18291. * Should be set to false if shader will overwrite all previous pixels.
  18292. */
  18293. autoClear: boolean;
  18294. /**
  18295. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18296. */
  18297. alphaMode: number;
  18298. /**
  18299. * Sets the setAlphaBlendConstants of the babylon engine
  18300. */
  18301. alphaConstants: Color4;
  18302. /**
  18303. * Animations to be used for the post processing
  18304. */
  18305. animations: import("babylonjs/Animations/animation").Animation[];
  18306. /**
  18307. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18308. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18309. */
  18310. enablePixelPerfectMode: boolean;
  18311. /**
  18312. * Force the postprocess to be applied without taking in account viewport
  18313. */
  18314. forceFullscreenViewport: boolean;
  18315. /**
  18316. * List of inspectable custom properties (used by the Inspector)
  18317. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18318. */
  18319. inspectableCustomProperties: IInspectable[];
  18320. /**
  18321. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18322. *
  18323. * | Value | Type | Description |
  18324. * | ----- | ----------------------------------- | ----------- |
  18325. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18326. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18327. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18328. *
  18329. */
  18330. scaleMode: number;
  18331. /**
  18332. * Force textures to be a power of two (default: false)
  18333. */
  18334. alwaysForcePOT: boolean;
  18335. private _samples;
  18336. /**
  18337. * Number of sample textures (default: 1)
  18338. */
  18339. samples: number;
  18340. /**
  18341. * Modify the scale of the post process to be the same as the viewport (default: false)
  18342. */
  18343. adaptScaleToCurrentViewport: boolean;
  18344. private _camera;
  18345. private _scene;
  18346. private _engine;
  18347. private _options;
  18348. private _reusable;
  18349. private _textureType;
  18350. /**
  18351. * Smart array of input and output textures for the post process.
  18352. * @hidden
  18353. */
  18354. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18355. /**
  18356. * The index in _textures that corresponds to the output texture.
  18357. * @hidden
  18358. */
  18359. _currentRenderTextureInd: number;
  18360. private _effect;
  18361. private _samplers;
  18362. private _fragmentUrl;
  18363. private _vertexUrl;
  18364. private _parameters;
  18365. private _scaleRatio;
  18366. protected _indexParameters: any;
  18367. private _shareOutputWithPostProcess;
  18368. private _texelSize;
  18369. private _forcedOutputTexture;
  18370. /**
  18371. * Returns the fragment url or shader name used in the post process.
  18372. * @returns the fragment url or name in the shader store.
  18373. */
  18374. getEffectName(): string;
  18375. /**
  18376. * An event triggered when the postprocess is activated.
  18377. */
  18378. onActivateObservable: Observable<Camera>;
  18379. private _onActivateObserver;
  18380. /**
  18381. * A function that is added to the onActivateObservable
  18382. */
  18383. onActivate: Nullable<(camera: Camera) => void>;
  18384. /**
  18385. * An event triggered when the postprocess changes its size.
  18386. */
  18387. onSizeChangedObservable: Observable<PostProcess>;
  18388. private _onSizeChangedObserver;
  18389. /**
  18390. * A function that is added to the onSizeChangedObservable
  18391. */
  18392. onSizeChanged: (postProcess: PostProcess) => void;
  18393. /**
  18394. * An event triggered when the postprocess applies its effect.
  18395. */
  18396. onApplyObservable: Observable<Effect>;
  18397. private _onApplyObserver;
  18398. /**
  18399. * A function that is added to the onApplyObservable
  18400. */
  18401. onApply: (effect: Effect) => void;
  18402. /**
  18403. * An event triggered before rendering the postprocess
  18404. */
  18405. onBeforeRenderObservable: Observable<Effect>;
  18406. private _onBeforeRenderObserver;
  18407. /**
  18408. * A function that is added to the onBeforeRenderObservable
  18409. */
  18410. onBeforeRender: (effect: Effect) => void;
  18411. /**
  18412. * An event triggered after rendering the postprocess
  18413. */
  18414. onAfterRenderObservable: Observable<Effect>;
  18415. private _onAfterRenderObserver;
  18416. /**
  18417. * A function that is added to the onAfterRenderObservable
  18418. */
  18419. onAfterRender: (efect: Effect) => void;
  18420. /**
  18421. * 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
  18422. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18423. */
  18424. inputTexture: InternalTexture;
  18425. /**
  18426. * Gets the camera which post process is applied to.
  18427. * @returns The camera the post process is applied to.
  18428. */
  18429. getCamera(): Camera;
  18430. /**
  18431. * Gets the texel size of the postprocess.
  18432. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18433. */
  18434. readonly texelSize: Vector2;
  18435. /**
  18436. * Creates a new instance PostProcess
  18437. * @param name The name of the PostProcess.
  18438. * @param fragmentUrl The url of the fragment shader to be used.
  18439. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18440. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18441. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18442. * @param camera The camera to apply the render pass to.
  18443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18444. * @param engine The engine which the post process will be applied. (default: current engine)
  18445. * @param reusable If the post process can be reused on the same frame. (default: false)
  18446. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18447. * @param textureType Type of textures used when performing the post process. (default: 0)
  18448. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18449. * @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
  18450. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18451. */
  18452. constructor(
  18453. /** Name of the PostProcess. */
  18454. 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);
  18455. /**
  18456. * Gets a string idenfifying the name of the class
  18457. * @returns "PostProcess" string
  18458. */
  18459. getClassName(): string;
  18460. /**
  18461. * Gets the engine which this post process belongs to.
  18462. * @returns The engine the post process was enabled with.
  18463. */
  18464. getEngine(): Engine;
  18465. /**
  18466. * The effect that is created when initializing the post process.
  18467. * @returns The created effect corresponding the the postprocess.
  18468. */
  18469. getEffect(): Effect;
  18470. /**
  18471. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18472. * @param postProcess The post process to share the output with.
  18473. * @returns This post process.
  18474. */
  18475. shareOutputWith(postProcess: PostProcess): PostProcess;
  18476. /**
  18477. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18478. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18479. */
  18480. useOwnOutput(): void;
  18481. /**
  18482. * Updates the effect with the current post process compile time values and recompiles the shader.
  18483. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18484. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18485. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18486. * @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
  18487. * @param onCompiled Called when the shader has been compiled.
  18488. * @param onError Called if there is an error when compiling a shader.
  18489. */
  18490. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18491. /**
  18492. * The post process is reusable if it can be used multiple times within one frame.
  18493. * @returns If the post process is reusable
  18494. */
  18495. isReusable(): boolean;
  18496. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18497. markTextureDirty(): void;
  18498. /**
  18499. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18500. * 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.
  18501. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18502. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18503. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18504. * @returns The target texture that was bound to be written to.
  18505. */
  18506. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18507. /**
  18508. * If the post process is supported.
  18509. */
  18510. readonly isSupported: boolean;
  18511. /**
  18512. * The aspect ratio of the output texture.
  18513. */
  18514. readonly aspectRatio: number;
  18515. /**
  18516. * Get a value indicating if the post-process is ready to be used
  18517. * @returns true if the post-process is ready (shader is compiled)
  18518. */
  18519. isReady(): boolean;
  18520. /**
  18521. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18522. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18523. */
  18524. apply(): Nullable<Effect>;
  18525. private _disposeTextures;
  18526. /**
  18527. * Disposes the post process.
  18528. * @param camera The camera to dispose the post process on.
  18529. */
  18530. dispose(camera?: Camera): void;
  18531. }
  18532. }
  18533. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18534. /** @hidden */
  18535. export var kernelBlurVaryingDeclaration: {
  18536. name: string;
  18537. shader: string;
  18538. };
  18539. }
  18540. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18541. /** @hidden */
  18542. export var kernelBlurFragment: {
  18543. name: string;
  18544. shader: string;
  18545. };
  18546. }
  18547. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18548. /** @hidden */
  18549. export var kernelBlurFragment2: {
  18550. name: string;
  18551. shader: string;
  18552. };
  18553. }
  18554. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18555. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18556. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18557. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18558. /** @hidden */
  18559. export var kernelBlurPixelShader: {
  18560. name: string;
  18561. shader: string;
  18562. };
  18563. }
  18564. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18565. /** @hidden */
  18566. export var kernelBlurVertex: {
  18567. name: string;
  18568. shader: string;
  18569. };
  18570. }
  18571. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18572. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18573. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18574. /** @hidden */
  18575. export var kernelBlurVertexShader: {
  18576. name: string;
  18577. shader: string;
  18578. };
  18579. }
  18580. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18581. import { Vector2 } from "babylonjs/Maths/math";
  18582. import { Nullable } from "babylonjs/types";
  18583. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18584. import { Camera } from "babylonjs/Cameras/camera";
  18585. import { Effect } from "babylonjs/Materials/effect";
  18586. import { Engine } from "babylonjs/Engines/engine";
  18587. import "babylonjs/Shaders/kernelBlur.fragment";
  18588. import "babylonjs/Shaders/kernelBlur.vertex";
  18589. /**
  18590. * The Blur Post Process which blurs an image based on a kernel and direction.
  18591. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18592. */
  18593. export class BlurPostProcess extends PostProcess {
  18594. /** The direction in which to blur the image. */
  18595. direction: Vector2;
  18596. private blockCompilation;
  18597. protected _kernel: number;
  18598. protected _idealKernel: number;
  18599. protected _packedFloat: boolean;
  18600. private _staticDefines;
  18601. /**
  18602. * Sets the length in pixels of the blur sample region
  18603. */
  18604. /**
  18605. * Gets the length in pixels of the blur sample region
  18606. */
  18607. kernel: number;
  18608. /**
  18609. * Sets wether or not the blur needs to unpack/repack floats
  18610. */
  18611. /**
  18612. * Gets wether or not the blur is unpacking/repacking floats
  18613. */
  18614. packedFloat: boolean;
  18615. /**
  18616. * Creates a new instance BlurPostProcess
  18617. * @param name The name of the effect.
  18618. * @param direction The direction in which to blur the image.
  18619. * @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.
  18620. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18621. * @param camera The camera to apply the render pass to.
  18622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18623. * @param engine The engine which the post process will be applied. (default: current engine)
  18624. * @param reusable If the post process can be reused on the same frame. (default: false)
  18625. * @param textureType Type of textures used when performing the post process. (default: 0)
  18626. * @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)
  18627. */
  18628. constructor(name: string,
  18629. /** The direction in which to blur the image. */
  18630. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18631. /**
  18632. * Updates the effect with the current post process compile time values and recompiles the shader.
  18633. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18634. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18635. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18636. * @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
  18637. * @param onCompiled Called when the shader has been compiled.
  18638. * @param onError Called if there is an error when compiling a shader.
  18639. */
  18640. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18641. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18642. /**
  18643. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18644. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18645. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18646. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18647. * The gaps between physical kernels are compensated for in the weighting of the samples
  18648. * @param idealKernel Ideal blur kernel.
  18649. * @return Nearest best kernel.
  18650. */
  18651. protected _nearestBestKernel(idealKernel: number): number;
  18652. /**
  18653. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18654. * @param x The point on the Gaussian distribution to sample.
  18655. * @return the value of the Gaussian function at x.
  18656. */
  18657. protected _gaussianWeight(x: number): number;
  18658. /**
  18659. * Generates a string that can be used as a floating point number in GLSL.
  18660. * @param x Value to print.
  18661. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18662. * @return GLSL float string.
  18663. */
  18664. protected _glslFloat(x: number, decimalFigures?: number): string;
  18665. }
  18666. }
  18667. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18668. import { Scene } from "babylonjs/scene";
  18669. import { Plane } from "babylonjs/Maths/math";
  18670. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18671. /**
  18672. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18673. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18674. * You can then easily use it as a reflectionTexture on a flat surface.
  18675. * In case the surface is not a plane, please consider relying on reflection probes.
  18676. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18677. */
  18678. export class MirrorTexture extends RenderTargetTexture {
  18679. private scene;
  18680. /**
  18681. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18682. * 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.
  18683. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18684. */
  18685. mirrorPlane: Plane;
  18686. /**
  18687. * Define the blur ratio used to blur the reflection if needed.
  18688. */
  18689. blurRatio: number;
  18690. /**
  18691. * Define the adaptive blur kernel used to blur the reflection if needed.
  18692. * This will autocompute the closest best match for the `blurKernel`
  18693. */
  18694. adaptiveBlurKernel: number;
  18695. /**
  18696. * Define the blur kernel used to blur the reflection if needed.
  18697. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18698. */
  18699. blurKernel: number;
  18700. /**
  18701. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18702. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18703. */
  18704. blurKernelX: number;
  18705. /**
  18706. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18707. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18708. */
  18709. blurKernelY: number;
  18710. private _autoComputeBlurKernel;
  18711. protected _onRatioRescale(): void;
  18712. private _updateGammaSpace;
  18713. private _imageProcessingConfigChangeObserver;
  18714. private _transformMatrix;
  18715. private _mirrorMatrix;
  18716. private _savedViewMatrix;
  18717. private _blurX;
  18718. private _blurY;
  18719. private _adaptiveBlurKernel;
  18720. private _blurKernelX;
  18721. private _blurKernelY;
  18722. private _blurRatio;
  18723. /**
  18724. * Instantiates a Mirror Texture.
  18725. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18726. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18727. * You can then easily use it as a reflectionTexture on a flat surface.
  18728. * In case the surface is not a plane, please consider relying on reflection probes.
  18729. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18730. * @param name
  18731. * @param size
  18732. * @param scene
  18733. * @param generateMipMaps
  18734. * @param type
  18735. * @param samplingMode
  18736. * @param generateDepthBuffer
  18737. */
  18738. constructor(name: string, size: number | {
  18739. width: number;
  18740. height: number;
  18741. } | {
  18742. ratio: number;
  18743. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18744. private _preparePostProcesses;
  18745. /**
  18746. * Clone the mirror texture.
  18747. * @returns the cloned texture
  18748. */
  18749. clone(): MirrorTexture;
  18750. /**
  18751. * Serialize the texture to a JSON representation you could use in Parse later on
  18752. * @returns the serialized JSON representation
  18753. */
  18754. serialize(): any;
  18755. /**
  18756. * Dispose the texture and release its associated resources.
  18757. */
  18758. dispose(): void;
  18759. }
  18760. }
  18761. declare module "babylonjs/Materials/Textures/texture" {
  18762. import { Observable } from "babylonjs/Misc/observable";
  18763. import { Nullable } from "babylonjs/types";
  18764. import { Scene } from "babylonjs/scene";
  18765. import { Matrix } from "babylonjs/Maths/math";
  18766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18767. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18768. /**
  18769. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18770. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18771. */
  18772. export class Texture extends BaseTexture {
  18773. /** @hidden */
  18774. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18775. /** @hidden */
  18776. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18777. /** @hidden */
  18778. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18779. /** nearest is mag = nearest and min = nearest and mip = linear */
  18780. static readonly NEAREST_SAMPLINGMODE: number;
  18781. /** nearest is mag = nearest and min = nearest and mip = linear */
  18782. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18783. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18784. static readonly BILINEAR_SAMPLINGMODE: number;
  18785. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18786. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18787. /** Trilinear is mag = linear and min = linear and mip = linear */
  18788. static readonly TRILINEAR_SAMPLINGMODE: number;
  18789. /** Trilinear is mag = linear and min = linear and mip = linear */
  18790. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18791. /** mag = nearest and min = nearest and mip = nearest */
  18792. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18793. /** mag = nearest and min = linear and mip = nearest */
  18794. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18795. /** mag = nearest and min = linear and mip = linear */
  18796. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18797. /** mag = nearest and min = linear and mip = none */
  18798. static readonly NEAREST_LINEAR: number;
  18799. /** mag = nearest and min = nearest and mip = none */
  18800. static readonly NEAREST_NEAREST: number;
  18801. /** mag = linear and min = nearest and mip = nearest */
  18802. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18803. /** mag = linear and min = nearest and mip = linear */
  18804. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18805. /** mag = linear and min = linear and mip = none */
  18806. static readonly LINEAR_LINEAR: number;
  18807. /** mag = linear and min = nearest and mip = none */
  18808. static readonly LINEAR_NEAREST: number;
  18809. /** Explicit coordinates mode */
  18810. static readonly EXPLICIT_MODE: number;
  18811. /** Spherical coordinates mode */
  18812. static readonly SPHERICAL_MODE: number;
  18813. /** Planar coordinates mode */
  18814. static readonly PLANAR_MODE: number;
  18815. /** Cubic coordinates mode */
  18816. static readonly CUBIC_MODE: number;
  18817. /** Projection coordinates mode */
  18818. static readonly PROJECTION_MODE: number;
  18819. /** Inverse Cubic coordinates mode */
  18820. static readonly SKYBOX_MODE: number;
  18821. /** Inverse Cubic coordinates mode */
  18822. static readonly INVCUBIC_MODE: number;
  18823. /** Equirectangular coordinates mode */
  18824. static readonly EQUIRECTANGULAR_MODE: number;
  18825. /** Equirectangular Fixed coordinates mode */
  18826. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18827. /** Equirectangular Fixed Mirrored coordinates mode */
  18828. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18829. /** Texture is not repeating outside of 0..1 UVs */
  18830. static readonly CLAMP_ADDRESSMODE: number;
  18831. /** Texture is repeating outside of 0..1 UVs */
  18832. static readonly WRAP_ADDRESSMODE: number;
  18833. /** Texture is repeating and mirrored */
  18834. static readonly MIRROR_ADDRESSMODE: number;
  18835. /**
  18836. * 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
  18837. */
  18838. static UseSerializedUrlIfAny: boolean;
  18839. /**
  18840. * Define the url of the texture.
  18841. */
  18842. url: Nullable<string>;
  18843. /**
  18844. * Define an offset on the texture to offset the u coordinates of the UVs
  18845. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18846. */
  18847. uOffset: number;
  18848. /**
  18849. * Define an offset on the texture to offset the v coordinates of the UVs
  18850. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18851. */
  18852. vOffset: number;
  18853. /**
  18854. * Define an offset on the texture to scale the u coordinates of the UVs
  18855. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18856. */
  18857. uScale: number;
  18858. /**
  18859. * Define an offset on the texture to scale the v coordinates of the UVs
  18860. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18861. */
  18862. vScale: number;
  18863. /**
  18864. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18865. * @see http://doc.babylonjs.com/how_to/more_materials
  18866. */
  18867. uAng: number;
  18868. /**
  18869. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18870. * @see http://doc.babylonjs.com/how_to/more_materials
  18871. */
  18872. vAng: number;
  18873. /**
  18874. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18875. * @see http://doc.babylonjs.com/how_to/more_materials
  18876. */
  18877. wAng: number;
  18878. /**
  18879. * Defines the center of rotation (U)
  18880. */
  18881. uRotationCenter: number;
  18882. /**
  18883. * Defines the center of rotation (V)
  18884. */
  18885. vRotationCenter: number;
  18886. /**
  18887. * Defines the center of rotation (W)
  18888. */
  18889. wRotationCenter: number;
  18890. /**
  18891. * Are mip maps generated for this texture or not.
  18892. */
  18893. readonly noMipmap: boolean;
  18894. /**
  18895. * List of inspectable custom properties (used by the Inspector)
  18896. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18897. */
  18898. inspectableCustomProperties: Nullable<IInspectable[]>;
  18899. private _noMipmap;
  18900. /** @hidden */
  18901. _invertY: boolean;
  18902. private _rowGenerationMatrix;
  18903. private _cachedTextureMatrix;
  18904. private _projectionModeMatrix;
  18905. private _t0;
  18906. private _t1;
  18907. private _t2;
  18908. private _cachedUOffset;
  18909. private _cachedVOffset;
  18910. private _cachedUScale;
  18911. private _cachedVScale;
  18912. private _cachedUAng;
  18913. private _cachedVAng;
  18914. private _cachedWAng;
  18915. private _cachedProjectionMatrixId;
  18916. private _cachedCoordinatesMode;
  18917. /** @hidden */
  18918. protected _initialSamplingMode: number;
  18919. /** @hidden */
  18920. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18921. private _deleteBuffer;
  18922. protected _format: Nullable<number>;
  18923. private _delayedOnLoad;
  18924. private _delayedOnError;
  18925. /**
  18926. * Observable triggered once the texture has been loaded.
  18927. */
  18928. onLoadObservable: Observable<Texture>;
  18929. protected _isBlocking: boolean;
  18930. /**
  18931. * Is the texture preventing material to render while loading.
  18932. * If false, a default texture will be used instead of the loading one during the preparation step.
  18933. */
  18934. isBlocking: boolean;
  18935. /**
  18936. * Get the current sampling mode associated with the texture.
  18937. */
  18938. readonly samplingMode: number;
  18939. /**
  18940. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18941. */
  18942. readonly invertY: boolean;
  18943. /**
  18944. * Instantiates a new texture.
  18945. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18946. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18947. * @param url define the url of the picture to load as a texture
  18948. * @param scene define the scene the texture will belong to
  18949. * @param noMipmap define if the texture will require mip maps or not
  18950. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18951. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18952. * @param onLoad define a callback triggered when the texture has been loaded
  18953. * @param onError define a callback triggered when an error occurred during the loading session
  18954. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18955. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18956. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18957. */
  18958. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18959. /**
  18960. * Update the url (and optional buffer) of this texture if url was null during construction.
  18961. * @param url the url of the texture
  18962. * @param buffer the buffer of the texture (defaults to null)
  18963. * @param onLoad callback called when the texture is loaded (defaults to null)
  18964. */
  18965. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18966. /**
  18967. * Finish the loading sequence of a texture flagged as delayed load.
  18968. * @hidden
  18969. */
  18970. delayLoad(): void;
  18971. private _prepareRowForTextureGeneration;
  18972. /**
  18973. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18974. * @returns the transform matrix of the texture.
  18975. */
  18976. getTextureMatrix(): Matrix;
  18977. /**
  18978. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18979. * @returns The reflection texture transform
  18980. */
  18981. getReflectionTextureMatrix(): Matrix;
  18982. /**
  18983. * Clones the texture.
  18984. * @returns the cloned texture
  18985. */
  18986. clone(): Texture;
  18987. /**
  18988. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18989. * @returns The JSON representation of the texture
  18990. */
  18991. serialize(): any;
  18992. /**
  18993. * Get the current class name of the texture useful for serialization or dynamic coding.
  18994. * @returns "Texture"
  18995. */
  18996. getClassName(): string;
  18997. /**
  18998. * Dispose the texture and release its associated resources.
  18999. */
  19000. dispose(): void;
  19001. /**
  19002. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19003. * @param parsedTexture Define the JSON representation of the texture
  19004. * @param scene Define the scene the parsed texture should be instantiated in
  19005. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19006. * @returns The parsed texture if successful
  19007. */
  19008. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19009. /**
  19010. * Creates a texture from its base 64 representation.
  19011. * @param data Define the base64 payload without the data: prefix
  19012. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19013. * @param scene Define the scene the texture should belong to
  19014. * @param noMipmap Forces the texture to not create mip map information if true
  19015. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19016. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19017. * @param onLoad define a callback triggered when the texture has been loaded
  19018. * @param onError define a callback triggered when an error occurred during the loading session
  19019. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19020. * @returns the created texture
  19021. */
  19022. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19023. /**
  19024. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19025. * @param data Define the base64 payload without the data: prefix
  19026. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19027. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19028. * @param scene Define the scene the texture should belong to
  19029. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19030. * @param noMipmap Forces the texture to not create mip map information if true
  19031. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19032. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19033. * @param onLoad define a callback triggered when the texture has been loaded
  19034. * @param onError define a callback triggered when an error occurred during the loading session
  19035. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19036. * @returns the created texture
  19037. */
  19038. 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;
  19039. }
  19040. }
  19041. declare module "babylonjs/PostProcesses/postProcessManager" {
  19042. import { Nullable } from "babylonjs/types";
  19043. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19044. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19045. import { Scene } from "babylonjs/scene";
  19046. /**
  19047. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19048. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19049. */
  19050. export class PostProcessManager {
  19051. private _scene;
  19052. private _indexBuffer;
  19053. private _vertexBuffers;
  19054. /**
  19055. * Creates a new instance PostProcess
  19056. * @param scene The scene that the post process is associated with.
  19057. */
  19058. constructor(scene: Scene);
  19059. private _prepareBuffers;
  19060. private _buildIndexBuffer;
  19061. /**
  19062. * Rebuilds the vertex buffers of the manager.
  19063. * @hidden
  19064. */
  19065. _rebuild(): void;
  19066. /**
  19067. * Prepares a frame to be run through a post process.
  19068. * @param sourceTexture The input texture to the post procesess. (default: null)
  19069. * @param postProcesses An array of post processes to be run. (default: null)
  19070. * @returns True if the post processes were able to be run.
  19071. * @hidden
  19072. */
  19073. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19074. /**
  19075. * Manually render a set of post processes to a texture.
  19076. * @param postProcesses An array of post processes to be run.
  19077. * @param targetTexture The target texture to render to.
  19078. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19079. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19080. * @param lodLevel defines which lod of the texture to render to
  19081. */
  19082. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19083. /**
  19084. * Finalize the result of the output of the postprocesses.
  19085. * @param doNotPresent If true the result will not be displayed to the screen.
  19086. * @param targetTexture The target texture to render to.
  19087. * @param faceIndex The index of the face to bind the target texture to.
  19088. * @param postProcesses The array of post processes to render.
  19089. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19090. * @hidden
  19091. */
  19092. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19093. /**
  19094. * Disposes of the post process manager.
  19095. */
  19096. dispose(): void;
  19097. }
  19098. }
  19099. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19100. import { Scene } from "babylonjs/scene";
  19101. import { ISceneComponent } from "babylonjs/sceneComponent";
  19102. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19103. module "babylonjs/abstractScene" {
  19104. interface AbstractScene {
  19105. /**
  19106. * The list of procedural textures added to the scene
  19107. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19108. */
  19109. proceduralTextures: Array<ProceduralTexture>;
  19110. }
  19111. }
  19112. /**
  19113. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19114. * in a given scene.
  19115. */
  19116. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19117. /**
  19118. * The component name helpfull to identify the component in the list of scene components.
  19119. */
  19120. readonly name: string;
  19121. /**
  19122. * The scene the component belongs to.
  19123. */
  19124. scene: Scene;
  19125. /**
  19126. * Creates a new instance of the component for the given scene
  19127. * @param scene Defines the scene to register the component in
  19128. */
  19129. constructor(scene: Scene);
  19130. /**
  19131. * Registers the component in a given scene
  19132. */
  19133. register(): void;
  19134. /**
  19135. * Rebuilds the elements related to this component in case of
  19136. * context lost for instance.
  19137. */
  19138. rebuild(): void;
  19139. /**
  19140. * Disposes the component and the associated ressources.
  19141. */
  19142. dispose(): void;
  19143. private _beforeClear;
  19144. }
  19145. }
  19146. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19147. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19148. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19149. module "babylonjs/Engines/engine" {
  19150. interface Engine {
  19151. /**
  19152. * Creates a new render target cube texture
  19153. * @param size defines the size of the texture
  19154. * @param options defines the options used to create the texture
  19155. * @returns a new render target cube texture stored in an InternalTexture
  19156. */
  19157. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19158. }
  19159. }
  19160. }
  19161. declare module "babylonjs/Shaders/procedural.vertex" {
  19162. /** @hidden */
  19163. export var proceduralVertexShader: {
  19164. name: string;
  19165. shader: string;
  19166. };
  19167. }
  19168. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19169. import { Observable } from "babylonjs/Misc/observable";
  19170. import { Nullable } from "babylonjs/types";
  19171. import { Scene } from "babylonjs/scene";
  19172. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19173. import { Effect } from "babylonjs/Materials/effect";
  19174. import { Texture } from "babylonjs/Materials/Textures/texture";
  19175. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19176. import "babylonjs/Shaders/procedural.vertex";
  19177. /**
  19178. * 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.
  19179. * This is the base class of any Procedural texture and contains most of the shareable code.
  19180. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19181. */
  19182. export class ProceduralTexture extends Texture {
  19183. isCube: boolean;
  19184. /**
  19185. * Define if the texture is enabled or not (disabled texture will not render)
  19186. */
  19187. isEnabled: boolean;
  19188. /**
  19189. * Define if the texture must be cleared before rendering (default is true)
  19190. */
  19191. autoClear: boolean;
  19192. /**
  19193. * Callback called when the texture is generated
  19194. */
  19195. onGenerated: () => void;
  19196. /**
  19197. * Event raised when the texture is generated
  19198. */
  19199. onGeneratedObservable: Observable<ProceduralTexture>;
  19200. /** @hidden */
  19201. _generateMipMaps: boolean;
  19202. /** @hidden **/
  19203. _effect: Effect;
  19204. /** @hidden */
  19205. _textures: {
  19206. [key: string]: Texture;
  19207. };
  19208. private _size;
  19209. private _currentRefreshId;
  19210. private _refreshRate;
  19211. private _vertexBuffers;
  19212. private _indexBuffer;
  19213. private _uniforms;
  19214. private _samplers;
  19215. private _fragment;
  19216. private _floats;
  19217. private _ints;
  19218. private _floatsArrays;
  19219. private _colors3;
  19220. private _colors4;
  19221. private _vectors2;
  19222. private _vectors3;
  19223. private _matrices;
  19224. private _fallbackTexture;
  19225. private _fallbackTextureUsed;
  19226. private _engine;
  19227. private _cachedDefines;
  19228. private _contentUpdateId;
  19229. private _contentData;
  19230. /**
  19231. * Instantiates a new procedural texture.
  19232. * 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.
  19233. * This is the base class of any Procedural texture and contains most of the shareable code.
  19234. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19235. * @param name Define the name of the texture
  19236. * @param size Define the size of the texture to create
  19237. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19238. * @param scene Define the scene the texture belongs to
  19239. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19240. * @param generateMipMaps Define if the texture should creates mip maps or not
  19241. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19242. */
  19243. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19244. /**
  19245. * The effect that is created when initializing the post process.
  19246. * @returns The created effect corresponding the the postprocess.
  19247. */
  19248. getEffect(): Effect;
  19249. /**
  19250. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19251. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19252. */
  19253. getContent(): Nullable<ArrayBufferView>;
  19254. private _createIndexBuffer;
  19255. /** @hidden */
  19256. _rebuild(): void;
  19257. /**
  19258. * Resets the texture in order to recreate its associated resources.
  19259. * This can be called in case of context loss
  19260. */
  19261. reset(): void;
  19262. protected _getDefines(): string;
  19263. /**
  19264. * Is the texture ready to be used ? (rendered at least once)
  19265. * @returns true if ready, otherwise, false.
  19266. */
  19267. isReady(): boolean;
  19268. /**
  19269. * Resets the refresh counter of the texture and start bak from scratch.
  19270. * Could be useful to regenerate the texture if it is setup to render only once.
  19271. */
  19272. resetRefreshCounter(): void;
  19273. /**
  19274. * Set the fragment shader to use in order to render the texture.
  19275. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19276. */
  19277. setFragment(fragment: any): void;
  19278. /**
  19279. * Define the refresh rate of the texture or the rendering frequency.
  19280. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19281. */
  19282. refreshRate: number;
  19283. /** @hidden */
  19284. _shouldRender(): boolean;
  19285. /**
  19286. * Get the size the texture is rendering at.
  19287. * @returns the size (texture is always squared)
  19288. */
  19289. getRenderSize(): number;
  19290. /**
  19291. * Resize the texture to new value.
  19292. * @param size Define the new size the texture should have
  19293. * @param generateMipMaps Define whether the new texture should create mip maps
  19294. */
  19295. resize(size: number, generateMipMaps: boolean): void;
  19296. private _checkUniform;
  19297. /**
  19298. * Set a texture in the shader program used to render.
  19299. * @param name Define the name of the uniform samplers as defined in the shader
  19300. * @param texture Define the texture to bind to this sampler
  19301. * @return the texture itself allowing "fluent" like uniform updates
  19302. */
  19303. setTexture(name: string, texture: Texture): ProceduralTexture;
  19304. /**
  19305. * Set a float in the shader.
  19306. * @param name Define the name of the uniform as defined in the shader
  19307. * @param value Define the value to give to the uniform
  19308. * @return the texture itself allowing "fluent" like uniform updates
  19309. */
  19310. setFloat(name: string, value: number): ProceduralTexture;
  19311. /**
  19312. * Set a int in the shader.
  19313. * @param name Define the name of the uniform as defined in the shader
  19314. * @param value Define the value to give to the uniform
  19315. * @return the texture itself allowing "fluent" like uniform updates
  19316. */
  19317. setInt(name: string, value: number): ProceduralTexture;
  19318. /**
  19319. * Set an array of floats in the shader.
  19320. * @param name Define the name of the uniform as defined in the shader
  19321. * @param value Define the value to give to the uniform
  19322. * @return the texture itself allowing "fluent" like uniform updates
  19323. */
  19324. setFloats(name: string, value: number[]): ProceduralTexture;
  19325. /**
  19326. * Set a vec3 in the shader from a Color3.
  19327. * @param name Define the name of the uniform as defined in the shader
  19328. * @param value Define the value to give to the uniform
  19329. * @return the texture itself allowing "fluent" like uniform updates
  19330. */
  19331. setColor3(name: string, value: Color3): ProceduralTexture;
  19332. /**
  19333. * Set a vec4 in the shader from a Color4.
  19334. * @param name Define the name of the uniform as defined in the shader
  19335. * @param value Define the value to give to the uniform
  19336. * @return the texture itself allowing "fluent" like uniform updates
  19337. */
  19338. setColor4(name: string, value: Color4): ProceduralTexture;
  19339. /**
  19340. * Set a vec2 in the shader from a Vector2.
  19341. * @param name Define the name of the uniform as defined in the shader
  19342. * @param value Define the value to give to the uniform
  19343. * @return the texture itself allowing "fluent" like uniform updates
  19344. */
  19345. setVector2(name: string, value: Vector2): ProceduralTexture;
  19346. /**
  19347. * Set a vec3 in the shader from a Vector3.
  19348. * @param name Define the name of the uniform as defined in the shader
  19349. * @param value Define the value to give to the uniform
  19350. * @return the texture itself allowing "fluent" like uniform updates
  19351. */
  19352. setVector3(name: string, value: Vector3): ProceduralTexture;
  19353. /**
  19354. * Set a mat4 in the shader from a MAtrix.
  19355. * @param name Define the name of the uniform as defined in the shader
  19356. * @param value Define the value to give to the uniform
  19357. * @return the texture itself allowing "fluent" like uniform updates
  19358. */
  19359. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19360. /**
  19361. * Render the texture to its associated render target.
  19362. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19363. */
  19364. render(useCameraPostProcess?: boolean): void;
  19365. /**
  19366. * Clone the texture.
  19367. * @returns the cloned texture
  19368. */
  19369. clone(): ProceduralTexture;
  19370. /**
  19371. * Dispose the texture and release its asoociated resources.
  19372. */
  19373. dispose(): void;
  19374. }
  19375. }
  19376. declare module "babylonjs/Particles/baseParticleSystem" {
  19377. import { Nullable } from "babylonjs/types";
  19378. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19380. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19381. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19382. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19383. import { Scene } from "babylonjs/scene";
  19384. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19385. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19386. import { Texture } from "babylonjs/Materials/Textures/texture";
  19387. import { Animation } from "babylonjs/Animations/animation";
  19388. /**
  19389. * This represents the base class for particle system in Babylon.
  19390. * 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.
  19391. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19392. * @example https://doc.babylonjs.com/babylon101/particles
  19393. */
  19394. export class BaseParticleSystem {
  19395. /**
  19396. * Source color is added to the destination color without alpha affecting the result
  19397. */
  19398. static BLENDMODE_ONEONE: number;
  19399. /**
  19400. * Blend current color and particle color using particle’s alpha
  19401. */
  19402. static BLENDMODE_STANDARD: number;
  19403. /**
  19404. * Add current color and particle color multiplied by particle’s alpha
  19405. */
  19406. static BLENDMODE_ADD: number;
  19407. /**
  19408. * Multiply current color with particle color
  19409. */
  19410. static BLENDMODE_MULTIPLY: number;
  19411. /**
  19412. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19413. */
  19414. static BLENDMODE_MULTIPLYADD: number;
  19415. /**
  19416. * List of animations used by the particle system.
  19417. */
  19418. animations: Animation[];
  19419. /**
  19420. * The id of the Particle system.
  19421. */
  19422. id: string;
  19423. /**
  19424. * The friendly name of the Particle system.
  19425. */
  19426. name: string;
  19427. /**
  19428. * The rendering group used by the Particle system to chose when to render.
  19429. */
  19430. renderingGroupId: number;
  19431. /**
  19432. * The emitter represents the Mesh or position we are attaching the particle system to.
  19433. */
  19434. emitter: Nullable<AbstractMesh | Vector3>;
  19435. /**
  19436. * The maximum number of particles to emit per frame
  19437. */
  19438. emitRate: number;
  19439. /**
  19440. * If you want to launch only a few particles at once, that can be done, as well.
  19441. */
  19442. manualEmitCount: number;
  19443. /**
  19444. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19445. */
  19446. updateSpeed: number;
  19447. /**
  19448. * The amount of time the particle system is running (depends of the overall update speed).
  19449. */
  19450. targetStopDuration: number;
  19451. /**
  19452. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19453. */
  19454. disposeOnStop: boolean;
  19455. /**
  19456. * Minimum power of emitting particles.
  19457. */
  19458. minEmitPower: number;
  19459. /**
  19460. * Maximum power of emitting particles.
  19461. */
  19462. maxEmitPower: number;
  19463. /**
  19464. * Minimum life time of emitting particles.
  19465. */
  19466. minLifeTime: number;
  19467. /**
  19468. * Maximum life time of emitting particles.
  19469. */
  19470. maxLifeTime: number;
  19471. /**
  19472. * Minimum Size of emitting particles.
  19473. */
  19474. minSize: number;
  19475. /**
  19476. * Maximum Size of emitting particles.
  19477. */
  19478. maxSize: number;
  19479. /**
  19480. * Minimum scale of emitting particles on X axis.
  19481. */
  19482. minScaleX: number;
  19483. /**
  19484. * Maximum scale of emitting particles on X axis.
  19485. */
  19486. maxScaleX: number;
  19487. /**
  19488. * Minimum scale of emitting particles on Y axis.
  19489. */
  19490. minScaleY: number;
  19491. /**
  19492. * Maximum scale of emitting particles on Y axis.
  19493. */
  19494. maxScaleY: number;
  19495. /**
  19496. * Gets or sets the minimal initial rotation in radians.
  19497. */
  19498. minInitialRotation: number;
  19499. /**
  19500. * Gets or sets the maximal initial rotation in radians.
  19501. */
  19502. maxInitialRotation: number;
  19503. /**
  19504. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19505. */
  19506. minAngularSpeed: number;
  19507. /**
  19508. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19509. */
  19510. maxAngularSpeed: number;
  19511. /**
  19512. * The texture used to render each particle. (this can be a spritesheet)
  19513. */
  19514. particleTexture: Nullable<Texture>;
  19515. /**
  19516. * The layer mask we are rendering the particles through.
  19517. */
  19518. layerMask: number;
  19519. /**
  19520. * This can help using your own shader to render the particle system.
  19521. * The according effect will be created
  19522. */
  19523. customShader: any;
  19524. /**
  19525. * By default particle system starts as soon as they are created. This prevents the
  19526. * automatic start to happen and let you decide when to start emitting particles.
  19527. */
  19528. preventAutoStart: boolean;
  19529. private _noiseTexture;
  19530. /**
  19531. * Gets or sets a texture used to add random noise to particle positions
  19532. */
  19533. noiseTexture: Nullable<ProceduralTexture>;
  19534. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19535. noiseStrength: Vector3;
  19536. /**
  19537. * Callback triggered when the particle animation is ending.
  19538. */
  19539. onAnimationEnd: Nullable<() => void>;
  19540. /**
  19541. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19542. */
  19543. blendMode: number;
  19544. /**
  19545. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19546. * to override the particles.
  19547. */
  19548. forceDepthWrite: boolean;
  19549. /** 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 */
  19550. preWarmCycles: number;
  19551. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19552. preWarmStepOffset: number;
  19553. /**
  19554. * 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)
  19555. */
  19556. spriteCellChangeSpeed: number;
  19557. /**
  19558. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19559. */
  19560. startSpriteCellID: number;
  19561. /**
  19562. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19563. */
  19564. endSpriteCellID: number;
  19565. /**
  19566. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19567. */
  19568. spriteCellWidth: number;
  19569. /**
  19570. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19571. */
  19572. spriteCellHeight: number;
  19573. /**
  19574. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19575. */
  19576. spriteRandomStartCell: boolean;
  19577. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19578. translationPivot: Vector2;
  19579. /** @hidden */
  19580. protected _isAnimationSheetEnabled: boolean;
  19581. /**
  19582. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19583. */
  19584. beginAnimationOnStart: boolean;
  19585. /**
  19586. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19587. */
  19588. beginAnimationFrom: number;
  19589. /**
  19590. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19591. */
  19592. beginAnimationTo: number;
  19593. /**
  19594. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19595. */
  19596. beginAnimationLoop: boolean;
  19597. /**
  19598. * Gets or sets a world offset applied to all particles
  19599. */
  19600. worldOffset: Vector3;
  19601. /**
  19602. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19603. */
  19604. isAnimationSheetEnabled: boolean;
  19605. /**
  19606. * Get hosting scene
  19607. * @returns the scene
  19608. */
  19609. getScene(): Scene;
  19610. /**
  19611. * You can use gravity if you want to give an orientation to your particles.
  19612. */
  19613. gravity: Vector3;
  19614. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19615. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19616. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19617. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19618. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19619. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19620. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19621. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19622. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19623. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19624. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19625. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19626. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19627. /**
  19628. * Defines the delay in milliseconds before starting the system (0 by default)
  19629. */
  19630. startDelay: number;
  19631. /**
  19632. * Gets the current list of drag gradients.
  19633. * You must use addDragGradient and removeDragGradient to udpate this list
  19634. * @returns the list of drag gradients
  19635. */
  19636. getDragGradients(): Nullable<Array<FactorGradient>>;
  19637. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19638. limitVelocityDamping: number;
  19639. /**
  19640. * Gets the current list of limit velocity gradients.
  19641. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19642. * @returns the list of limit velocity gradients
  19643. */
  19644. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19645. /**
  19646. * Gets the current list of color gradients.
  19647. * You must use addColorGradient and removeColorGradient to udpate this list
  19648. * @returns the list of color gradients
  19649. */
  19650. getColorGradients(): Nullable<Array<ColorGradient>>;
  19651. /**
  19652. * Gets the current list of size gradients.
  19653. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19654. * @returns the list of size gradients
  19655. */
  19656. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19657. /**
  19658. * Gets the current list of color remap gradients.
  19659. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19660. * @returns the list of color remap gradients
  19661. */
  19662. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19663. /**
  19664. * Gets the current list of alpha remap gradients.
  19665. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19666. * @returns the list of alpha remap gradients
  19667. */
  19668. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19669. /**
  19670. * Gets the current list of life time gradients.
  19671. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19672. * @returns the list of life time gradients
  19673. */
  19674. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19675. /**
  19676. * Gets the current list of angular speed gradients.
  19677. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19678. * @returns the list of angular speed gradients
  19679. */
  19680. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19681. /**
  19682. * Gets the current list of velocity gradients.
  19683. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19684. * @returns the list of velocity gradients
  19685. */
  19686. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19687. /**
  19688. * Gets the current list of start size gradients.
  19689. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19690. * @returns the list of start size gradients
  19691. */
  19692. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19693. /**
  19694. * Gets the current list of emit rate gradients.
  19695. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19696. * @returns the list of emit rate gradients
  19697. */
  19698. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19699. /**
  19700. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19701. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19702. */
  19703. direction1: Vector3;
  19704. /**
  19705. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19706. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19707. */
  19708. direction2: Vector3;
  19709. /**
  19710. * 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.
  19711. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19712. */
  19713. minEmitBox: Vector3;
  19714. /**
  19715. * 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.
  19716. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19717. */
  19718. maxEmitBox: Vector3;
  19719. /**
  19720. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19721. */
  19722. color1: Color4;
  19723. /**
  19724. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19725. */
  19726. color2: Color4;
  19727. /**
  19728. * Color the particle will have at the end of its lifetime
  19729. */
  19730. colorDead: Color4;
  19731. /**
  19732. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19733. */
  19734. textureMask: Color4;
  19735. /**
  19736. * The particle emitter type defines the emitter used by the particle system.
  19737. * It can be for example box, sphere, or cone...
  19738. */
  19739. particleEmitterType: IParticleEmitterType;
  19740. /** @hidden */
  19741. _isSubEmitter: boolean;
  19742. /**
  19743. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19744. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19745. */
  19746. billboardMode: number;
  19747. protected _isBillboardBased: boolean;
  19748. /**
  19749. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19750. */
  19751. isBillboardBased: boolean;
  19752. /**
  19753. * The scene the particle system belongs to.
  19754. */
  19755. protected _scene: Scene;
  19756. /**
  19757. * Local cache of defines for image processing.
  19758. */
  19759. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19760. /**
  19761. * Default configuration related to image processing available in the standard Material.
  19762. */
  19763. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19764. /**
  19765. * Gets the image processing configuration used either in this material.
  19766. */
  19767. /**
  19768. * Sets the Default image processing configuration used either in the this material.
  19769. *
  19770. * If sets to null, the scene one is in use.
  19771. */
  19772. imageProcessingConfiguration: ImageProcessingConfiguration;
  19773. /**
  19774. * Attaches a new image processing configuration to the Standard Material.
  19775. * @param configuration
  19776. */
  19777. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19778. /** @hidden */
  19779. protected _reset(): void;
  19780. /** @hidden */
  19781. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19782. /**
  19783. * Instantiates a particle system.
  19784. * 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.
  19785. * @param name The name of the particle system
  19786. */
  19787. constructor(name: string);
  19788. /**
  19789. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19790. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19791. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19792. * @returns the emitter
  19793. */
  19794. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19795. /**
  19796. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19797. * @param radius The radius of the hemisphere to emit from
  19798. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19799. * @returns the emitter
  19800. */
  19801. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19802. /**
  19803. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19804. * @param radius The radius of the sphere to emit from
  19805. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19806. * @returns the emitter
  19807. */
  19808. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19809. /**
  19810. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19811. * @param radius The radius of the sphere to emit from
  19812. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19813. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19814. * @returns the emitter
  19815. */
  19816. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19817. /**
  19818. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19819. * @param radius The radius of the emission cylinder
  19820. * @param height The height of the emission cylinder
  19821. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19822. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19823. * @returns the emitter
  19824. */
  19825. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19826. /**
  19827. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19828. * @param radius The radius of the cylinder to emit from
  19829. * @param height The height of the emission cylinder
  19830. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19831. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19832. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19833. * @returns the emitter
  19834. */
  19835. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19836. /**
  19837. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19838. * @param radius The radius of the cone to emit from
  19839. * @param angle The base angle of the cone
  19840. * @returns the emitter
  19841. */
  19842. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19843. /**
  19844. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19845. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19846. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19847. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19848. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19849. * @returns the emitter
  19850. */
  19851. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19852. }
  19853. }
  19854. declare module "babylonjs/Particles/subEmitter" {
  19855. import { Scene } from "babylonjs/scene";
  19856. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19857. /**
  19858. * Type of sub emitter
  19859. */
  19860. export enum SubEmitterType {
  19861. /**
  19862. * Attached to the particle over it's lifetime
  19863. */
  19864. ATTACHED = 0,
  19865. /**
  19866. * Created when the particle dies
  19867. */
  19868. END = 1
  19869. }
  19870. /**
  19871. * Sub emitter class used to emit particles from an existing particle
  19872. */
  19873. export class SubEmitter {
  19874. /**
  19875. * the particle system to be used by the sub emitter
  19876. */
  19877. particleSystem: ParticleSystem;
  19878. /**
  19879. * Type of the submitter (Default: END)
  19880. */
  19881. type: SubEmitterType;
  19882. /**
  19883. * 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)
  19884. * Note: This only is supported when using an emitter of type Mesh
  19885. */
  19886. inheritDirection: boolean;
  19887. /**
  19888. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19889. */
  19890. inheritedVelocityAmount: number;
  19891. /**
  19892. * Creates a sub emitter
  19893. * @param particleSystem the particle system to be used by the sub emitter
  19894. */
  19895. constructor(
  19896. /**
  19897. * the particle system to be used by the sub emitter
  19898. */
  19899. particleSystem: ParticleSystem);
  19900. /**
  19901. * Clones the sub emitter
  19902. * @returns the cloned sub emitter
  19903. */
  19904. clone(): SubEmitter;
  19905. /**
  19906. * Serialize current object to a JSON object
  19907. * @returns the serialized object
  19908. */
  19909. serialize(): any;
  19910. /** @hidden */
  19911. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19912. /**
  19913. * Creates a new SubEmitter from a serialized JSON version
  19914. * @param serializationObject defines the JSON object to read from
  19915. * @param scene defines the hosting scene
  19916. * @param rootUrl defines the rootUrl for data loading
  19917. * @returns a new SubEmitter
  19918. */
  19919. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19920. /** Release associated resources */
  19921. dispose(): void;
  19922. }
  19923. }
  19924. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  19925. /** @hidden */
  19926. export var imageProcessingDeclaration: {
  19927. name: string;
  19928. shader: string;
  19929. };
  19930. }
  19931. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  19932. /** @hidden */
  19933. export var imageProcessingFunctions: {
  19934. name: string;
  19935. shader: string;
  19936. };
  19937. }
  19938. declare module "babylonjs/Shaders/particles.fragment" {
  19939. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19940. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19941. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19942. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19943. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19944. /** @hidden */
  19945. export var particlesPixelShader: {
  19946. name: string;
  19947. shader: string;
  19948. };
  19949. }
  19950. declare module "babylonjs/Shaders/particles.vertex" {
  19951. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19952. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19953. /** @hidden */
  19954. export var particlesVertexShader: {
  19955. name: string;
  19956. shader: string;
  19957. };
  19958. }
  19959. declare module "babylonjs/Particles/particleSystem" {
  19960. import { Nullable } from "babylonjs/types";
  19961. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  19962. import { Observable } from "babylonjs/Misc/observable";
  19963. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  19964. import { Effect } from "babylonjs/Materials/effect";
  19965. import { Scene, IDisposable } from "babylonjs/scene";
  19966. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19967. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  19968. import { Particle } from "babylonjs/Particles/particle";
  19969. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  19970. import "babylonjs/Shaders/particles.fragment";
  19971. import "babylonjs/Shaders/particles.vertex";
  19972. /**
  19973. * This represents a particle system in Babylon.
  19974. * 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.
  19975. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19976. * @example https://doc.babylonjs.com/babylon101/particles
  19977. */
  19978. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19979. /**
  19980. * Billboard mode will only apply to Y axis
  19981. */
  19982. static readonly BILLBOARDMODE_Y: number;
  19983. /**
  19984. * Billboard mode will apply to all axes
  19985. */
  19986. static readonly BILLBOARDMODE_ALL: number;
  19987. /**
  19988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19989. */
  19990. static readonly BILLBOARDMODE_STRETCHED: number;
  19991. /**
  19992. * This function can be defined to provide custom update for active particles.
  19993. * This function will be called instead of regular update (age, position, color, etc.).
  19994. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19995. */
  19996. updateFunction: (particles: Particle[]) => void;
  19997. private _emitterWorldMatrix;
  19998. /**
  19999. * This function can be defined to specify initial direction for every new particle.
  20000. * It by default use the emitterType defined function
  20001. */
  20002. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20003. /**
  20004. * This function can be defined to specify initial position for every new particle.
  20005. * It by default use the emitterType defined function
  20006. */
  20007. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20008. /**
  20009. * @hidden
  20010. */
  20011. _inheritedVelocityOffset: Vector3;
  20012. /**
  20013. * An event triggered when the system is disposed
  20014. */
  20015. onDisposeObservable: Observable<ParticleSystem>;
  20016. private _onDisposeObserver;
  20017. /**
  20018. * Sets a callback that will be triggered when the system is disposed
  20019. */
  20020. onDispose: () => void;
  20021. private _particles;
  20022. private _epsilon;
  20023. private _capacity;
  20024. private _stockParticles;
  20025. private _newPartsExcess;
  20026. private _vertexData;
  20027. private _vertexBuffer;
  20028. private _vertexBuffers;
  20029. private _spriteBuffer;
  20030. private _indexBuffer;
  20031. private _effect;
  20032. private _customEffect;
  20033. private _cachedDefines;
  20034. private _scaledColorStep;
  20035. private _colorDiff;
  20036. private _scaledDirection;
  20037. private _scaledGravity;
  20038. private _currentRenderId;
  20039. private _alive;
  20040. private _useInstancing;
  20041. private _started;
  20042. private _stopped;
  20043. private _actualFrame;
  20044. private _scaledUpdateSpeed;
  20045. private _vertexBufferSize;
  20046. /** @hidden */
  20047. _currentEmitRateGradient: Nullable<FactorGradient>;
  20048. /** @hidden */
  20049. _currentEmitRate1: number;
  20050. /** @hidden */
  20051. _currentEmitRate2: number;
  20052. /** @hidden */
  20053. _currentStartSizeGradient: Nullable<FactorGradient>;
  20054. /** @hidden */
  20055. _currentStartSize1: number;
  20056. /** @hidden */
  20057. _currentStartSize2: number;
  20058. private readonly _rawTextureWidth;
  20059. private _rampGradientsTexture;
  20060. private _useRampGradients;
  20061. /** Gets or sets a boolean indicating that ramp gradients must be used
  20062. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20063. */
  20064. useRampGradients: boolean;
  20065. /**
  20066. * 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.
  20067. * 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: [])
  20068. */
  20069. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20070. private _subEmitters;
  20071. /**
  20072. * @hidden
  20073. * If the particle systems emitter should be disposed when the particle system is disposed
  20074. */
  20075. _disposeEmitterOnDispose: boolean;
  20076. /**
  20077. * The current active Sub-systems, this property is used by the root particle system only.
  20078. */
  20079. activeSubSystems: Array<ParticleSystem>;
  20080. private _rootParticleSystem;
  20081. /**
  20082. * Gets the current list of active particles
  20083. */
  20084. readonly particles: Particle[];
  20085. /**
  20086. * Returns the string "ParticleSystem"
  20087. * @returns a string containing the class name
  20088. */
  20089. getClassName(): string;
  20090. /**
  20091. * Instantiates a particle system.
  20092. * 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.
  20093. * @param name The name of the particle system
  20094. * @param capacity The max number of particles alive at the same time
  20095. * @param scene The scene the particle system belongs to
  20096. * @param customEffect a custom effect used to change the way particles are rendered by default
  20097. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20098. * @param epsilon Offset used to render the particles
  20099. */
  20100. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20101. private _addFactorGradient;
  20102. private _removeFactorGradient;
  20103. /**
  20104. * Adds a new life time gradient
  20105. * @param gradient defines the gradient to use (between 0 and 1)
  20106. * @param factor defines the life time factor to affect to the specified gradient
  20107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20108. * @returns the current particle system
  20109. */
  20110. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20111. /**
  20112. * Remove a specific life time gradient
  20113. * @param gradient defines the gradient to remove
  20114. * @returns the current particle system
  20115. */
  20116. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20117. /**
  20118. * Adds a new size gradient
  20119. * @param gradient defines the gradient to use (between 0 and 1)
  20120. * @param factor defines the size factor to affect to the specified gradient
  20121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20122. * @returns the current particle system
  20123. */
  20124. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20125. /**
  20126. * Remove a specific size gradient
  20127. * @param gradient defines the gradient to remove
  20128. * @returns the current particle system
  20129. */
  20130. removeSizeGradient(gradient: number): IParticleSystem;
  20131. /**
  20132. * Adds a new color remap gradient
  20133. * @param gradient defines the gradient to use (between 0 and 1)
  20134. * @param min defines the color remap minimal range
  20135. * @param max defines the color remap maximal range
  20136. * @returns the current particle system
  20137. */
  20138. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20139. /**
  20140. * Remove a specific color remap gradient
  20141. * @param gradient defines the gradient to remove
  20142. * @returns the current particle system
  20143. */
  20144. removeColorRemapGradient(gradient: number): IParticleSystem;
  20145. /**
  20146. * Adds a new alpha remap gradient
  20147. * @param gradient defines the gradient to use (between 0 and 1)
  20148. * @param min defines the alpha remap minimal range
  20149. * @param max defines the alpha remap maximal range
  20150. * @returns the current particle system
  20151. */
  20152. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20153. /**
  20154. * Remove a specific alpha remap gradient
  20155. * @param gradient defines the gradient to remove
  20156. * @returns the current particle system
  20157. */
  20158. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20159. /**
  20160. * Adds a new angular speed gradient
  20161. * @param gradient defines the gradient to use (between 0 and 1)
  20162. * @param factor defines the angular speed to affect to the specified gradient
  20163. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20164. * @returns the current particle system
  20165. */
  20166. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20167. /**
  20168. * Remove a specific angular speed gradient
  20169. * @param gradient defines the gradient to remove
  20170. * @returns the current particle system
  20171. */
  20172. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20173. /**
  20174. * Adds a new velocity gradient
  20175. * @param gradient defines the gradient to use (between 0 and 1)
  20176. * @param factor defines the velocity to affect to the specified gradient
  20177. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20178. * @returns the current particle system
  20179. */
  20180. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20181. /**
  20182. * Remove a specific velocity gradient
  20183. * @param gradient defines the gradient to remove
  20184. * @returns the current particle system
  20185. */
  20186. removeVelocityGradient(gradient: number): IParticleSystem;
  20187. /**
  20188. * Adds a new limit velocity gradient
  20189. * @param gradient defines the gradient to use (between 0 and 1)
  20190. * @param factor defines the limit velocity value to affect to the specified gradient
  20191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20192. * @returns the current particle system
  20193. */
  20194. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20195. /**
  20196. * Remove a specific limit velocity gradient
  20197. * @param gradient defines the gradient to remove
  20198. * @returns the current particle system
  20199. */
  20200. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20201. /**
  20202. * Adds a new drag gradient
  20203. * @param gradient defines the gradient to use (between 0 and 1)
  20204. * @param factor defines the drag value to affect to the specified gradient
  20205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20206. * @returns the current particle system
  20207. */
  20208. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20209. /**
  20210. * Remove a specific drag gradient
  20211. * @param gradient defines the gradient to remove
  20212. * @returns the current particle system
  20213. */
  20214. removeDragGradient(gradient: number): IParticleSystem;
  20215. /**
  20216. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20217. * @param gradient defines the gradient to use (between 0 and 1)
  20218. * @param factor defines the emit rate value to affect to the specified gradient
  20219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20220. * @returns the current particle system
  20221. */
  20222. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20223. /**
  20224. * Remove a specific emit rate gradient
  20225. * @param gradient defines the gradient to remove
  20226. * @returns the current particle system
  20227. */
  20228. removeEmitRateGradient(gradient: number): IParticleSystem;
  20229. /**
  20230. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20231. * @param gradient defines the gradient to use (between 0 and 1)
  20232. * @param factor defines the start size value to affect to the specified gradient
  20233. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20234. * @returns the current particle system
  20235. */
  20236. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20237. /**
  20238. * Remove a specific start size gradient
  20239. * @param gradient defines the gradient to remove
  20240. * @returns the current particle system
  20241. */
  20242. removeStartSizeGradient(gradient: number): IParticleSystem;
  20243. private _createRampGradientTexture;
  20244. /**
  20245. * Gets the current list of ramp gradients.
  20246. * You must use addRampGradient and removeRampGradient to udpate this list
  20247. * @returns the list of ramp gradients
  20248. */
  20249. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20250. /**
  20251. * Adds a new ramp gradient used to remap particle colors
  20252. * @param gradient defines the gradient to use (between 0 and 1)
  20253. * @param color defines the color to affect to the specified gradient
  20254. * @returns the current particle system
  20255. */
  20256. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20257. /**
  20258. * Remove a specific ramp gradient
  20259. * @param gradient defines the gradient to remove
  20260. * @returns the current particle system
  20261. */
  20262. removeRampGradient(gradient: number): ParticleSystem;
  20263. /**
  20264. * Adds a new color gradient
  20265. * @param gradient defines the gradient to use (between 0 and 1)
  20266. * @param color1 defines the color to affect to the specified gradient
  20267. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20268. * @returns this particle system
  20269. */
  20270. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20271. /**
  20272. * Remove a specific color gradient
  20273. * @param gradient defines the gradient to remove
  20274. * @returns this particle system
  20275. */
  20276. removeColorGradient(gradient: number): IParticleSystem;
  20277. private _fetchR;
  20278. protected _reset(): void;
  20279. private _resetEffect;
  20280. private _createVertexBuffers;
  20281. private _createIndexBuffer;
  20282. /**
  20283. * Gets the maximum number of particles active at the same time.
  20284. * @returns The max number of active particles.
  20285. */
  20286. getCapacity(): number;
  20287. /**
  20288. * Gets whether there are still active particles in the system.
  20289. * @returns True if it is alive, otherwise false.
  20290. */
  20291. isAlive(): boolean;
  20292. /**
  20293. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20294. * @returns True if it has been started, otherwise false.
  20295. */
  20296. isStarted(): boolean;
  20297. private _prepareSubEmitterInternalArray;
  20298. /**
  20299. * Starts the particle system and begins to emit
  20300. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20301. */
  20302. start(delay?: number): void;
  20303. /**
  20304. * Stops the particle system.
  20305. * @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.
  20306. */
  20307. stop(stopSubEmitters?: boolean): void;
  20308. /**
  20309. * Remove all active particles
  20310. */
  20311. reset(): void;
  20312. /**
  20313. * @hidden (for internal use only)
  20314. */
  20315. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20316. /**
  20317. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20318. * Its lifetime will start back at 0.
  20319. */
  20320. recycleParticle: (particle: Particle) => void;
  20321. private _stopSubEmitters;
  20322. private _createParticle;
  20323. private _removeFromRoot;
  20324. private _emitFromParticle;
  20325. private _update;
  20326. /** @hidden */
  20327. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20328. /** @hidden */
  20329. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20330. /** @hidden */
  20331. private _getEffect;
  20332. /**
  20333. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20334. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20335. */
  20336. animate(preWarmOnly?: boolean): void;
  20337. private _appendParticleVertices;
  20338. /**
  20339. * Rebuilds the particle system.
  20340. */
  20341. rebuild(): void;
  20342. /**
  20343. * Is this system ready to be used/rendered
  20344. * @return true if the system is ready
  20345. */
  20346. isReady(): boolean;
  20347. private _render;
  20348. /**
  20349. * Renders the particle system in its current state.
  20350. * @returns the current number of particles
  20351. */
  20352. render(): number;
  20353. /**
  20354. * Disposes the particle system and free the associated resources
  20355. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20356. */
  20357. dispose(disposeTexture?: boolean): void;
  20358. /**
  20359. * Clones the particle system.
  20360. * @param name The name of the cloned object
  20361. * @param newEmitter The new emitter to use
  20362. * @returns the cloned particle system
  20363. */
  20364. clone(name: string, newEmitter: any): ParticleSystem;
  20365. /**
  20366. * Serializes the particle system to a JSON object.
  20367. * @returns the JSON object
  20368. */
  20369. serialize(): any;
  20370. /** @hidden */
  20371. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20372. /** @hidden */
  20373. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20374. /**
  20375. * Parses a JSON object to create a particle system.
  20376. * @param parsedParticleSystem The JSON object to parse
  20377. * @param scene The scene to create the particle system in
  20378. * @param rootUrl The root url to use to load external dependencies like texture
  20379. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20380. * @returns the Parsed particle system
  20381. */
  20382. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20383. }
  20384. }
  20385. declare module "babylonjs/Particles/particle" {
  20386. import { Nullable } from "babylonjs/types";
  20387. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20388. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20389. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20390. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20391. /**
  20392. * A particle represents one of the element emitted by a particle system.
  20393. * This is mainly define by its coordinates, direction, velocity and age.
  20394. */
  20395. export class Particle {
  20396. /**
  20397. * The particle system the particle belongs to.
  20398. */
  20399. particleSystem: ParticleSystem;
  20400. private static _Count;
  20401. /**
  20402. * Unique ID of the particle
  20403. */
  20404. id: number;
  20405. /**
  20406. * The world position of the particle in the scene.
  20407. */
  20408. position: Vector3;
  20409. /**
  20410. * The world direction of the particle in the scene.
  20411. */
  20412. direction: Vector3;
  20413. /**
  20414. * The color of the particle.
  20415. */
  20416. color: Color4;
  20417. /**
  20418. * The color change of the particle per step.
  20419. */
  20420. colorStep: Color4;
  20421. /**
  20422. * Defines how long will the life of the particle be.
  20423. */
  20424. lifeTime: number;
  20425. /**
  20426. * The current age of the particle.
  20427. */
  20428. age: number;
  20429. /**
  20430. * The current size of the particle.
  20431. */
  20432. size: number;
  20433. /**
  20434. * The current scale of the particle.
  20435. */
  20436. scale: Vector2;
  20437. /**
  20438. * The current angle of the particle.
  20439. */
  20440. angle: number;
  20441. /**
  20442. * Defines how fast is the angle changing.
  20443. */
  20444. angularSpeed: number;
  20445. /**
  20446. * Defines the cell index used by the particle to be rendered from a sprite.
  20447. */
  20448. cellIndex: number;
  20449. /**
  20450. * The information required to support color remapping
  20451. */
  20452. remapData: Vector4;
  20453. /** @hidden */
  20454. _randomCellOffset?: number;
  20455. /** @hidden */
  20456. _initialDirection: Nullable<Vector3>;
  20457. /** @hidden */
  20458. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20459. /** @hidden */
  20460. _initialStartSpriteCellID: number;
  20461. /** @hidden */
  20462. _initialEndSpriteCellID: number;
  20463. /** @hidden */
  20464. _currentColorGradient: Nullable<ColorGradient>;
  20465. /** @hidden */
  20466. _currentColor1: Color4;
  20467. /** @hidden */
  20468. _currentColor2: Color4;
  20469. /** @hidden */
  20470. _currentSizeGradient: Nullable<FactorGradient>;
  20471. /** @hidden */
  20472. _currentSize1: number;
  20473. /** @hidden */
  20474. _currentSize2: number;
  20475. /** @hidden */
  20476. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20477. /** @hidden */
  20478. _currentAngularSpeed1: number;
  20479. /** @hidden */
  20480. _currentAngularSpeed2: number;
  20481. /** @hidden */
  20482. _currentVelocityGradient: Nullable<FactorGradient>;
  20483. /** @hidden */
  20484. _currentVelocity1: number;
  20485. /** @hidden */
  20486. _currentVelocity2: number;
  20487. /** @hidden */
  20488. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20489. /** @hidden */
  20490. _currentLimitVelocity1: number;
  20491. /** @hidden */
  20492. _currentLimitVelocity2: number;
  20493. /** @hidden */
  20494. _currentDragGradient: Nullable<FactorGradient>;
  20495. /** @hidden */
  20496. _currentDrag1: number;
  20497. /** @hidden */
  20498. _currentDrag2: number;
  20499. /** @hidden */
  20500. _randomNoiseCoordinates1: Vector3;
  20501. /** @hidden */
  20502. _randomNoiseCoordinates2: Vector3;
  20503. /**
  20504. * Creates a new instance Particle
  20505. * @param particleSystem the particle system the particle belongs to
  20506. */
  20507. constructor(
  20508. /**
  20509. * The particle system the particle belongs to.
  20510. */
  20511. particleSystem: ParticleSystem);
  20512. private updateCellInfoFromSystem;
  20513. /**
  20514. * Defines how the sprite cell index is updated for the particle
  20515. */
  20516. updateCellIndex(): void;
  20517. /** @hidden */
  20518. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20519. /** @hidden */
  20520. _inheritParticleInfoToSubEmitters(): void;
  20521. /** @hidden */
  20522. _reset(): void;
  20523. /**
  20524. * Copy the properties of particle to another one.
  20525. * @param other the particle to copy the information to.
  20526. */
  20527. copyTo(other: Particle): void;
  20528. }
  20529. }
  20530. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20531. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20532. import { Effect } from "babylonjs/Materials/effect";
  20533. import { Particle } from "babylonjs/Particles/particle";
  20534. /**
  20535. * Particle emitter represents a volume emitting particles.
  20536. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20537. */
  20538. export interface IParticleEmitterType {
  20539. /**
  20540. * Called by the particle System when the direction is computed for the created particle.
  20541. * @param worldMatrix is the world matrix of the particle system
  20542. * @param directionToUpdate is the direction vector to update with the result
  20543. * @param particle is the particle we are computed the direction for
  20544. */
  20545. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20546. /**
  20547. * Called by the particle System when the position is computed for the created particle.
  20548. * @param worldMatrix is the world matrix of the particle system
  20549. * @param positionToUpdate is the position vector to update with the result
  20550. * @param particle is the particle we are computed the position for
  20551. */
  20552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20553. /**
  20554. * Clones the current emitter and returns a copy of it
  20555. * @returns the new emitter
  20556. */
  20557. clone(): IParticleEmitterType;
  20558. /**
  20559. * Called by the GPUParticleSystem to setup the update shader
  20560. * @param effect defines the update shader
  20561. */
  20562. applyToShader(effect: Effect): void;
  20563. /**
  20564. * Returns a string to use to update the GPU particles update shader
  20565. * @returns the effect defines string
  20566. */
  20567. getEffectDefines(): string;
  20568. /**
  20569. * Returns a string representing the class name
  20570. * @returns a string containing the class name
  20571. */
  20572. getClassName(): string;
  20573. /**
  20574. * Serializes the particle system to a JSON object.
  20575. * @returns the JSON object
  20576. */
  20577. serialize(): any;
  20578. /**
  20579. * Parse properties from a JSON object
  20580. * @param serializationObject defines the JSON object
  20581. */
  20582. parse(serializationObject: any): void;
  20583. }
  20584. }
  20585. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20586. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20587. import { Effect } from "babylonjs/Materials/effect";
  20588. import { Particle } from "babylonjs/Particles/particle";
  20589. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20590. /**
  20591. * Particle emitter emitting particles from the inside of a box.
  20592. * It emits the particles randomly between 2 given directions.
  20593. */
  20594. export class BoxParticleEmitter implements IParticleEmitterType {
  20595. /**
  20596. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20597. */
  20598. direction1: Vector3;
  20599. /**
  20600. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20601. */
  20602. direction2: Vector3;
  20603. /**
  20604. * 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.
  20605. */
  20606. minEmitBox: Vector3;
  20607. /**
  20608. * 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.
  20609. */
  20610. maxEmitBox: Vector3;
  20611. /**
  20612. * Creates a new instance BoxParticleEmitter
  20613. */
  20614. constructor();
  20615. /**
  20616. * Called by the particle System when the direction is computed for the created particle.
  20617. * @param worldMatrix is the world matrix of the particle system
  20618. * @param directionToUpdate is the direction vector to update with the result
  20619. * @param particle is the particle we are computed the direction for
  20620. */
  20621. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20622. /**
  20623. * Called by the particle System when the position is computed for the created particle.
  20624. * @param worldMatrix is the world matrix of the particle system
  20625. * @param positionToUpdate is the position vector to update with the result
  20626. * @param particle is the particle we are computed the position for
  20627. */
  20628. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20629. /**
  20630. * Clones the current emitter and returns a copy of it
  20631. * @returns the new emitter
  20632. */
  20633. clone(): BoxParticleEmitter;
  20634. /**
  20635. * Called by the GPUParticleSystem to setup the update shader
  20636. * @param effect defines the update shader
  20637. */
  20638. applyToShader(effect: Effect): void;
  20639. /**
  20640. * Returns a string to use to update the GPU particles update shader
  20641. * @returns a string containng the defines string
  20642. */
  20643. getEffectDefines(): string;
  20644. /**
  20645. * Returns the string "BoxParticleEmitter"
  20646. * @returns a string containing the class name
  20647. */
  20648. getClassName(): string;
  20649. /**
  20650. * Serializes the particle system to a JSON object.
  20651. * @returns the JSON object
  20652. */
  20653. serialize(): any;
  20654. /**
  20655. * Parse properties from a JSON object
  20656. * @param serializationObject defines the JSON object
  20657. */
  20658. parse(serializationObject: any): void;
  20659. }
  20660. }
  20661. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20662. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20663. import { Effect } from "babylonjs/Materials/effect";
  20664. import { Particle } from "babylonjs/Particles/particle";
  20665. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20666. /**
  20667. * Particle emitter emitting particles from the inside of a cone.
  20668. * It emits the particles alongside the cone volume from the base to the particle.
  20669. * The emission direction might be randomized.
  20670. */
  20671. export class ConeParticleEmitter implements IParticleEmitterType {
  20672. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20673. directionRandomizer: number;
  20674. private _radius;
  20675. private _angle;
  20676. private _height;
  20677. /**
  20678. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20679. */
  20680. radiusRange: number;
  20681. /**
  20682. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20683. */
  20684. heightRange: number;
  20685. /**
  20686. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20687. */
  20688. emitFromSpawnPointOnly: boolean;
  20689. /**
  20690. * Gets or sets the radius of the emission cone
  20691. */
  20692. radius: number;
  20693. /**
  20694. * Gets or sets the angle of the emission cone
  20695. */
  20696. angle: number;
  20697. private _buildHeight;
  20698. /**
  20699. * Creates a new instance ConeParticleEmitter
  20700. * @param radius the radius of the emission cone (1 by default)
  20701. * @param angle the cone base angle (PI by default)
  20702. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20703. */
  20704. constructor(radius?: number, angle?: number,
  20705. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20706. directionRandomizer?: number);
  20707. /**
  20708. * Called by the particle System when the direction is computed for the created particle.
  20709. * @param worldMatrix is the world matrix of the particle system
  20710. * @param directionToUpdate is the direction vector to update with the result
  20711. * @param particle is the particle we are computed the direction for
  20712. */
  20713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20714. /**
  20715. * Called by the particle System when the position is computed for the created particle.
  20716. * @param worldMatrix is the world matrix of the particle system
  20717. * @param positionToUpdate is the position vector to update with the result
  20718. * @param particle is the particle we are computed the position for
  20719. */
  20720. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20721. /**
  20722. * Clones the current emitter and returns a copy of it
  20723. * @returns the new emitter
  20724. */
  20725. clone(): ConeParticleEmitter;
  20726. /**
  20727. * Called by the GPUParticleSystem to setup the update shader
  20728. * @param effect defines the update shader
  20729. */
  20730. applyToShader(effect: Effect): void;
  20731. /**
  20732. * Returns a string to use to update the GPU particles update shader
  20733. * @returns a string containng the defines string
  20734. */
  20735. getEffectDefines(): string;
  20736. /**
  20737. * Returns the string "ConeParticleEmitter"
  20738. * @returns a string containing the class name
  20739. */
  20740. getClassName(): string;
  20741. /**
  20742. * Serializes the particle system to a JSON object.
  20743. * @returns the JSON object
  20744. */
  20745. serialize(): any;
  20746. /**
  20747. * Parse properties from a JSON object
  20748. * @param serializationObject defines the JSON object
  20749. */
  20750. parse(serializationObject: any): void;
  20751. }
  20752. }
  20753. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20754. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20755. import { Effect } from "babylonjs/Materials/effect";
  20756. import { Particle } from "babylonjs/Particles/particle";
  20757. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20758. /**
  20759. * Particle emitter emitting particles from the inside of a cylinder.
  20760. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20761. */
  20762. export class CylinderParticleEmitter implements IParticleEmitterType {
  20763. /**
  20764. * The radius of the emission cylinder.
  20765. */
  20766. radius: number;
  20767. /**
  20768. * The height of the emission cylinder.
  20769. */
  20770. height: number;
  20771. /**
  20772. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20773. */
  20774. radiusRange: number;
  20775. /**
  20776. * How much to randomize the particle direction [0-1].
  20777. */
  20778. directionRandomizer: number;
  20779. /**
  20780. * Creates a new instance CylinderParticleEmitter
  20781. * @param radius the radius of the emission cylinder (1 by default)
  20782. * @param height the height of the emission cylinder (1 by default)
  20783. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20784. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20785. */
  20786. constructor(
  20787. /**
  20788. * The radius of the emission cylinder.
  20789. */
  20790. radius?: number,
  20791. /**
  20792. * The height of the emission cylinder.
  20793. */
  20794. height?: number,
  20795. /**
  20796. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20797. */
  20798. radiusRange?: number,
  20799. /**
  20800. * How much to randomize the particle direction [0-1].
  20801. */
  20802. directionRandomizer?: number);
  20803. /**
  20804. * Called by the particle System when the direction is computed for the created particle.
  20805. * @param worldMatrix is the world matrix of the particle system
  20806. * @param directionToUpdate is the direction vector to update with the result
  20807. * @param particle is the particle we are computed the direction for
  20808. */
  20809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20810. /**
  20811. * Called by the particle System when the position is computed for the created particle.
  20812. * @param worldMatrix is the world matrix of the particle system
  20813. * @param positionToUpdate is the position vector to update with the result
  20814. * @param particle is the particle we are computed the position for
  20815. */
  20816. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20817. /**
  20818. * Clones the current emitter and returns a copy of it
  20819. * @returns the new emitter
  20820. */
  20821. clone(): CylinderParticleEmitter;
  20822. /**
  20823. * Called by the GPUParticleSystem to setup the update shader
  20824. * @param effect defines the update shader
  20825. */
  20826. applyToShader(effect: Effect): void;
  20827. /**
  20828. * Returns a string to use to update the GPU particles update shader
  20829. * @returns a string containng the defines string
  20830. */
  20831. getEffectDefines(): string;
  20832. /**
  20833. * Returns the string "CylinderParticleEmitter"
  20834. * @returns a string containing the class name
  20835. */
  20836. getClassName(): string;
  20837. /**
  20838. * Serializes the particle system to a JSON object.
  20839. * @returns the JSON object
  20840. */
  20841. serialize(): any;
  20842. /**
  20843. * Parse properties from a JSON object
  20844. * @param serializationObject defines the JSON object
  20845. */
  20846. parse(serializationObject: any): void;
  20847. }
  20848. /**
  20849. * Particle emitter emitting particles from the inside of a cylinder.
  20850. * It emits the particles randomly between two vectors.
  20851. */
  20852. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20853. /**
  20854. * The min limit of the emission direction.
  20855. */
  20856. direction1: Vector3;
  20857. /**
  20858. * The max limit of the emission direction.
  20859. */
  20860. direction2: Vector3;
  20861. /**
  20862. * Creates a new instance CylinderDirectedParticleEmitter
  20863. * @param radius the radius of the emission cylinder (1 by default)
  20864. * @param height the height of the emission cylinder (1 by default)
  20865. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20866. * @param direction1 the min limit of the emission direction (up vector by default)
  20867. * @param direction2 the max limit of the emission direction (up vector by default)
  20868. */
  20869. constructor(radius?: number, height?: number, radiusRange?: number,
  20870. /**
  20871. * The min limit of the emission direction.
  20872. */
  20873. direction1?: Vector3,
  20874. /**
  20875. * The max limit of the emission direction.
  20876. */
  20877. direction2?: Vector3);
  20878. /**
  20879. * Called by the particle System when the direction is computed for the created particle.
  20880. * @param worldMatrix is the world matrix of the particle system
  20881. * @param directionToUpdate is the direction vector to update with the result
  20882. * @param particle is the particle we are computed the direction for
  20883. */
  20884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20885. /**
  20886. * Clones the current emitter and returns a copy of it
  20887. * @returns the new emitter
  20888. */
  20889. clone(): CylinderDirectedParticleEmitter;
  20890. /**
  20891. * Called by the GPUParticleSystem to setup the update shader
  20892. * @param effect defines the update shader
  20893. */
  20894. applyToShader(effect: Effect): void;
  20895. /**
  20896. * Returns a string to use to update the GPU particles update shader
  20897. * @returns a string containng the defines string
  20898. */
  20899. getEffectDefines(): string;
  20900. /**
  20901. * Returns the string "CylinderDirectedParticleEmitter"
  20902. * @returns a string containing the class name
  20903. */
  20904. getClassName(): string;
  20905. /**
  20906. * Serializes the particle system to a JSON object.
  20907. * @returns the JSON object
  20908. */
  20909. serialize(): any;
  20910. /**
  20911. * Parse properties from a JSON object
  20912. * @param serializationObject defines the JSON object
  20913. */
  20914. parse(serializationObject: any): void;
  20915. }
  20916. }
  20917. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  20918. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20919. import { Effect } from "babylonjs/Materials/effect";
  20920. import { Particle } from "babylonjs/Particles/particle";
  20921. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20922. /**
  20923. * Particle emitter emitting particles from the inside of a hemisphere.
  20924. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20925. */
  20926. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20927. /**
  20928. * The radius of the emission hemisphere.
  20929. */
  20930. radius: number;
  20931. /**
  20932. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20933. */
  20934. radiusRange: number;
  20935. /**
  20936. * How much to randomize the particle direction [0-1].
  20937. */
  20938. directionRandomizer: number;
  20939. /**
  20940. * Creates a new instance HemisphericParticleEmitter
  20941. * @param radius the radius of the emission hemisphere (1 by default)
  20942. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20943. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20944. */
  20945. constructor(
  20946. /**
  20947. * The radius of the emission hemisphere.
  20948. */
  20949. radius?: number,
  20950. /**
  20951. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20952. */
  20953. radiusRange?: number,
  20954. /**
  20955. * How much to randomize the particle direction [0-1].
  20956. */
  20957. directionRandomizer?: number);
  20958. /**
  20959. * Called by the particle System when the direction is computed for the created particle.
  20960. * @param worldMatrix is the world matrix of the particle system
  20961. * @param directionToUpdate is the direction vector to update with the result
  20962. * @param particle is the particle we are computed the direction for
  20963. */
  20964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20965. /**
  20966. * Called by the particle System when the position is computed for the created particle.
  20967. * @param worldMatrix is the world matrix of the particle system
  20968. * @param positionToUpdate is the position vector to update with the result
  20969. * @param particle is the particle we are computed the position for
  20970. */
  20971. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20972. /**
  20973. * Clones the current emitter and returns a copy of it
  20974. * @returns the new emitter
  20975. */
  20976. clone(): HemisphericParticleEmitter;
  20977. /**
  20978. * Called by the GPUParticleSystem to setup the update shader
  20979. * @param effect defines the update shader
  20980. */
  20981. applyToShader(effect: Effect): void;
  20982. /**
  20983. * Returns a string to use to update the GPU particles update shader
  20984. * @returns a string containng the defines string
  20985. */
  20986. getEffectDefines(): string;
  20987. /**
  20988. * Returns the string "HemisphericParticleEmitter"
  20989. * @returns a string containing the class name
  20990. */
  20991. getClassName(): string;
  20992. /**
  20993. * Serializes the particle system to a JSON object.
  20994. * @returns the JSON object
  20995. */
  20996. serialize(): any;
  20997. /**
  20998. * Parse properties from a JSON object
  20999. * @param serializationObject defines the JSON object
  21000. */
  21001. parse(serializationObject: any): void;
  21002. }
  21003. }
  21004. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21005. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21006. import { Effect } from "babylonjs/Materials/effect";
  21007. import { Particle } from "babylonjs/Particles/particle";
  21008. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21009. /**
  21010. * Particle emitter emitting particles from a point.
  21011. * It emits the particles randomly between 2 given directions.
  21012. */
  21013. export class PointParticleEmitter implements IParticleEmitterType {
  21014. /**
  21015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21016. */
  21017. direction1: Vector3;
  21018. /**
  21019. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21020. */
  21021. direction2: Vector3;
  21022. /**
  21023. * Creates a new instance PointParticleEmitter
  21024. */
  21025. constructor();
  21026. /**
  21027. * Called by the particle System when the direction is computed for the created particle.
  21028. * @param worldMatrix is the world matrix of the particle system
  21029. * @param directionToUpdate is the direction vector to update with the result
  21030. * @param particle is the particle we are computed the direction for
  21031. */
  21032. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21033. /**
  21034. * Called by the particle System when the position is computed for the created particle.
  21035. * @param worldMatrix is the world matrix of the particle system
  21036. * @param positionToUpdate is the position vector to update with the result
  21037. * @param particle is the particle we are computed the position for
  21038. */
  21039. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21040. /**
  21041. * Clones the current emitter and returns a copy of it
  21042. * @returns the new emitter
  21043. */
  21044. clone(): PointParticleEmitter;
  21045. /**
  21046. * Called by the GPUParticleSystem to setup the update shader
  21047. * @param effect defines the update shader
  21048. */
  21049. applyToShader(effect: Effect): void;
  21050. /**
  21051. * Returns a string to use to update the GPU particles update shader
  21052. * @returns a string containng the defines string
  21053. */
  21054. getEffectDefines(): string;
  21055. /**
  21056. * Returns the string "PointParticleEmitter"
  21057. * @returns a string containing the class name
  21058. */
  21059. getClassName(): string;
  21060. /**
  21061. * Serializes the particle system to a JSON object.
  21062. * @returns the JSON object
  21063. */
  21064. serialize(): any;
  21065. /**
  21066. * Parse properties from a JSON object
  21067. * @param serializationObject defines the JSON object
  21068. */
  21069. parse(serializationObject: any): void;
  21070. }
  21071. }
  21072. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21073. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21074. import { Effect } from "babylonjs/Materials/effect";
  21075. import { Particle } from "babylonjs/Particles/particle";
  21076. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21077. /**
  21078. * Particle emitter emitting particles from the inside of a sphere.
  21079. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21080. */
  21081. export class SphereParticleEmitter implements IParticleEmitterType {
  21082. /**
  21083. * The radius of the emission sphere.
  21084. */
  21085. radius: number;
  21086. /**
  21087. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21088. */
  21089. radiusRange: number;
  21090. /**
  21091. * How much to randomize the particle direction [0-1].
  21092. */
  21093. directionRandomizer: number;
  21094. /**
  21095. * Creates a new instance SphereParticleEmitter
  21096. * @param radius the radius of the emission sphere (1 by default)
  21097. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21098. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21099. */
  21100. constructor(
  21101. /**
  21102. * The radius of the emission sphere.
  21103. */
  21104. radius?: number,
  21105. /**
  21106. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21107. */
  21108. radiusRange?: number,
  21109. /**
  21110. * How much to randomize the particle direction [0-1].
  21111. */
  21112. directionRandomizer?: number);
  21113. /**
  21114. * Called by the particle System when the direction is computed for the created particle.
  21115. * @param worldMatrix is the world matrix of the particle system
  21116. * @param directionToUpdate is the direction vector to update with the result
  21117. * @param particle is the particle we are computed the direction for
  21118. */
  21119. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21120. /**
  21121. * Called by the particle System when the position is computed for the created particle.
  21122. * @param worldMatrix is the world matrix of the particle system
  21123. * @param positionToUpdate is the position vector to update with the result
  21124. * @param particle is the particle we are computed the position for
  21125. */
  21126. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21127. /**
  21128. * Clones the current emitter and returns a copy of it
  21129. * @returns the new emitter
  21130. */
  21131. clone(): SphereParticleEmitter;
  21132. /**
  21133. * Called by the GPUParticleSystem to setup the update shader
  21134. * @param effect defines the update shader
  21135. */
  21136. applyToShader(effect: Effect): void;
  21137. /**
  21138. * Returns a string to use to update the GPU particles update shader
  21139. * @returns a string containng the defines string
  21140. */
  21141. getEffectDefines(): string;
  21142. /**
  21143. * Returns the string "SphereParticleEmitter"
  21144. * @returns a string containing the class name
  21145. */
  21146. getClassName(): string;
  21147. /**
  21148. * Serializes the particle system to a JSON object.
  21149. * @returns the JSON object
  21150. */
  21151. serialize(): any;
  21152. /**
  21153. * Parse properties from a JSON object
  21154. * @param serializationObject defines the JSON object
  21155. */
  21156. parse(serializationObject: any): void;
  21157. }
  21158. /**
  21159. * Particle emitter emitting particles from the inside of a sphere.
  21160. * It emits the particles randomly between two vectors.
  21161. */
  21162. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21163. /**
  21164. * The min limit of the emission direction.
  21165. */
  21166. direction1: Vector3;
  21167. /**
  21168. * The max limit of the emission direction.
  21169. */
  21170. direction2: Vector3;
  21171. /**
  21172. * Creates a new instance SphereDirectedParticleEmitter
  21173. * @param radius the radius of the emission sphere (1 by default)
  21174. * @param direction1 the min limit of the emission direction (up vector by default)
  21175. * @param direction2 the max limit of the emission direction (up vector by default)
  21176. */
  21177. constructor(radius?: number,
  21178. /**
  21179. * The min limit of the emission direction.
  21180. */
  21181. direction1?: Vector3,
  21182. /**
  21183. * The max limit of the emission direction.
  21184. */
  21185. direction2?: Vector3);
  21186. /**
  21187. * Called by the particle System when the direction is computed for the created particle.
  21188. * @param worldMatrix is the world matrix of the particle system
  21189. * @param directionToUpdate is the direction vector to update with the result
  21190. * @param particle is the particle we are computed the direction for
  21191. */
  21192. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21193. /**
  21194. * Clones the current emitter and returns a copy of it
  21195. * @returns the new emitter
  21196. */
  21197. clone(): SphereDirectedParticleEmitter;
  21198. /**
  21199. * Called by the GPUParticleSystem to setup the update shader
  21200. * @param effect defines the update shader
  21201. */
  21202. applyToShader(effect: Effect): void;
  21203. /**
  21204. * Returns a string to use to update the GPU particles update shader
  21205. * @returns a string containng the defines string
  21206. */
  21207. getEffectDefines(): string;
  21208. /**
  21209. * Returns the string "SphereDirectedParticleEmitter"
  21210. * @returns a string containing the class name
  21211. */
  21212. getClassName(): string;
  21213. /**
  21214. * Serializes the particle system to a JSON object.
  21215. * @returns the JSON object
  21216. */
  21217. serialize(): any;
  21218. /**
  21219. * Parse properties from a JSON object
  21220. * @param serializationObject defines the JSON object
  21221. */
  21222. parse(serializationObject: any): void;
  21223. }
  21224. }
  21225. declare module "babylonjs/Particles/EmitterTypes/index" {
  21226. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21227. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21228. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21229. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21230. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21231. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21232. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21233. }
  21234. declare module "babylonjs/Particles/IParticleSystem" {
  21235. import { Nullable } from "babylonjs/types";
  21236. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21239. import { Texture } from "babylonjs/Materials/Textures/texture";
  21240. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21241. import { Scene } from "babylonjs/scene";
  21242. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21243. import { Animation } from "babylonjs/Animations/animation";
  21244. /**
  21245. * Interface representing a particle system in Babylon.js.
  21246. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21247. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21248. */
  21249. export interface IParticleSystem {
  21250. /**
  21251. * List of animations used by the particle system.
  21252. */
  21253. animations: Animation[];
  21254. /**
  21255. * The id of the Particle system.
  21256. */
  21257. id: string;
  21258. /**
  21259. * The name of the Particle system.
  21260. */
  21261. name: string;
  21262. /**
  21263. * The emitter represents the Mesh or position we are attaching the particle system to.
  21264. */
  21265. emitter: Nullable<AbstractMesh | Vector3>;
  21266. /**
  21267. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21268. */
  21269. isBillboardBased: boolean;
  21270. /**
  21271. * The rendering group used by the Particle system to chose when to render.
  21272. */
  21273. renderingGroupId: number;
  21274. /**
  21275. * The layer mask we are rendering the particles through.
  21276. */
  21277. layerMask: number;
  21278. /**
  21279. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21280. */
  21281. updateSpeed: number;
  21282. /**
  21283. * The amount of time the particle system is running (depends of the overall update speed).
  21284. */
  21285. targetStopDuration: number;
  21286. /**
  21287. * The texture used to render each particle. (this can be a spritesheet)
  21288. */
  21289. particleTexture: Nullable<Texture>;
  21290. /**
  21291. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21292. */
  21293. blendMode: number;
  21294. /**
  21295. * Minimum life time of emitting particles.
  21296. */
  21297. minLifeTime: number;
  21298. /**
  21299. * Maximum life time of emitting particles.
  21300. */
  21301. maxLifeTime: number;
  21302. /**
  21303. * Minimum Size of emitting particles.
  21304. */
  21305. minSize: number;
  21306. /**
  21307. * Maximum Size of emitting particles.
  21308. */
  21309. maxSize: number;
  21310. /**
  21311. * Minimum scale of emitting particles on X axis.
  21312. */
  21313. minScaleX: number;
  21314. /**
  21315. * Maximum scale of emitting particles on X axis.
  21316. */
  21317. maxScaleX: number;
  21318. /**
  21319. * Minimum scale of emitting particles on Y axis.
  21320. */
  21321. minScaleY: number;
  21322. /**
  21323. * Maximum scale of emitting particles on Y axis.
  21324. */
  21325. maxScaleY: number;
  21326. /**
  21327. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21328. */
  21329. color1: Color4;
  21330. /**
  21331. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21332. */
  21333. color2: Color4;
  21334. /**
  21335. * Color the particle will have at the end of its lifetime.
  21336. */
  21337. colorDead: Color4;
  21338. /**
  21339. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21340. */
  21341. emitRate: number;
  21342. /**
  21343. * You can use gravity if you want to give an orientation to your particles.
  21344. */
  21345. gravity: Vector3;
  21346. /**
  21347. * Minimum power of emitting particles.
  21348. */
  21349. minEmitPower: number;
  21350. /**
  21351. * Maximum power of emitting particles.
  21352. */
  21353. maxEmitPower: number;
  21354. /**
  21355. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21356. */
  21357. minAngularSpeed: number;
  21358. /**
  21359. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21360. */
  21361. maxAngularSpeed: number;
  21362. /**
  21363. * Gets or sets the minimal initial rotation in radians.
  21364. */
  21365. minInitialRotation: number;
  21366. /**
  21367. * Gets or sets the maximal initial rotation in radians.
  21368. */
  21369. maxInitialRotation: number;
  21370. /**
  21371. * The particle emitter type defines the emitter used by the particle system.
  21372. * It can be for example box, sphere, or cone...
  21373. */
  21374. particleEmitterType: Nullable<IParticleEmitterType>;
  21375. /**
  21376. * Defines the delay in milliseconds before starting the system (0 by default)
  21377. */
  21378. startDelay: number;
  21379. /**
  21380. * 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
  21381. */
  21382. preWarmCycles: number;
  21383. /**
  21384. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21385. */
  21386. preWarmStepOffset: number;
  21387. /**
  21388. * 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)
  21389. */
  21390. spriteCellChangeSpeed: number;
  21391. /**
  21392. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21393. */
  21394. startSpriteCellID: number;
  21395. /**
  21396. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21397. */
  21398. endSpriteCellID: number;
  21399. /**
  21400. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21401. */
  21402. spriteCellWidth: number;
  21403. /**
  21404. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21405. */
  21406. spriteCellHeight: number;
  21407. /**
  21408. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21409. */
  21410. spriteRandomStartCell: boolean;
  21411. /**
  21412. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21413. */
  21414. isAnimationSheetEnabled: boolean;
  21415. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21416. translationPivot: Vector2;
  21417. /**
  21418. * Gets or sets a texture used to add random noise to particle positions
  21419. */
  21420. noiseTexture: Nullable<BaseTexture>;
  21421. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21422. noiseStrength: Vector3;
  21423. /**
  21424. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21425. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21426. */
  21427. billboardMode: number;
  21428. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21429. limitVelocityDamping: number;
  21430. /**
  21431. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21432. */
  21433. beginAnimationOnStart: boolean;
  21434. /**
  21435. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21436. */
  21437. beginAnimationFrom: number;
  21438. /**
  21439. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21440. */
  21441. beginAnimationTo: number;
  21442. /**
  21443. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21444. */
  21445. beginAnimationLoop: boolean;
  21446. /**
  21447. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21448. */
  21449. disposeOnStop: boolean;
  21450. /**
  21451. * Gets the maximum number of particles active at the same time.
  21452. * @returns The max number of active particles.
  21453. */
  21454. getCapacity(): number;
  21455. /**
  21456. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21457. * @returns True if it has been started, otherwise false.
  21458. */
  21459. isStarted(): boolean;
  21460. /**
  21461. * Animates the particle system for this frame.
  21462. */
  21463. animate(): void;
  21464. /**
  21465. * Renders the particle system in its current state.
  21466. * @returns the current number of particles
  21467. */
  21468. render(): number;
  21469. /**
  21470. * Dispose the particle system and frees its associated resources.
  21471. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21472. */
  21473. dispose(disposeTexture?: boolean): void;
  21474. /**
  21475. * Clones the particle system.
  21476. * @param name The name of the cloned object
  21477. * @param newEmitter The new emitter to use
  21478. * @returns the cloned particle system
  21479. */
  21480. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21481. /**
  21482. * Serializes the particle system to a JSON object.
  21483. * @returns the JSON object
  21484. */
  21485. serialize(): any;
  21486. /**
  21487. * Rebuild the particle system
  21488. */
  21489. rebuild(): void;
  21490. /**
  21491. * Starts the particle system and begins to emit
  21492. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21493. */
  21494. start(delay?: number): void;
  21495. /**
  21496. * Stops the particle system.
  21497. */
  21498. stop(): void;
  21499. /**
  21500. * Remove all active particles
  21501. */
  21502. reset(): void;
  21503. /**
  21504. * Is this system ready to be used/rendered
  21505. * @return true if the system is ready
  21506. */
  21507. isReady(): boolean;
  21508. /**
  21509. * Adds a new color gradient
  21510. * @param gradient defines the gradient to use (between 0 and 1)
  21511. * @param color1 defines the color to affect to the specified gradient
  21512. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21513. * @returns the current particle system
  21514. */
  21515. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21516. /**
  21517. * Remove a specific color gradient
  21518. * @param gradient defines the gradient to remove
  21519. * @returns the current particle system
  21520. */
  21521. removeColorGradient(gradient: number): IParticleSystem;
  21522. /**
  21523. * Adds a new size gradient
  21524. * @param gradient defines the gradient to use (between 0 and 1)
  21525. * @param factor defines the size factor to affect to the specified gradient
  21526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21527. * @returns the current particle system
  21528. */
  21529. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21530. /**
  21531. * Remove a specific size gradient
  21532. * @param gradient defines the gradient to remove
  21533. * @returns the current particle system
  21534. */
  21535. removeSizeGradient(gradient: number): IParticleSystem;
  21536. /**
  21537. * Gets the current list of color gradients.
  21538. * You must use addColorGradient and removeColorGradient to udpate this list
  21539. * @returns the list of color gradients
  21540. */
  21541. getColorGradients(): Nullable<Array<ColorGradient>>;
  21542. /**
  21543. * Gets the current list of size gradients.
  21544. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21545. * @returns the list of size gradients
  21546. */
  21547. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21548. /**
  21549. * Gets the current list of angular speed gradients.
  21550. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21551. * @returns the list of angular speed gradients
  21552. */
  21553. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21554. /**
  21555. * Adds a new angular speed gradient
  21556. * @param gradient defines the gradient to use (between 0 and 1)
  21557. * @param factor defines the angular speed to affect to the specified gradient
  21558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21559. * @returns the current particle system
  21560. */
  21561. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21562. /**
  21563. * Remove a specific angular speed gradient
  21564. * @param gradient defines the gradient to remove
  21565. * @returns the current particle system
  21566. */
  21567. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21568. /**
  21569. * Gets the current list of velocity gradients.
  21570. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21571. * @returns the list of velocity gradients
  21572. */
  21573. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21574. /**
  21575. * Adds a new velocity gradient
  21576. * @param gradient defines the gradient to use (between 0 and 1)
  21577. * @param factor defines the velocity to affect to the specified gradient
  21578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21579. * @returns the current particle system
  21580. */
  21581. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21582. /**
  21583. * Remove a specific velocity gradient
  21584. * @param gradient defines the gradient to remove
  21585. * @returns the current particle system
  21586. */
  21587. removeVelocityGradient(gradient: number): IParticleSystem;
  21588. /**
  21589. * Gets the current list of limit velocity gradients.
  21590. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21591. * @returns the list of limit velocity gradients
  21592. */
  21593. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21594. /**
  21595. * Adds a new limit velocity gradient
  21596. * @param gradient defines the gradient to use (between 0 and 1)
  21597. * @param factor defines the limit velocity to affect to the specified gradient
  21598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21599. * @returns the current particle system
  21600. */
  21601. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21602. /**
  21603. * Remove a specific limit velocity gradient
  21604. * @param gradient defines the gradient to remove
  21605. * @returns the current particle system
  21606. */
  21607. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21608. /**
  21609. * Adds a new drag gradient
  21610. * @param gradient defines the gradient to use (between 0 and 1)
  21611. * @param factor defines the drag to affect to the specified gradient
  21612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21613. * @returns the current particle system
  21614. */
  21615. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21616. /**
  21617. * Remove a specific drag gradient
  21618. * @param gradient defines the gradient to remove
  21619. * @returns the current particle system
  21620. */
  21621. removeDragGradient(gradient: number): IParticleSystem;
  21622. /**
  21623. * Gets the current list of drag gradients.
  21624. * You must use addDragGradient and removeDragGradient to udpate this list
  21625. * @returns the list of drag gradients
  21626. */
  21627. getDragGradients(): Nullable<Array<FactorGradient>>;
  21628. /**
  21629. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21630. * @param gradient defines the gradient to use (between 0 and 1)
  21631. * @param factor defines the emit rate to affect to the specified gradient
  21632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21633. * @returns the current particle system
  21634. */
  21635. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21636. /**
  21637. * Remove a specific emit rate gradient
  21638. * @param gradient defines the gradient to remove
  21639. * @returns the current particle system
  21640. */
  21641. removeEmitRateGradient(gradient: number): IParticleSystem;
  21642. /**
  21643. * Gets the current list of emit rate gradients.
  21644. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21645. * @returns the list of emit rate gradients
  21646. */
  21647. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21648. /**
  21649. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21650. * @param gradient defines the gradient to use (between 0 and 1)
  21651. * @param factor defines the start size to affect to the specified gradient
  21652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21653. * @returns the current particle system
  21654. */
  21655. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21656. /**
  21657. * Remove a specific start size gradient
  21658. * @param gradient defines the gradient to remove
  21659. * @returns the current particle system
  21660. */
  21661. removeStartSizeGradient(gradient: number): IParticleSystem;
  21662. /**
  21663. * Gets the current list of start size gradients.
  21664. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21665. * @returns the list of start size gradients
  21666. */
  21667. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21668. /**
  21669. * Adds a new life time gradient
  21670. * @param gradient defines the gradient to use (between 0 and 1)
  21671. * @param factor defines the life time factor to affect to the specified gradient
  21672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21673. * @returns the current particle system
  21674. */
  21675. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21676. /**
  21677. * Remove a specific life time gradient
  21678. * @param gradient defines the gradient to remove
  21679. * @returns the current particle system
  21680. */
  21681. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21682. /**
  21683. * Gets the current list of life time gradients.
  21684. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21685. * @returns the list of life time gradients
  21686. */
  21687. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21688. /**
  21689. * Gets the current list of color gradients.
  21690. * You must use addColorGradient and removeColorGradient to udpate this list
  21691. * @returns the list of color gradients
  21692. */
  21693. getColorGradients(): Nullable<Array<ColorGradient>>;
  21694. /**
  21695. * Adds a new ramp gradient used to remap particle colors
  21696. * @param gradient defines the gradient to use (between 0 and 1)
  21697. * @param color defines the color to affect to the specified gradient
  21698. * @returns the current particle system
  21699. */
  21700. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21701. /**
  21702. * Gets the current list of ramp gradients.
  21703. * You must use addRampGradient and removeRampGradient to udpate this list
  21704. * @returns the list of ramp gradients
  21705. */
  21706. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21707. /** Gets or sets a boolean indicating that ramp gradients must be used
  21708. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21709. */
  21710. useRampGradients: boolean;
  21711. /**
  21712. * Adds a new color remap gradient
  21713. * @param gradient defines the gradient to use (between 0 and 1)
  21714. * @param min defines the color remap minimal range
  21715. * @param max defines the color remap maximal range
  21716. * @returns the current particle system
  21717. */
  21718. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21719. /**
  21720. * Gets the current list of color remap gradients.
  21721. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21722. * @returns the list of color remap gradients
  21723. */
  21724. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21725. /**
  21726. * Adds a new alpha remap gradient
  21727. * @param gradient defines the gradient to use (between 0 and 1)
  21728. * @param min defines the alpha remap minimal range
  21729. * @param max defines the alpha remap maximal range
  21730. * @returns the current particle system
  21731. */
  21732. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21733. /**
  21734. * Gets the current list of alpha remap gradients.
  21735. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21736. * @returns the list of alpha remap gradients
  21737. */
  21738. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21739. /**
  21740. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21741. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21742. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21743. * @returns the emitter
  21744. */
  21745. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21746. /**
  21747. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21748. * @param radius The radius of the hemisphere to emit from
  21749. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21750. * @returns the emitter
  21751. */
  21752. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21753. /**
  21754. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21755. * @param radius The radius of the sphere to emit from
  21756. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21757. * @returns the emitter
  21758. */
  21759. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21760. /**
  21761. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21762. * @param radius The radius of the sphere to emit from
  21763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21765. * @returns the emitter
  21766. */
  21767. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21768. /**
  21769. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21770. * @param radius The radius of the emission cylinder
  21771. * @param height The height of the emission cylinder
  21772. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21773. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21774. * @returns the emitter
  21775. */
  21776. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21777. /**
  21778. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21779. * @param radius The radius of the cylinder to emit from
  21780. * @param height The height of the emission cylinder
  21781. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21782. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21783. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21784. * @returns the emitter
  21785. */
  21786. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21787. /**
  21788. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21789. * @param radius The radius of the cone to emit from
  21790. * @param angle The base angle of the cone
  21791. * @returns the emitter
  21792. */
  21793. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21794. /**
  21795. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21796. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21797. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21798. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21799. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21800. * @returns the emitter
  21801. */
  21802. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21803. /**
  21804. * Get hosting scene
  21805. * @returns the scene
  21806. */
  21807. getScene(): Scene;
  21808. }
  21809. }
  21810. declare module "babylonjs/Shaders/line.fragment" {
  21811. /** @hidden */
  21812. export var linePixelShader: {
  21813. name: string;
  21814. shader: string;
  21815. };
  21816. }
  21817. declare module "babylonjs/Shaders/line.vertex" {
  21818. /** @hidden */
  21819. export var lineVertexShader: {
  21820. name: string;
  21821. shader: string;
  21822. };
  21823. }
  21824. declare module "babylonjs/Rendering/edgesRenderer" {
  21825. import { Nullable } from "babylonjs/types";
  21826. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21828. import { Vector3 } from "babylonjs/Maths/math";
  21829. import { IDisposable } from "babylonjs/scene";
  21830. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21831. import "babylonjs/Shaders/line.fragment";
  21832. import "babylonjs/Shaders/line.vertex";
  21833. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21834. module "babylonjs/Meshes/abstractMesh" {
  21835. interface AbstractMesh {
  21836. /**
  21837. * Gets the edgesRenderer associated with the mesh
  21838. */
  21839. edgesRenderer: Nullable<EdgesRenderer>;
  21840. }
  21841. }
  21842. module "babylonjs/Meshes/linesMesh" {
  21843. interface LinesMesh {
  21844. /**
  21845. * Enables the edge rendering mode on the mesh.
  21846. * This mode makes the mesh edges visible
  21847. * @param epsilon defines the maximal distance between two angles to detect a face
  21848. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21849. * @returns the currentAbstractMesh
  21850. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21851. */
  21852. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21853. }
  21854. }
  21855. module "babylonjs/Meshes/linesMesh" {
  21856. interface InstancedLinesMesh {
  21857. /**
  21858. * Enables the edge rendering mode on the mesh.
  21859. * This mode makes the mesh edges visible
  21860. * @param epsilon defines the maximal distance between two angles to detect a face
  21861. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21862. * @returns the current InstancedLinesMesh
  21863. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21864. */
  21865. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21866. }
  21867. }
  21868. /**
  21869. * Defines the minimum contract an Edges renderer should follow.
  21870. */
  21871. export interface IEdgesRenderer extends IDisposable {
  21872. /**
  21873. * Gets or sets a boolean indicating if the edgesRenderer is active
  21874. */
  21875. isEnabled: boolean;
  21876. /**
  21877. * Renders the edges of the attached mesh,
  21878. */
  21879. render(): void;
  21880. /**
  21881. * Checks wether or not the edges renderer is ready to render.
  21882. * @return true if ready, otherwise false.
  21883. */
  21884. isReady(): boolean;
  21885. }
  21886. /**
  21887. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21888. */
  21889. export class EdgesRenderer implements IEdgesRenderer {
  21890. /**
  21891. * Define the size of the edges with an orthographic camera
  21892. */
  21893. edgesWidthScalerForOrthographic: number;
  21894. /**
  21895. * Define the size of the edges with a perspective camera
  21896. */
  21897. edgesWidthScalerForPerspective: number;
  21898. protected _source: AbstractMesh;
  21899. protected _linesPositions: number[];
  21900. protected _linesNormals: number[];
  21901. protected _linesIndices: number[];
  21902. protected _epsilon: number;
  21903. protected _indicesCount: number;
  21904. protected _lineShader: ShaderMaterial;
  21905. protected _ib: DataBuffer;
  21906. protected _buffers: {
  21907. [key: string]: Nullable<VertexBuffer>;
  21908. };
  21909. protected _checkVerticesInsteadOfIndices: boolean;
  21910. private _meshRebuildObserver;
  21911. private _meshDisposeObserver;
  21912. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21913. isEnabled: boolean;
  21914. /**
  21915. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21916. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21917. * @param source Mesh used to create edges
  21918. * @param epsilon sum of angles in adjacency to check for edge
  21919. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21920. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21921. */
  21922. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21923. protected _prepareRessources(): void;
  21924. /** @hidden */
  21925. _rebuild(): void;
  21926. /**
  21927. * Releases the required resources for the edges renderer
  21928. */
  21929. dispose(): void;
  21930. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21931. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21932. /**
  21933. * Checks if the pair of p0 and p1 is en edge
  21934. * @param faceIndex
  21935. * @param edge
  21936. * @param faceNormals
  21937. * @param p0
  21938. * @param p1
  21939. * @private
  21940. */
  21941. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21942. /**
  21943. * push line into the position, normal and index buffer
  21944. * @protected
  21945. */
  21946. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21947. /**
  21948. * Generates lines edges from adjacencjes
  21949. * @private
  21950. */
  21951. _generateEdgesLines(): void;
  21952. /**
  21953. * Checks wether or not the edges renderer is ready to render.
  21954. * @return true if ready, otherwise false.
  21955. */
  21956. isReady(): boolean;
  21957. /**
  21958. * Renders the edges of the attached mesh,
  21959. */
  21960. render(): void;
  21961. }
  21962. /**
  21963. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21964. */
  21965. export class LineEdgesRenderer extends EdgesRenderer {
  21966. /**
  21967. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21968. * @param source LineMesh used to generate edges
  21969. * @param epsilon not important (specified angle for edge detection)
  21970. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21971. */
  21972. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21973. /**
  21974. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21975. */
  21976. _generateEdgesLines(): void;
  21977. }
  21978. }
  21979. declare module "babylonjs/Rendering/renderingGroup" {
  21980. import { SmartArray } from "babylonjs/Misc/smartArray";
  21981. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21983. import { Nullable } from "babylonjs/types";
  21984. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  21985. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  21986. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  21987. import { Material } from "babylonjs/Materials/material";
  21988. import { Scene } from "babylonjs/scene";
  21989. /**
  21990. * This represents the object necessary to create a rendering group.
  21991. * This is exclusively used and created by the rendering manager.
  21992. * To modify the behavior, you use the available helpers in your scene or meshes.
  21993. * @hidden
  21994. */
  21995. export class RenderingGroup {
  21996. index: number;
  21997. private static _zeroVector;
  21998. private _scene;
  21999. private _opaqueSubMeshes;
  22000. private _transparentSubMeshes;
  22001. private _alphaTestSubMeshes;
  22002. private _depthOnlySubMeshes;
  22003. private _particleSystems;
  22004. private _spriteManagers;
  22005. private _opaqueSortCompareFn;
  22006. private _alphaTestSortCompareFn;
  22007. private _transparentSortCompareFn;
  22008. private _renderOpaque;
  22009. private _renderAlphaTest;
  22010. private _renderTransparent;
  22011. /** @hidden */
  22012. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22013. onBeforeTransparentRendering: () => void;
  22014. /**
  22015. * Set the opaque sort comparison function.
  22016. * If null the sub meshes will be render in the order they were created
  22017. */
  22018. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22019. /**
  22020. * Set the alpha test sort comparison function.
  22021. * If null the sub meshes will be render in the order they were created
  22022. */
  22023. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22024. /**
  22025. * Set the transparent sort comparison function.
  22026. * If null the sub meshes will be render in the order they were created
  22027. */
  22028. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22029. /**
  22030. * Creates a new rendering group.
  22031. * @param index The rendering group index
  22032. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22033. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22034. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22035. */
  22036. 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>);
  22037. /**
  22038. * Render all the sub meshes contained in the group.
  22039. * @param customRenderFunction Used to override the default render behaviour of the group.
  22040. * @returns true if rendered some submeshes.
  22041. */
  22042. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22043. /**
  22044. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22045. * @param subMeshes The submeshes to render
  22046. */
  22047. private renderOpaqueSorted;
  22048. /**
  22049. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22050. * @param subMeshes The submeshes to render
  22051. */
  22052. private renderAlphaTestSorted;
  22053. /**
  22054. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22055. * @param subMeshes The submeshes to render
  22056. */
  22057. private renderTransparentSorted;
  22058. /**
  22059. * Renders the submeshes in a specified order.
  22060. * @param subMeshes The submeshes to sort before render
  22061. * @param sortCompareFn The comparison function use to sort
  22062. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22063. * @param transparent Specifies to activate blending if true
  22064. */
  22065. private static renderSorted;
  22066. /**
  22067. * Renders the submeshes in the order they were dispatched (no sort applied).
  22068. * @param subMeshes The submeshes to render
  22069. */
  22070. private static renderUnsorted;
  22071. /**
  22072. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22073. * are rendered back to front if in the same alpha index.
  22074. *
  22075. * @param a The first submesh
  22076. * @param b The second submesh
  22077. * @returns The result of the comparison
  22078. */
  22079. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22080. /**
  22081. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22082. * are rendered back to front.
  22083. *
  22084. * @param a The first submesh
  22085. * @param b The second submesh
  22086. * @returns The result of the comparison
  22087. */
  22088. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22089. /**
  22090. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22091. * are rendered front to back (prevent overdraw).
  22092. *
  22093. * @param a The first submesh
  22094. * @param b The second submesh
  22095. * @returns The result of the comparison
  22096. */
  22097. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22098. /**
  22099. * Resets the different lists of submeshes to prepare a new frame.
  22100. */
  22101. prepare(): void;
  22102. dispose(): void;
  22103. /**
  22104. * Inserts the submesh in its correct queue depending on its material.
  22105. * @param subMesh The submesh to dispatch
  22106. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22107. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22108. */
  22109. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22110. dispatchSprites(spriteManager: ISpriteManager): void;
  22111. dispatchParticles(particleSystem: IParticleSystem): void;
  22112. private _renderParticles;
  22113. private _renderSprites;
  22114. }
  22115. }
  22116. declare module "babylonjs/Rendering/renderingManager" {
  22117. import { Nullable } from "babylonjs/types";
  22118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22119. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22120. import { SmartArray } from "babylonjs/Misc/smartArray";
  22121. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22122. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22123. import { Material } from "babylonjs/Materials/material";
  22124. import { Scene } from "babylonjs/scene";
  22125. import { Camera } from "babylonjs/Cameras/camera";
  22126. /**
  22127. * Interface describing the different options available in the rendering manager
  22128. * regarding Auto Clear between groups.
  22129. */
  22130. export interface IRenderingManagerAutoClearSetup {
  22131. /**
  22132. * Defines whether or not autoclear is enable.
  22133. */
  22134. autoClear: boolean;
  22135. /**
  22136. * Defines whether or not to autoclear the depth buffer.
  22137. */
  22138. depth: boolean;
  22139. /**
  22140. * Defines whether or not to autoclear the stencil buffer.
  22141. */
  22142. stencil: boolean;
  22143. }
  22144. /**
  22145. * This class is used by the onRenderingGroupObservable
  22146. */
  22147. export class RenderingGroupInfo {
  22148. /**
  22149. * The Scene that being rendered
  22150. */
  22151. scene: Scene;
  22152. /**
  22153. * The camera currently used for the rendering pass
  22154. */
  22155. camera: Nullable<Camera>;
  22156. /**
  22157. * The ID of the renderingGroup being processed
  22158. */
  22159. renderingGroupId: number;
  22160. }
  22161. /**
  22162. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22163. * It is enable to manage the different groups as well as the different necessary sort functions.
  22164. * This should not be used directly aside of the few static configurations
  22165. */
  22166. export class RenderingManager {
  22167. /**
  22168. * The max id used for rendering groups (not included)
  22169. */
  22170. static MAX_RENDERINGGROUPS: number;
  22171. /**
  22172. * The min id used for rendering groups (included)
  22173. */
  22174. static MIN_RENDERINGGROUPS: number;
  22175. /**
  22176. * Used to globally prevent autoclearing scenes.
  22177. */
  22178. static AUTOCLEAR: boolean;
  22179. /**
  22180. * @hidden
  22181. */
  22182. _useSceneAutoClearSetup: boolean;
  22183. private _scene;
  22184. private _renderingGroups;
  22185. private _depthStencilBufferAlreadyCleaned;
  22186. private _autoClearDepthStencil;
  22187. private _customOpaqueSortCompareFn;
  22188. private _customAlphaTestSortCompareFn;
  22189. private _customTransparentSortCompareFn;
  22190. private _renderingGroupInfo;
  22191. /**
  22192. * Instantiates a new rendering group for a particular scene
  22193. * @param scene Defines the scene the groups belongs to
  22194. */
  22195. constructor(scene: Scene);
  22196. private _clearDepthStencilBuffer;
  22197. /**
  22198. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22199. * @hidden
  22200. */
  22201. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22202. /**
  22203. * Resets the different information of the group to prepare a new frame
  22204. * @hidden
  22205. */
  22206. reset(): void;
  22207. /**
  22208. * Dispose and release the group and its associated resources.
  22209. * @hidden
  22210. */
  22211. dispose(): void;
  22212. /**
  22213. * Clear the info related to rendering groups preventing retention points during dispose.
  22214. */
  22215. freeRenderingGroups(): void;
  22216. private _prepareRenderingGroup;
  22217. /**
  22218. * Add a sprite manager to the rendering manager in order to render it this frame.
  22219. * @param spriteManager Define the sprite manager to render
  22220. */
  22221. dispatchSprites(spriteManager: ISpriteManager): void;
  22222. /**
  22223. * Add a particle system to the rendering manager in order to render it this frame.
  22224. * @param particleSystem Define the particle system to render
  22225. */
  22226. dispatchParticles(particleSystem: IParticleSystem): void;
  22227. /**
  22228. * Add a submesh to the manager in order to render it this frame
  22229. * @param subMesh The submesh to dispatch
  22230. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22231. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22232. */
  22233. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22234. /**
  22235. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22236. * This allowed control for front to back rendering or reversly depending of the special needs.
  22237. *
  22238. * @param renderingGroupId The rendering group id corresponding to its index
  22239. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22240. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22241. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22242. */
  22243. 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;
  22244. /**
  22245. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22246. *
  22247. * @param renderingGroupId The rendering group id corresponding to its index
  22248. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22249. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22250. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22251. */
  22252. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22253. /**
  22254. * Gets the current auto clear configuration for one rendering group of the rendering
  22255. * manager.
  22256. * @param index the rendering group index to get the information for
  22257. * @returns The auto clear setup for the requested rendering group
  22258. */
  22259. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22260. }
  22261. }
  22262. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22263. import { Observable } from "babylonjs/Misc/observable";
  22264. import { SmartArray } from "babylonjs/Misc/smartArray";
  22265. import { Nullable } from "babylonjs/types";
  22266. import { Camera } from "babylonjs/Cameras/camera";
  22267. import { Scene } from "babylonjs/scene";
  22268. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22269. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22271. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22272. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22273. import { Texture } from "babylonjs/Materials/Textures/texture";
  22274. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22275. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22276. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22277. import { Engine } from "babylonjs/Engines/engine";
  22278. /**
  22279. * This Helps creating a texture that will be created from a camera in your scene.
  22280. * It is basically a dynamic texture that could be used to create special effects for instance.
  22281. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22282. */
  22283. export class RenderTargetTexture extends Texture {
  22284. isCube: boolean;
  22285. /**
  22286. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22287. */
  22288. static readonly REFRESHRATE_RENDER_ONCE: number;
  22289. /**
  22290. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22291. */
  22292. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22293. /**
  22294. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22295. * the central point of your effect and can save a lot of performances.
  22296. */
  22297. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22298. /**
  22299. * Use this predicate to dynamically define the list of mesh you want to render.
  22300. * If set, the renderList property will be overwritten.
  22301. */
  22302. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22303. private _renderList;
  22304. /**
  22305. * Use this list to define the list of mesh you want to render.
  22306. */
  22307. renderList: Nullable<Array<AbstractMesh>>;
  22308. private _hookArray;
  22309. /**
  22310. * Define if particles should be rendered in your texture.
  22311. */
  22312. renderParticles: boolean;
  22313. /**
  22314. * Define if sprites should be rendered in your texture.
  22315. */
  22316. renderSprites: boolean;
  22317. /**
  22318. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22319. */
  22320. coordinatesMode: number;
  22321. /**
  22322. * Define the camera used to render the texture.
  22323. */
  22324. activeCamera: Nullable<Camera>;
  22325. /**
  22326. * Override the render function of the texture with your own one.
  22327. */
  22328. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22329. /**
  22330. * Define if camera post processes should be use while rendering the texture.
  22331. */
  22332. useCameraPostProcesses: boolean;
  22333. /**
  22334. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22335. */
  22336. ignoreCameraViewport: boolean;
  22337. private _postProcessManager;
  22338. private _postProcesses;
  22339. private _resizeObserver;
  22340. /**
  22341. * An event triggered when the texture is unbind.
  22342. */
  22343. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22344. /**
  22345. * An event triggered when the texture is unbind.
  22346. */
  22347. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22348. private _onAfterUnbindObserver;
  22349. /**
  22350. * Set a after unbind callback in the texture.
  22351. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22352. */
  22353. onAfterUnbind: () => void;
  22354. /**
  22355. * An event triggered before rendering the texture
  22356. */
  22357. onBeforeRenderObservable: Observable<number>;
  22358. private _onBeforeRenderObserver;
  22359. /**
  22360. * Set a before render callback in the texture.
  22361. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22362. */
  22363. onBeforeRender: (faceIndex: number) => void;
  22364. /**
  22365. * An event triggered after rendering the texture
  22366. */
  22367. onAfterRenderObservable: Observable<number>;
  22368. private _onAfterRenderObserver;
  22369. /**
  22370. * Set a after render callback in the texture.
  22371. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22372. */
  22373. onAfterRender: (faceIndex: number) => void;
  22374. /**
  22375. * An event triggered after the texture clear
  22376. */
  22377. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22378. private _onClearObserver;
  22379. /**
  22380. * Set a clear callback in the texture.
  22381. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22382. */
  22383. onClear: (Engine: Engine) => void;
  22384. /**
  22385. * Define the clear color of the Render Target if it should be different from the scene.
  22386. */
  22387. clearColor: Color4;
  22388. protected _size: number | {
  22389. width: number;
  22390. height: number;
  22391. };
  22392. protected _initialSizeParameter: number | {
  22393. width: number;
  22394. height: number;
  22395. } | {
  22396. ratio: number;
  22397. };
  22398. protected _sizeRatio: Nullable<number>;
  22399. /** @hidden */
  22400. _generateMipMaps: boolean;
  22401. protected _renderingManager: RenderingManager;
  22402. /** @hidden */
  22403. _waitingRenderList: string[];
  22404. protected _doNotChangeAspectRatio: boolean;
  22405. protected _currentRefreshId: number;
  22406. protected _refreshRate: number;
  22407. protected _textureMatrix: Matrix;
  22408. protected _samples: number;
  22409. protected _renderTargetOptions: RenderTargetCreationOptions;
  22410. /**
  22411. * Gets render target creation options that were used.
  22412. */
  22413. readonly renderTargetOptions: RenderTargetCreationOptions;
  22414. protected _engine: Engine;
  22415. protected _onRatioRescale(): void;
  22416. /**
  22417. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22418. * It must define where the camera used to render the texture is set
  22419. */
  22420. boundingBoxPosition: Vector3;
  22421. private _boundingBoxSize;
  22422. /**
  22423. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22424. * When defined, the cubemap will switch to local mode
  22425. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22426. * @example https://www.babylonjs-playground.com/#RNASML
  22427. */
  22428. boundingBoxSize: Vector3;
  22429. /**
  22430. * In case the RTT has been created with a depth texture, get the associated
  22431. * depth texture.
  22432. * Otherwise, return null.
  22433. */
  22434. depthStencilTexture: Nullable<InternalTexture>;
  22435. /**
  22436. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22437. * or used a shadow, depth texture...
  22438. * @param name The friendly name of the texture
  22439. * @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)
  22440. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22441. * @param generateMipMaps True if mip maps need to be generated after render.
  22442. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22443. * @param type The type of the buffer in the RTT (int, half float, float...)
  22444. * @param isCube True if a cube texture needs to be created
  22445. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22446. * @param generateDepthBuffer True to generate a depth buffer
  22447. * @param generateStencilBuffer True to generate a stencil buffer
  22448. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22449. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22450. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22451. */
  22452. constructor(name: string, size: number | {
  22453. width: number;
  22454. height: number;
  22455. } | {
  22456. ratio: number;
  22457. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22458. /**
  22459. * Creates a depth stencil texture.
  22460. * This is only available in WebGL 2 or with the depth texture extension available.
  22461. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22462. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22463. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22464. */
  22465. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22466. private _processSizeParameter;
  22467. /**
  22468. * Define the number of samples to use in case of MSAA.
  22469. * It defaults to one meaning no MSAA has been enabled.
  22470. */
  22471. samples: number;
  22472. /**
  22473. * Resets the refresh counter of the texture and start bak from scratch.
  22474. * Could be useful to regenerate the texture if it is setup to render only once.
  22475. */
  22476. resetRefreshCounter(): void;
  22477. /**
  22478. * Define the refresh rate of the texture or the rendering frequency.
  22479. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22480. */
  22481. refreshRate: number;
  22482. /**
  22483. * Adds a post process to the render target rendering passes.
  22484. * @param postProcess define the post process to add
  22485. */
  22486. addPostProcess(postProcess: PostProcess): void;
  22487. /**
  22488. * Clear all the post processes attached to the render target
  22489. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22490. */
  22491. clearPostProcesses(dispose?: boolean): void;
  22492. /**
  22493. * Remove one of the post process from the list of attached post processes to the texture
  22494. * @param postProcess define the post process to remove from the list
  22495. */
  22496. removePostProcess(postProcess: PostProcess): void;
  22497. /** @hidden */
  22498. _shouldRender(): boolean;
  22499. /**
  22500. * Gets the actual render size of the texture.
  22501. * @returns the width of the render size
  22502. */
  22503. getRenderSize(): number;
  22504. /**
  22505. * Gets the actual render width of the texture.
  22506. * @returns the width of the render size
  22507. */
  22508. getRenderWidth(): number;
  22509. /**
  22510. * Gets the actual render height of the texture.
  22511. * @returns the height of the render size
  22512. */
  22513. getRenderHeight(): number;
  22514. /**
  22515. * Get if the texture can be rescaled or not.
  22516. */
  22517. readonly canRescale: boolean;
  22518. /**
  22519. * Resize the texture using a ratio.
  22520. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22521. */
  22522. scale(ratio: number): void;
  22523. /**
  22524. * Get the texture reflection matrix used to rotate/transform the reflection.
  22525. * @returns the reflection matrix
  22526. */
  22527. getReflectionTextureMatrix(): Matrix;
  22528. /**
  22529. * Resize the texture to a new desired size.
  22530. * Be carrefull as it will recreate all the data in the new texture.
  22531. * @param size Define the new size. It can be:
  22532. * - a number for squared texture,
  22533. * - an object containing { width: number, height: number }
  22534. * - or an object containing a ratio { ratio: number }
  22535. */
  22536. resize(size: number | {
  22537. width: number;
  22538. height: number;
  22539. } | {
  22540. ratio: number;
  22541. }): void;
  22542. /**
  22543. * Renders all the objects from the render list into the texture.
  22544. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22545. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22546. */
  22547. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22548. private _bestReflectionRenderTargetDimension;
  22549. /**
  22550. * @hidden
  22551. * @param faceIndex face index to bind to if this is a cubetexture
  22552. */
  22553. _bindFrameBuffer(faceIndex?: number): void;
  22554. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22555. private renderToTarget;
  22556. /**
  22557. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22558. * This allowed control for front to back rendering or reversly depending of the special needs.
  22559. *
  22560. * @param renderingGroupId The rendering group id corresponding to its index
  22561. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22562. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22563. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22564. */
  22565. 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;
  22566. /**
  22567. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22568. *
  22569. * @param renderingGroupId The rendering group id corresponding to its index
  22570. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22571. */
  22572. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22573. /**
  22574. * Clones the texture.
  22575. * @returns the cloned texture
  22576. */
  22577. clone(): RenderTargetTexture;
  22578. /**
  22579. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22580. * @returns The JSON representation of the texture
  22581. */
  22582. serialize(): any;
  22583. /**
  22584. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22585. */
  22586. disposeFramebufferObjects(): void;
  22587. /**
  22588. * Dispose the texture and release its associated resources.
  22589. */
  22590. dispose(): void;
  22591. /** @hidden */
  22592. _rebuild(): void;
  22593. /**
  22594. * Clear the info related to rendering groups preventing retention point in material dispose.
  22595. */
  22596. freeRenderingGroups(): void;
  22597. /**
  22598. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22599. * @returns the view count
  22600. */
  22601. getViewCount(): number;
  22602. }
  22603. }
  22604. declare module "babylonjs/Materials/material" {
  22605. import { IAnimatable } from "babylonjs/Misc/tools";
  22606. import { SmartArray } from "babylonjs/Misc/smartArray";
  22607. import { Observable } from "babylonjs/Misc/observable";
  22608. import { Nullable } from "babylonjs/types";
  22609. import { Scene } from "babylonjs/scene";
  22610. import { Matrix } from "babylonjs/Maths/math";
  22611. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22613. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22614. import { Effect } from "babylonjs/Materials/effect";
  22615. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22616. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22617. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22618. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22619. import { Mesh } from "babylonjs/Meshes/mesh";
  22620. import { Animation } from "babylonjs/Animations/animation";
  22621. /**
  22622. * Base class for the main features of a material in Babylon.js
  22623. */
  22624. export class Material implements IAnimatable {
  22625. /**
  22626. * Returns the triangle fill mode
  22627. */
  22628. static readonly TriangleFillMode: number;
  22629. /**
  22630. * Returns the wireframe mode
  22631. */
  22632. static readonly WireFrameFillMode: number;
  22633. /**
  22634. * Returns the point fill mode
  22635. */
  22636. static readonly PointFillMode: number;
  22637. /**
  22638. * Returns the point list draw mode
  22639. */
  22640. static readonly PointListDrawMode: number;
  22641. /**
  22642. * Returns the line list draw mode
  22643. */
  22644. static readonly LineListDrawMode: number;
  22645. /**
  22646. * Returns the line loop draw mode
  22647. */
  22648. static readonly LineLoopDrawMode: number;
  22649. /**
  22650. * Returns the line strip draw mode
  22651. */
  22652. static readonly LineStripDrawMode: number;
  22653. /**
  22654. * Returns the triangle strip draw mode
  22655. */
  22656. static readonly TriangleStripDrawMode: number;
  22657. /**
  22658. * Returns the triangle fan draw mode
  22659. */
  22660. static readonly TriangleFanDrawMode: number;
  22661. /**
  22662. * Stores the clock-wise side orientation
  22663. */
  22664. static readonly ClockWiseSideOrientation: number;
  22665. /**
  22666. * Stores the counter clock-wise side orientation
  22667. */
  22668. static readonly CounterClockWiseSideOrientation: number;
  22669. /**
  22670. * The dirty texture flag value
  22671. */
  22672. static readonly TextureDirtyFlag: number;
  22673. /**
  22674. * The dirty light flag value
  22675. */
  22676. static readonly LightDirtyFlag: number;
  22677. /**
  22678. * The dirty fresnel flag value
  22679. */
  22680. static readonly FresnelDirtyFlag: number;
  22681. /**
  22682. * The dirty attribute flag value
  22683. */
  22684. static readonly AttributesDirtyFlag: number;
  22685. /**
  22686. * The dirty misc flag value
  22687. */
  22688. static readonly MiscDirtyFlag: number;
  22689. /**
  22690. * The all dirty flag value
  22691. */
  22692. static readonly AllDirtyFlag: number;
  22693. /**
  22694. * The ID of the material
  22695. */
  22696. id: string;
  22697. /**
  22698. * Gets or sets the unique id of the material
  22699. */
  22700. uniqueId: number;
  22701. /**
  22702. * The name of the material
  22703. */
  22704. name: string;
  22705. /**
  22706. * Gets or sets user defined metadata
  22707. */
  22708. metadata: any;
  22709. /**
  22710. * For internal use only. Please do not use.
  22711. */
  22712. reservedDataStore: any;
  22713. /**
  22714. * Specifies if the ready state should be checked on each call
  22715. */
  22716. checkReadyOnEveryCall: boolean;
  22717. /**
  22718. * Specifies if the ready state should be checked once
  22719. */
  22720. checkReadyOnlyOnce: boolean;
  22721. /**
  22722. * The state of the material
  22723. */
  22724. state: string;
  22725. /**
  22726. * The alpha value of the material
  22727. */
  22728. protected _alpha: number;
  22729. /**
  22730. * List of inspectable custom properties (used by the Inspector)
  22731. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22732. */
  22733. inspectableCustomProperties: IInspectable[];
  22734. /**
  22735. * Sets the alpha value of the material
  22736. */
  22737. /**
  22738. * Gets the alpha value of the material
  22739. */
  22740. alpha: number;
  22741. /**
  22742. * Specifies if back face culling is enabled
  22743. */
  22744. protected _backFaceCulling: boolean;
  22745. /**
  22746. * Sets the back-face culling state
  22747. */
  22748. /**
  22749. * Gets the back-face culling state
  22750. */
  22751. backFaceCulling: boolean;
  22752. /**
  22753. * Stores the value for side orientation
  22754. */
  22755. sideOrientation: number;
  22756. /**
  22757. * Callback triggered when the material is compiled
  22758. */
  22759. onCompiled: Nullable<(effect: Effect) => void>;
  22760. /**
  22761. * Callback triggered when an error occurs
  22762. */
  22763. onError: Nullable<(effect: Effect, errors: string) => void>;
  22764. /**
  22765. * Callback triggered to get the render target textures
  22766. */
  22767. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22768. /**
  22769. * Gets a boolean indicating that current material needs to register RTT
  22770. */
  22771. readonly hasRenderTargetTextures: boolean;
  22772. /**
  22773. * Specifies if the material should be serialized
  22774. */
  22775. doNotSerialize: boolean;
  22776. /**
  22777. * @hidden
  22778. */
  22779. _storeEffectOnSubMeshes: boolean;
  22780. /**
  22781. * Stores the animations for the material
  22782. */
  22783. animations: Nullable<Array<Animation>>;
  22784. /**
  22785. * An event triggered when the material is disposed
  22786. */
  22787. onDisposeObservable: Observable<Material>;
  22788. /**
  22789. * An observer which watches for dispose events
  22790. */
  22791. private _onDisposeObserver;
  22792. private _onUnBindObservable;
  22793. /**
  22794. * Called during a dispose event
  22795. */
  22796. onDispose: () => void;
  22797. private _onBindObservable;
  22798. /**
  22799. * An event triggered when the material is bound
  22800. */
  22801. readonly onBindObservable: Observable<AbstractMesh>;
  22802. /**
  22803. * An observer which watches for bind events
  22804. */
  22805. private _onBindObserver;
  22806. /**
  22807. * Called during a bind event
  22808. */
  22809. onBind: (Mesh: AbstractMesh) => void;
  22810. /**
  22811. * An event triggered when the material is unbound
  22812. */
  22813. readonly onUnBindObservable: Observable<Material>;
  22814. /**
  22815. * Stores the value of the alpha mode
  22816. */
  22817. private _alphaMode;
  22818. /**
  22819. * Sets the value of the alpha mode.
  22820. *
  22821. * | Value | Type | Description |
  22822. * | --- | --- | --- |
  22823. * | 0 | ALPHA_DISABLE | |
  22824. * | 1 | ALPHA_ADD | |
  22825. * | 2 | ALPHA_COMBINE | |
  22826. * | 3 | ALPHA_SUBTRACT | |
  22827. * | 4 | ALPHA_MULTIPLY | |
  22828. * | 5 | ALPHA_MAXIMIZED | |
  22829. * | 6 | ALPHA_ONEONE | |
  22830. * | 7 | ALPHA_PREMULTIPLIED | |
  22831. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22832. * | 9 | ALPHA_INTERPOLATE | |
  22833. * | 10 | ALPHA_SCREENMODE | |
  22834. *
  22835. */
  22836. /**
  22837. * Gets the value of the alpha mode
  22838. */
  22839. alphaMode: number;
  22840. /**
  22841. * Stores the state of the need depth pre-pass value
  22842. */
  22843. private _needDepthPrePass;
  22844. /**
  22845. * Sets the need depth pre-pass value
  22846. */
  22847. /**
  22848. * Gets the depth pre-pass value
  22849. */
  22850. needDepthPrePass: boolean;
  22851. /**
  22852. * Specifies if depth writing should be disabled
  22853. */
  22854. disableDepthWrite: boolean;
  22855. /**
  22856. * Specifies if depth writing should be forced
  22857. */
  22858. forceDepthWrite: boolean;
  22859. /**
  22860. * Specifies if there should be a separate pass for culling
  22861. */
  22862. separateCullingPass: boolean;
  22863. /**
  22864. * Stores the state specifing if fog should be enabled
  22865. */
  22866. private _fogEnabled;
  22867. /**
  22868. * Sets the state for enabling fog
  22869. */
  22870. /**
  22871. * Gets the value of the fog enabled state
  22872. */
  22873. fogEnabled: boolean;
  22874. /**
  22875. * Stores the size of points
  22876. */
  22877. pointSize: number;
  22878. /**
  22879. * Stores the z offset value
  22880. */
  22881. zOffset: number;
  22882. /**
  22883. * Gets a value specifying if wireframe mode is enabled
  22884. */
  22885. /**
  22886. * Sets the state of wireframe mode
  22887. */
  22888. wireframe: boolean;
  22889. /**
  22890. * Gets the value specifying if point clouds are enabled
  22891. */
  22892. /**
  22893. * Sets the state of point cloud mode
  22894. */
  22895. pointsCloud: boolean;
  22896. /**
  22897. * Gets the material fill mode
  22898. */
  22899. /**
  22900. * Sets the material fill mode
  22901. */
  22902. fillMode: number;
  22903. /**
  22904. * @hidden
  22905. * Stores the effects for the material
  22906. */
  22907. _effect: Nullable<Effect>;
  22908. /**
  22909. * @hidden
  22910. * Specifies if the material was previously ready
  22911. */
  22912. _wasPreviouslyReady: boolean;
  22913. /**
  22914. * Specifies if uniform buffers should be used
  22915. */
  22916. private _useUBO;
  22917. /**
  22918. * Stores a reference to the scene
  22919. */
  22920. private _scene;
  22921. /**
  22922. * Stores the fill mode state
  22923. */
  22924. private _fillMode;
  22925. /**
  22926. * Specifies if the depth write state should be cached
  22927. */
  22928. private _cachedDepthWriteState;
  22929. /**
  22930. * Stores the uniform buffer
  22931. */
  22932. protected _uniformBuffer: UniformBuffer;
  22933. /** @hidden */
  22934. _indexInSceneMaterialArray: number;
  22935. /** @hidden */
  22936. meshMap: Nullable<{
  22937. [id: string]: AbstractMesh | undefined;
  22938. }>;
  22939. /**
  22940. * Creates a material instance
  22941. * @param name defines the name of the material
  22942. * @param scene defines the scene to reference
  22943. * @param doNotAdd specifies if the material should be added to the scene
  22944. */
  22945. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22946. /**
  22947. * Returns a string representation of the current material
  22948. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22949. * @returns a string with material information
  22950. */
  22951. toString(fullDetails?: boolean): string;
  22952. /**
  22953. * Gets the class name of the material
  22954. * @returns a string with the class name of the material
  22955. */
  22956. getClassName(): string;
  22957. /**
  22958. * Specifies if updates for the material been locked
  22959. */
  22960. readonly isFrozen: boolean;
  22961. /**
  22962. * Locks updates for the material
  22963. */
  22964. freeze(): void;
  22965. /**
  22966. * Unlocks updates for the material
  22967. */
  22968. unfreeze(): void;
  22969. /**
  22970. * Specifies if the material is ready to be used
  22971. * @param mesh defines the mesh to check
  22972. * @param useInstances specifies if instances should be used
  22973. * @returns a boolean indicating if the material is ready to be used
  22974. */
  22975. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22976. /**
  22977. * Specifies that the submesh is ready to be used
  22978. * @param mesh defines the mesh to check
  22979. * @param subMesh defines which submesh to check
  22980. * @param useInstances specifies that instances should be used
  22981. * @returns a boolean indicating that the submesh is ready or not
  22982. */
  22983. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22984. /**
  22985. * Returns the material effect
  22986. * @returns the effect associated with the material
  22987. */
  22988. getEffect(): Nullable<Effect>;
  22989. /**
  22990. * Returns the current scene
  22991. * @returns a Scene
  22992. */
  22993. getScene(): Scene;
  22994. /**
  22995. * Specifies if the material will require alpha blending
  22996. * @returns a boolean specifying if alpha blending is needed
  22997. */
  22998. needAlphaBlending(): boolean;
  22999. /**
  23000. * Specifies if the mesh will require alpha blending
  23001. * @param mesh defines the mesh to check
  23002. * @returns a boolean specifying if alpha blending is needed for the mesh
  23003. */
  23004. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23005. /**
  23006. * Specifies if this material should be rendered in alpha test mode
  23007. * @returns a boolean specifying if an alpha test is needed.
  23008. */
  23009. needAlphaTesting(): boolean;
  23010. /**
  23011. * Gets the texture used for the alpha test
  23012. * @returns the texture to use for alpha testing
  23013. */
  23014. getAlphaTestTexture(): Nullable<BaseTexture>;
  23015. /**
  23016. * Marks the material to indicate that it needs to be re-calculated
  23017. */
  23018. markDirty(): void;
  23019. /** @hidden */
  23020. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23021. /**
  23022. * Binds the material to the mesh
  23023. * @param world defines the world transformation matrix
  23024. * @param mesh defines the mesh to bind the material to
  23025. */
  23026. bind(world: Matrix, mesh?: Mesh): void;
  23027. /**
  23028. * Binds the submesh to the material
  23029. * @param world defines the world transformation matrix
  23030. * @param mesh defines the mesh containing the submesh
  23031. * @param subMesh defines the submesh to bind the material to
  23032. */
  23033. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23034. /**
  23035. * Binds the world matrix to the material
  23036. * @param world defines the world transformation matrix
  23037. */
  23038. bindOnlyWorldMatrix(world: Matrix): void;
  23039. /**
  23040. * Binds the scene's uniform buffer to the effect.
  23041. * @param effect defines the effect to bind to the scene uniform buffer
  23042. * @param sceneUbo defines the uniform buffer storing scene data
  23043. */
  23044. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23045. /**
  23046. * Binds the view matrix to the effect
  23047. * @param effect defines the effect to bind the view matrix to
  23048. */
  23049. bindView(effect: Effect): void;
  23050. /**
  23051. * Binds the view projection matrix to the effect
  23052. * @param effect defines the effect to bind the view projection matrix to
  23053. */
  23054. bindViewProjection(effect: Effect): void;
  23055. /**
  23056. * Specifies if material alpha testing should be turned on for the mesh
  23057. * @param mesh defines the mesh to check
  23058. */
  23059. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23060. /**
  23061. * Processes to execute after binding the material to a mesh
  23062. * @param mesh defines the rendered mesh
  23063. */
  23064. protected _afterBind(mesh?: Mesh): void;
  23065. /**
  23066. * Unbinds the material from the mesh
  23067. */
  23068. unbind(): void;
  23069. /**
  23070. * Gets the active textures from the material
  23071. * @returns an array of textures
  23072. */
  23073. getActiveTextures(): BaseTexture[];
  23074. /**
  23075. * Specifies if the material uses a texture
  23076. * @param texture defines the texture to check against the material
  23077. * @returns a boolean specifying if the material uses the texture
  23078. */
  23079. hasTexture(texture: BaseTexture): boolean;
  23080. /**
  23081. * Makes a duplicate of the material, and gives it a new name
  23082. * @param name defines the new name for the duplicated material
  23083. * @returns the cloned material
  23084. */
  23085. clone(name: string): Nullable<Material>;
  23086. /**
  23087. * Gets the meshes bound to the material
  23088. * @returns an array of meshes bound to the material
  23089. */
  23090. getBindedMeshes(): AbstractMesh[];
  23091. /**
  23092. * Force shader compilation
  23093. * @param mesh defines the mesh associated with this material
  23094. * @param onCompiled defines a function to execute once the material is compiled
  23095. * @param options defines the options to configure the compilation
  23096. */
  23097. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23098. clipPlane: boolean;
  23099. }>): void;
  23100. /**
  23101. * Force shader compilation
  23102. * @param mesh defines the mesh that will use this material
  23103. * @param options defines additional options for compiling the shaders
  23104. * @returns a promise that resolves when the compilation completes
  23105. */
  23106. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23107. clipPlane: boolean;
  23108. }>): Promise<void>;
  23109. private static readonly _AllDirtyCallBack;
  23110. private static readonly _ImageProcessingDirtyCallBack;
  23111. private static readonly _TextureDirtyCallBack;
  23112. private static readonly _FresnelDirtyCallBack;
  23113. private static readonly _MiscDirtyCallBack;
  23114. private static readonly _LightsDirtyCallBack;
  23115. private static readonly _AttributeDirtyCallBack;
  23116. private static _FresnelAndMiscDirtyCallBack;
  23117. private static _TextureAndMiscDirtyCallBack;
  23118. private static readonly _DirtyCallbackArray;
  23119. private static readonly _RunDirtyCallBacks;
  23120. /**
  23121. * Marks a define in the material to indicate that it needs to be re-computed
  23122. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23123. */
  23124. markAsDirty(flag: number): void;
  23125. /**
  23126. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23127. * @param func defines a function which checks material defines against the submeshes
  23128. */
  23129. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23130. /**
  23131. * Indicates that we need to re-calculated for all submeshes
  23132. */
  23133. protected _markAllSubMeshesAsAllDirty(): void;
  23134. /**
  23135. * Indicates that image processing needs to be re-calculated for all submeshes
  23136. */
  23137. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23138. /**
  23139. * Indicates that textures need to be re-calculated for all submeshes
  23140. */
  23141. protected _markAllSubMeshesAsTexturesDirty(): void;
  23142. /**
  23143. * Indicates that fresnel needs to be re-calculated for all submeshes
  23144. */
  23145. protected _markAllSubMeshesAsFresnelDirty(): void;
  23146. /**
  23147. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23148. */
  23149. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23150. /**
  23151. * Indicates that lights need to be re-calculated for all submeshes
  23152. */
  23153. protected _markAllSubMeshesAsLightsDirty(): void;
  23154. /**
  23155. * Indicates that attributes need to be re-calculated for all submeshes
  23156. */
  23157. protected _markAllSubMeshesAsAttributesDirty(): void;
  23158. /**
  23159. * Indicates that misc needs to be re-calculated for all submeshes
  23160. */
  23161. protected _markAllSubMeshesAsMiscDirty(): void;
  23162. /**
  23163. * Indicates that textures and misc need to be re-calculated for all submeshes
  23164. */
  23165. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23166. /**
  23167. * Disposes the material
  23168. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23169. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23170. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23171. */
  23172. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23173. /** @hidden */
  23174. private releaseVertexArrayObject;
  23175. /**
  23176. * Serializes this material
  23177. * @returns the serialized material object
  23178. */
  23179. serialize(): any;
  23180. /**
  23181. * Creates a material from parsed material data
  23182. * @param parsedMaterial defines parsed material data
  23183. * @param scene defines the hosting scene
  23184. * @param rootUrl defines the root URL to use to load textures
  23185. * @returns a new material
  23186. */
  23187. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23188. }
  23189. }
  23190. declare module "babylonjs/Meshes/subMesh" {
  23191. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23192. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23193. import { Engine } from "babylonjs/Engines/engine";
  23194. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23195. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23196. import { Effect } from "babylonjs/Materials/effect";
  23197. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23198. import { Collider } from "babylonjs/Collisions/collider";
  23199. import { Material } from "babylonjs/Materials/material";
  23200. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23202. import { Mesh } from "babylonjs/Meshes/mesh";
  23203. import { Ray } from "babylonjs/Culling/ray";
  23204. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23205. /**
  23206. * Base class for submeshes
  23207. */
  23208. export class BaseSubMesh {
  23209. /** @hidden */
  23210. _materialDefines: Nullable<MaterialDefines>;
  23211. /** @hidden */
  23212. _materialEffect: Nullable<Effect>;
  23213. /**
  23214. * Gets associated effect
  23215. */
  23216. readonly effect: Nullable<Effect>;
  23217. /**
  23218. * Sets associated effect (effect used to render this submesh)
  23219. * @param effect defines the effect to associate with
  23220. * @param defines defines the set of defines used to compile this effect
  23221. */
  23222. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23223. }
  23224. /**
  23225. * Defines a subdivision inside a mesh
  23226. */
  23227. export class SubMesh extends BaseSubMesh implements ICullable {
  23228. /** the material index to use */
  23229. materialIndex: number;
  23230. /** vertex index start */
  23231. verticesStart: number;
  23232. /** vertices count */
  23233. verticesCount: number;
  23234. /** index start */
  23235. indexStart: number;
  23236. /** indices count */
  23237. indexCount: number;
  23238. /** @hidden */
  23239. _linesIndexCount: number;
  23240. private _mesh;
  23241. private _renderingMesh;
  23242. private _boundingInfo;
  23243. private _linesIndexBuffer;
  23244. /** @hidden */
  23245. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23246. /** @hidden */
  23247. _trianglePlanes: Plane[];
  23248. /** @hidden */
  23249. _lastColliderTransformMatrix: Nullable<Matrix>;
  23250. /** @hidden */
  23251. _renderId: number;
  23252. /** @hidden */
  23253. _alphaIndex: number;
  23254. /** @hidden */
  23255. _distanceToCamera: number;
  23256. /** @hidden */
  23257. _id: number;
  23258. private _currentMaterial;
  23259. /**
  23260. * Add a new submesh to a mesh
  23261. * @param materialIndex defines the material index to use
  23262. * @param verticesStart defines vertex index start
  23263. * @param verticesCount defines vertices count
  23264. * @param indexStart defines index start
  23265. * @param indexCount defines indices count
  23266. * @param mesh defines the parent mesh
  23267. * @param renderingMesh defines an optional rendering mesh
  23268. * @param createBoundingBox defines if bounding box should be created for this submesh
  23269. * @returns the new submesh
  23270. */
  23271. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23272. /**
  23273. * Creates a new submesh
  23274. * @param materialIndex defines the material index to use
  23275. * @param verticesStart defines vertex index start
  23276. * @param verticesCount defines vertices count
  23277. * @param indexStart defines index start
  23278. * @param indexCount defines indices count
  23279. * @param mesh defines the parent mesh
  23280. * @param renderingMesh defines an optional rendering mesh
  23281. * @param createBoundingBox defines if bounding box should be created for this submesh
  23282. */
  23283. constructor(
  23284. /** the material index to use */
  23285. materialIndex: number,
  23286. /** vertex index start */
  23287. verticesStart: number,
  23288. /** vertices count */
  23289. verticesCount: number,
  23290. /** index start */
  23291. indexStart: number,
  23292. /** indices count */
  23293. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23294. /**
  23295. * Returns true if this submesh covers the entire parent mesh
  23296. * @ignorenaming
  23297. */
  23298. readonly IsGlobal: boolean;
  23299. /**
  23300. * Returns the submesh BoudingInfo object
  23301. * @returns current bounding info (or mesh's one if the submesh is global)
  23302. */
  23303. getBoundingInfo(): BoundingInfo;
  23304. /**
  23305. * Sets the submesh BoundingInfo
  23306. * @param boundingInfo defines the new bounding info to use
  23307. * @returns the SubMesh
  23308. */
  23309. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23310. /**
  23311. * Returns the mesh of the current submesh
  23312. * @return the parent mesh
  23313. */
  23314. getMesh(): AbstractMesh;
  23315. /**
  23316. * Returns the rendering mesh of the submesh
  23317. * @returns the rendering mesh (could be different from parent mesh)
  23318. */
  23319. getRenderingMesh(): Mesh;
  23320. /**
  23321. * Returns the submesh material
  23322. * @returns null or the current material
  23323. */
  23324. getMaterial(): Nullable<Material>;
  23325. /**
  23326. * Sets a new updated BoundingInfo object to the submesh
  23327. * @param data defines an optional position array to use to determine the bounding info
  23328. * @returns the SubMesh
  23329. */
  23330. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23331. /** @hidden */
  23332. _checkCollision(collider: Collider): boolean;
  23333. /**
  23334. * Updates the submesh BoundingInfo
  23335. * @param world defines the world matrix to use to update the bounding info
  23336. * @returns the submesh
  23337. */
  23338. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23339. /**
  23340. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23341. * @param frustumPlanes defines the frustum planes
  23342. * @returns true if the submesh is intersecting with the frustum
  23343. */
  23344. isInFrustum(frustumPlanes: Plane[]): boolean;
  23345. /**
  23346. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23347. * @param frustumPlanes defines the frustum planes
  23348. * @returns true if the submesh is inside the frustum
  23349. */
  23350. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23351. /**
  23352. * Renders the submesh
  23353. * @param enableAlphaMode defines if alpha needs to be used
  23354. * @returns the submesh
  23355. */
  23356. render(enableAlphaMode: boolean): SubMesh;
  23357. /**
  23358. * @hidden
  23359. */
  23360. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23361. /**
  23362. * Checks if the submesh intersects with a ray
  23363. * @param ray defines the ray to test
  23364. * @returns true is the passed ray intersects the submesh bounding box
  23365. */
  23366. canIntersects(ray: Ray): boolean;
  23367. /**
  23368. * Intersects current submesh with a ray
  23369. * @param ray defines the ray to test
  23370. * @param positions defines mesh's positions array
  23371. * @param indices defines mesh's indices array
  23372. * @param fastCheck defines if only bounding info should be used
  23373. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23374. * @returns intersection info or null if no intersection
  23375. */
  23376. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23377. /** @hidden */
  23378. private _intersectLines;
  23379. /** @hidden */
  23380. private _intersectUnIndexedLines;
  23381. /** @hidden */
  23382. private _intersectTriangles;
  23383. /** @hidden */
  23384. private _intersectUnIndexedTriangles;
  23385. /** @hidden */
  23386. _rebuild(): void;
  23387. /**
  23388. * Creates a new submesh from the passed mesh
  23389. * @param newMesh defines the new hosting mesh
  23390. * @param newRenderingMesh defines an optional rendering mesh
  23391. * @returns the new submesh
  23392. */
  23393. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23394. /**
  23395. * Release associated resources
  23396. */
  23397. dispose(): void;
  23398. /**
  23399. * Gets the class name
  23400. * @returns the string "SubMesh".
  23401. */
  23402. getClassName(): string;
  23403. /**
  23404. * Creates a new submesh from indices data
  23405. * @param materialIndex the index of the main mesh material
  23406. * @param startIndex the index where to start the copy in the mesh indices array
  23407. * @param indexCount the number of indices to copy then from the startIndex
  23408. * @param mesh the main mesh to create the submesh from
  23409. * @param renderingMesh the optional rendering mesh
  23410. * @returns a new submesh
  23411. */
  23412. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23413. }
  23414. }
  23415. declare module "babylonjs/Meshes/geometry" {
  23416. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23417. import { Scene } from "babylonjs/scene";
  23418. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23419. import { Engine } from "babylonjs/Engines/engine";
  23420. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23421. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23422. import { Effect } from "babylonjs/Materials/effect";
  23423. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23424. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23425. import { Mesh } from "babylonjs/Meshes/mesh";
  23426. /**
  23427. * Class used to store geometry data (vertex buffers + index buffer)
  23428. */
  23429. export class Geometry implements IGetSetVerticesData {
  23430. /**
  23431. * Gets or sets the ID of the geometry
  23432. */
  23433. id: string;
  23434. /**
  23435. * Gets or sets the unique ID of the geometry
  23436. */
  23437. uniqueId: number;
  23438. /**
  23439. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23440. */
  23441. delayLoadState: number;
  23442. /**
  23443. * Gets the file containing the data to load when running in delay load state
  23444. */
  23445. delayLoadingFile: Nullable<string>;
  23446. /**
  23447. * Callback called when the geometry is updated
  23448. */
  23449. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23450. private _scene;
  23451. private _engine;
  23452. private _meshes;
  23453. private _totalVertices;
  23454. /** @hidden */
  23455. _indices: IndicesArray;
  23456. /** @hidden */
  23457. _vertexBuffers: {
  23458. [key: string]: VertexBuffer;
  23459. };
  23460. private _isDisposed;
  23461. private _extend;
  23462. private _boundingBias;
  23463. /** @hidden */
  23464. _delayInfo: Array<string>;
  23465. private _indexBuffer;
  23466. private _indexBufferIsUpdatable;
  23467. /** @hidden */
  23468. _boundingInfo: Nullable<BoundingInfo>;
  23469. /** @hidden */
  23470. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23471. /** @hidden */
  23472. _softwareSkinningFrameId: number;
  23473. private _vertexArrayObjects;
  23474. private _updatable;
  23475. /** @hidden */
  23476. _positions: Nullable<Vector3[]>;
  23477. /**
  23478. * 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
  23479. */
  23480. /**
  23481. * 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
  23482. */
  23483. boundingBias: Vector2;
  23484. /**
  23485. * Static function used to attach a new empty geometry to a mesh
  23486. * @param mesh defines the mesh to attach the geometry to
  23487. * @returns the new Geometry
  23488. */
  23489. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23490. /**
  23491. * Creates a new geometry
  23492. * @param id defines the unique ID
  23493. * @param scene defines the hosting scene
  23494. * @param vertexData defines the VertexData used to get geometry data
  23495. * @param updatable defines if geometry must be updatable (false by default)
  23496. * @param mesh defines the mesh that will be associated with the geometry
  23497. */
  23498. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23499. /**
  23500. * Gets the current extend of the geometry
  23501. */
  23502. readonly extend: {
  23503. minimum: Vector3;
  23504. maximum: Vector3;
  23505. };
  23506. /**
  23507. * Gets the hosting scene
  23508. * @returns the hosting Scene
  23509. */
  23510. getScene(): Scene;
  23511. /**
  23512. * Gets the hosting engine
  23513. * @returns the hosting Engine
  23514. */
  23515. getEngine(): Engine;
  23516. /**
  23517. * Defines if the geometry is ready to use
  23518. * @returns true if the geometry is ready to be used
  23519. */
  23520. isReady(): boolean;
  23521. /**
  23522. * Gets a value indicating that the geometry should not be serialized
  23523. */
  23524. readonly doNotSerialize: boolean;
  23525. /** @hidden */
  23526. _rebuild(): void;
  23527. /**
  23528. * Affects all geometry data in one call
  23529. * @param vertexData defines the geometry data
  23530. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23531. */
  23532. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23533. /**
  23534. * Set specific vertex data
  23535. * @param kind defines the data kind (Position, normal, etc...)
  23536. * @param data defines the vertex data to use
  23537. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23538. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23539. */
  23540. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23541. /**
  23542. * Removes a specific vertex data
  23543. * @param kind defines the data kind (Position, normal, etc...)
  23544. */
  23545. removeVerticesData(kind: string): void;
  23546. /**
  23547. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23548. * @param buffer defines the vertex buffer to use
  23549. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23550. */
  23551. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23552. /**
  23553. * Update a specific vertex buffer
  23554. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23555. * It will do nothing if the buffer is not updatable
  23556. * @param kind defines the data kind (Position, normal, etc...)
  23557. * @param data defines the data to use
  23558. * @param offset defines the offset in the target buffer where to store the data
  23559. * @param useBytes set to true if the offset is in bytes
  23560. */
  23561. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23562. /**
  23563. * Update a specific vertex buffer
  23564. * This function will create a new buffer if the current one is not updatable
  23565. * @param kind defines the data kind (Position, normal, etc...)
  23566. * @param data defines the data to use
  23567. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23568. */
  23569. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23570. private _updateBoundingInfo;
  23571. /** @hidden */
  23572. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23573. /**
  23574. * Gets total number of vertices
  23575. * @returns the total number of vertices
  23576. */
  23577. getTotalVertices(): number;
  23578. /**
  23579. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23580. * @param kind defines the data kind (Position, normal, etc...)
  23581. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23582. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23583. * @returns a float array containing vertex data
  23584. */
  23585. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23586. /**
  23587. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23588. * @param kind defines the data kind (Position, normal, etc...)
  23589. * @returns true if the vertex buffer with the specified kind is updatable
  23590. */
  23591. isVertexBufferUpdatable(kind: string): boolean;
  23592. /**
  23593. * Gets a specific vertex buffer
  23594. * @param kind defines the data kind (Position, normal, etc...)
  23595. * @returns a VertexBuffer
  23596. */
  23597. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23598. /**
  23599. * Returns all vertex buffers
  23600. * @return an object holding all vertex buffers indexed by kind
  23601. */
  23602. getVertexBuffers(): Nullable<{
  23603. [key: string]: VertexBuffer;
  23604. }>;
  23605. /**
  23606. * Gets a boolean indicating if specific vertex buffer is present
  23607. * @param kind defines the data kind (Position, normal, etc...)
  23608. * @returns true if data is present
  23609. */
  23610. isVerticesDataPresent(kind: string): boolean;
  23611. /**
  23612. * Gets a list of all attached data kinds (Position, normal, etc...)
  23613. * @returns a list of string containing all kinds
  23614. */
  23615. getVerticesDataKinds(): string[];
  23616. /**
  23617. * Update index buffer
  23618. * @param indices defines the indices to store in the index buffer
  23619. * @param offset defines the offset in the target buffer where to store the data
  23620. * @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)
  23621. */
  23622. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23623. /**
  23624. * Creates a new index buffer
  23625. * @param indices defines the indices to store in the index buffer
  23626. * @param totalVertices defines the total number of vertices (could be null)
  23627. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23628. */
  23629. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23630. /**
  23631. * Return the total number of indices
  23632. * @returns the total number of indices
  23633. */
  23634. getTotalIndices(): number;
  23635. /**
  23636. * Gets the index buffer array
  23637. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23638. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23639. * @returns the index buffer array
  23640. */
  23641. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23642. /**
  23643. * Gets the index buffer
  23644. * @return the index buffer
  23645. */
  23646. getIndexBuffer(): Nullable<DataBuffer>;
  23647. /** @hidden */
  23648. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23649. /**
  23650. * Release the associated resources for a specific mesh
  23651. * @param mesh defines the source mesh
  23652. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23653. */
  23654. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23655. /**
  23656. * Apply current geometry to a given mesh
  23657. * @param mesh defines the mesh to apply geometry to
  23658. */
  23659. applyToMesh(mesh: Mesh): void;
  23660. private _updateExtend;
  23661. private _applyToMesh;
  23662. private notifyUpdate;
  23663. /**
  23664. * Load the geometry if it was flagged as delay loaded
  23665. * @param scene defines the hosting scene
  23666. * @param onLoaded defines a callback called when the geometry is loaded
  23667. */
  23668. load(scene: Scene, onLoaded?: () => void): void;
  23669. private _queueLoad;
  23670. /**
  23671. * Invert the geometry to move from a right handed system to a left handed one.
  23672. */
  23673. toLeftHanded(): void;
  23674. /** @hidden */
  23675. _resetPointsArrayCache(): void;
  23676. /** @hidden */
  23677. _generatePointsArray(): boolean;
  23678. /**
  23679. * Gets a value indicating if the geometry is disposed
  23680. * @returns true if the geometry was disposed
  23681. */
  23682. isDisposed(): boolean;
  23683. private _disposeVertexArrayObjects;
  23684. /**
  23685. * Free all associated resources
  23686. */
  23687. dispose(): void;
  23688. /**
  23689. * Clone the current geometry into a new geometry
  23690. * @param id defines the unique ID of the new geometry
  23691. * @returns a new geometry object
  23692. */
  23693. copy(id: string): Geometry;
  23694. /**
  23695. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23696. * @return a JSON representation of the current geometry data (without the vertices data)
  23697. */
  23698. serialize(): any;
  23699. private toNumberArray;
  23700. /**
  23701. * Serialize all vertices data into a JSON oject
  23702. * @returns a JSON representation of the current geometry data
  23703. */
  23704. serializeVerticeData(): any;
  23705. /**
  23706. * Extracts a clone of a mesh geometry
  23707. * @param mesh defines the source mesh
  23708. * @param id defines the unique ID of the new geometry object
  23709. * @returns the new geometry object
  23710. */
  23711. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23712. /**
  23713. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23714. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23715. * Be aware Math.random() could cause collisions, but:
  23716. * "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"
  23717. * @returns a string containing a new GUID
  23718. */
  23719. static RandomId(): string;
  23720. /** @hidden */
  23721. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23722. private static _CleanMatricesWeights;
  23723. /**
  23724. * Create a new geometry from persisted data (Using .babylon file format)
  23725. * @param parsedVertexData defines the persisted data
  23726. * @param scene defines the hosting scene
  23727. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23728. * @returns the new geometry object
  23729. */
  23730. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23731. }
  23732. }
  23733. declare module "babylonjs/Meshes/mesh.vertexData" {
  23734. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23735. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23736. import { Geometry } from "babylonjs/Meshes/geometry";
  23737. import { Mesh } from "babylonjs/Meshes/mesh";
  23738. /**
  23739. * Define an interface for all classes that will get and set the data on vertices
  23740. */
  23741. export interface IGetSetVerticesData {
  23742. /**
  23743. * Gets a boolean indicating if specific vertex data is present
  23744. * @param kind defines the vertex data kind to use
  23745. * @returns true is data kind is present
  23746. */
  23747. isVerticesDataPresent(kind: string): boolean;
  23748. /**
  23749. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23750. * @param kind defines the data kind (Position, normal, etc...)
  23751. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23752. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23753. * @returns a float array containing vertex data
  23754. */
  23755. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23756. /**
  23757. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23758. * @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.
  23759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23760. * @returns the indices array or an empty array if the mesh has no geometry
  23761. */
  23762. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23763. /**
  23764. * Set specific vertex data
  23765. * @param kind defines the data kind (Position, normal, etc...)
  23766. * @param data defines the vertex data to use
  23767. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23768. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23769. */
  23770. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23771. /**
  23772. * Update a specific associated vertex buffer
  23773. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23774. * - VertexBuffer.PositionKind
  23775. * - VertexBuffer.UVKind
  23776. * - VertexBuffer.UV2Kind
  23777. * - VertexBuffer.UV3Kind
  23778. * - VertexBuffer.UV4Kind
  23779. * - VertexBuffer.UV5Kind
  23780. * - VertexBuffer.UV6Kind
  23781. * - VertexBuffer.ColorKind
  23782. * - VertexBuffer.MatricesIndicesKind
  23783. * - VertexBuffer.MatricesIndicesExtraKind
  23784. * - VertexBuffer.MatricesWeightsKind
  23785. * - VertexBuffer.MatricesWeightsExtraKind
  23786. * @param data defines the data source
  23787. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23788. * @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)
  23789. */
  23790. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23791. /**
  23792. * Creates a new index buffer
  23793. * @param indices defines the indices to store in the index buffer
  23794. * @param totalVertices defines the total number of vertices (could be null)
  23795. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23796. */
  23797. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23798. }
  23799. /**
  23800. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23801. */
  23802. export class VertexData {
  23803. /**
  23804. * Mesh side orientation : usually the external or front surface
  23805. */
  23806. static readonly FRONTSIDE: number;
  23807. /**
  23808. * Mesh side orientation : usually the internal or back surface
  23809. */
  23810. static readonly BACKSIDE: number;
  23811. /**
  23812. * Mesh side orientation : both internal and external or front and back surfaces
  23813. */
  23814. static readonly DOUBLESIDE: number;
  23815. /**
  23816. * Mesh side orientation : by default, `FRONTSIDE`
  23817. */
  23818. static readonly DEFAULTSIDE: number;
  23819. /**
  23820. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23821. */
  23822. positions: Nullable<FloatArray>;
  23823. /**
  23824. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23825. */
  23826. normals: Nullable<FloatArray>;
  23827. /**
  23828. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23829. */
  23830. tangents: Nullable<FloatArray>;
  23831. /**
  23832. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23833. */
  23834. uvs: Nullable<FloatArray>;
  23835. /**
  23836. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23837. */
  23838. uvs2: Nullable<FloatArray>;
  23839. /**
  23840. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23841. */
  23842. uvs3: Nullable<FloatArray>;
  23843. /**
  23844. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23845. */
  23846. uvs4: Nullable<FloatArray>;
  23847. /**
  23848. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23849. */
  23850. uvs5: Nullable<FloatArray>;
  23851. /**
  23852. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23853. */
  23854. uvs6: Nullable<FloatArray>;
  23855. /**
  23856. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23857. */
  23858. colors: Nullable<FloatArray>;
  23859. /**
  23860. * 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).
  23861. */
  23862. matricesIndices: Nullable<FloatArray>;
  23863. /**
  23864. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23865. */
  23866. matricesWeights: Nullable<FloatArray>;
  23867. /**
  23868. * An array extending the number of possible indices
  23869. */
  23870. matricesIndicesExtra: Nullable<FloatArray>;
  23871. /**
  23872. * An array extending the number of possible weights when the number of indices is extended
  23873. */
  23874. matricesWeightsExtra: Nullable<FloatArray>;
  23875. /**
  23876. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23877. */
  23878. indices: Nullable<IndicesArray>;
  23879. /**
  23880. * Uses the passed data array to set the set the values for the specified kind of data
  23881. * @param data a linear array of floating numbers
  23882. * @param kind the type of data that is being set, eg positions, colors etc
  23883. */
  23884. set(data: FloatArray, kind: string): void;
  23885. /**
  23886. * Associates the vertexData to the passed Mesh.
  23887. * Sets it as updatable or not (default `false`)
  23888. * @param mesh the mesh the vertexData is applied to
  23889. * @param updatable when used and having the value true allows new data to update the vertexData
  23890. * @returns the VertexData
  23891. */
  23892. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23893. /**
  23894. * Associates the vertexData to the passed Geometry.
  23895. * Sets it as updatable or not (default `false`)
  23896. * @param geometry the geometry the vertexData is applied to
  23897. * @param updatable when used and having the value true allows new data to update the vertexData
  23898. * @returns VertexData
  23899. */
  23900. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23901. /**
  23902. * Updates the associated mesh
  23903. * @param mesh the mesh to be updated
  23904. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23905. * @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
  23906. * @returns VertexData
  23907. */
  23908. updateMesh(mesh: Mesh): VertexData;
  23909. /**
  23910. * Updates the associated geometry
  23911. * @param geometry the geometry to be updated
  23912. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23913. * @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
  23914. * @returns VertexData.
  23915. */
  23916. updateGeometry(geometry: Geometry): VertexData;
  23917. private _applyTo;
  23918. private _update;
  23919. /**
  23920. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23921. * @param matrix the transforming matrix
  23922. * @returns the VertexData
  23923. */
  23924. transform(matrix: Matrix): VertexData;
  23925. /**
  23926. * Merges the passed VertexData into the current one
  23927. * @param other the VertexData to be merged into the current one
  23928. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23929. * @returns the modified VertexData
  23930. */
  23931. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23932. private _mergeElement;
  23933. private _validate;
  23934. /**
  23935. * Serializes the VertexData
  23936. * @returns a serialized object
  23937. */
  23938. serialize(): any;
  23939. /**
  23940. * Extracts the vertexData from a mesh
  23941. * @param mesh the mesh from which to extract the VertexData
  23942. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23943. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23944. * @returns the object VertexData associated to the passed mesh
  23945. */
  23946. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23947. /**
  23948. * Extracts the vertexData from the geometry
  23949. * @param geometry the geometry from which to extract the VertexData
  23950. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23951. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23952. * @returns the object VertexData associated to the passed mesh
  23953. */
  23954. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23955. private static _ExtractFrom;
  23956. /**
  23957. * Creates the VertexData for a Ribbon
  23958. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23959. * * pathArray array of paths, each of which an array of successive Vector3
  23960. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23961. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23962. * * 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
  23963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23964. * * 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)
  23965. * * 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)
  23966. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23967. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23968. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23969. * @returns the VertexData of the ribbon
  23970. */
  23971. static CreateRibbon(options: {
  23972. pathArray: Vector3[][];
  23973. closeArray?: boolean;
  23974. closePath?: boolean;
  23975. offset?: number;
  23976. sideOrientation?: number;
  23977. frontUVs?: Vector4;
  23978. backUVs?: Vector4;
  23979. invertUV?: boolean;
  23980. uvs?: Vector2[];
  23981. colors?: Color4[];
  23982. }): VertexData;
  23983. /**
  23984. * Creates the VertexData for a box
  23985. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23986. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23987. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23988. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23989. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23990. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23991. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23993. * * 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)
  23994. * * 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)
  23995. * @returns the VertexData of the box
  23996. */
  23997. static CreateBox(options: {
  23998. size?: number;
  23999. width?: number;
  24000. height?: number;
  24001. depth?: number;
  24002. faceUV?: Vector4[];
  24003. faceColors?: Color4[];
  24004. sideOrientation?: number;
  24005. frontUVs?: Vector4;
  24006. backUVs?: Vector4;
  24007. }): VertexData;
  24008. /**
  24009. * Creates the VertexData for a tiled box
  24010. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24011. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24012. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24013. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24015. * @returns the VertexData of the box
  24016. */
  24017. static CreateTiledBox(options: {
  24018. pattern?: number;
  24019. width?: number;
  24020. height?: number;
  24021. depth?: number;
  24022. tileSize?: number;
  24023. tileWidth?: number;
  24024. tileHeight?: number;
  24025. alignHorizontal?: number;
  24026. alignVertical?: number;
  24027. faceUV?: Vector4[];
  24028. faceColors?: Color4[];
  24029. sideOrientation?: number;
  24030. }): VertexData;
  24031. /**
  24032. * Creates the VertexData for a tiled plane
  24033. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24034. * * pattern a limited pattern arrangement depending on the number
  24035. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24036. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24037. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24038. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24039. * * 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)
  24040. * * 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)
  24041. * @returns the VertexData of the tiled plane
  24042. */
  24043. static CreateTiledPlane(options: {
  24044. pattern?: number;
  24045. tileSize?: number;
  24046. tileWidth?: number;
  24047. tileHeight?: number;
  24048. size?: number;
  24049. width?: number;
  24050. height?: number;
  24051. alignHorizontal?: number;
  24052. alignVertical?: number;
  24053. sideOrientation?: number;
  24054. frontUVs?: Vector4;
  24055. backUVs?: Vector4;
  24056. }): VertexData;
  24057. /**
  24058. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24059. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24060. * * segments sets the number of horizontal strips optional, default 32
  24061. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24062. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24063. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24064. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24065. * * 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
  24066. * * 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
  24067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24068. * * 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)
  24069. * * 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)
  24070. * @returns the VertexData of the ellipsoid
  24071. */
  24072. static CreateSphere(options: {
  24073. segments?: number;
  24074. diameter?: number;
  24075. diameterX?: number;
  24076. diameterY?: number;
  24077. diameterZ?: number;
  24078. arc?: number;
  24079. slice?: number;
  24080. sideOrientation?: number;
  24081. frontUVs?: Vector4;
  24082. backUVs?: Vector4;
  24083. }): VertexData;
  24084. /**
  24085. * Creates the VertexData for a cylinder, cone or prism
  24086. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24087. * * height sets the height (y direction) of the cylinder, optional, default 2
  24088. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24089. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24090. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24091. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24092. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24093. * * 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
  24094. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24095. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24096. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24097. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24098. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24099. * * 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)
  24100. * * 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)
  24101. * @returns the VertexData of the cylinder, cone or prism
  24102. */
  24103. static CreateCylinder(options: {
  24104. height?: number;
  24105. diameterTop?: number;
  24106. diameterBottom?: number;
  24107. diameter?: number;
  24108. tessellation?: number;
  24109. subdivisions?: number;
  24110. arc?: number;
  24111. faceColors?: Color4[];
  24112. faceUV?: Vector4[];
  24113. hasRings?: boolean;
  24114. enclose?: boolean;
  24115. sideOrientation?: number;
  24116. frontUVs?: Vector4;
  24117. backUVs?: Vector4;
  24118. }): VertexData;
  24119. /**
  24120. * Creates the VertexData for a torus
  24121. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24122. * * diameter the diameter of the torus, optional default 1
  24123. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24124. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24125. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24126. * * 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)
  24127. * * 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)
  24128. * @returns the VertexData of the torus
  24129. */
  24130. static CreateTorus(options: {
  24131. diameter?: number;
  24132. thickness?: number;
  24133. tessellation?: number;
  24134. sideOrientation?: number;
  24135. frontUVs?: Vector4;
  24136. backUVs?: Vector4;
  24137. }): VertexData;
  24138. /**
  24139. * Creates the VertexData of the LineSystem
  24140. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24141. * - lines an array of lines, each line being an array of successive Vector3
  24142. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24143. * @returns the VertexData of the LineSystem
  24144. */
  24145. static CreateLineSystem(options: {
  24146. lines: Vector3[][];
  24147. colors?: Nullable<Color4[][]>;
  24148. }): VertexData;
  24149. /**
  24150. * Create the VertexData for a DashedLines
  24151. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24152. * - points an array successive Vector3
  24153. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24154. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24155. * - dashNb the intended total number of dashes, optional, default 200
  24156. * @returns the VertexData for the DashedLines
  24157. */
  24158. static CreateDashedLines(options: {
  24159. points: Vector3[];
  24160. dashSize?: number;
  24161. gapSize?: number;
  24162. dashNb?: number;
  24163. }): VertexData;
  24164. /**
  24165. * Creates the VertexData for a Ground
  24166. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24167. * - width the width (x direction) of the ground, optional, default 1
  24168. * - height the height (z direction) of the ground, optional, default 1
  24169. * - subdivisions the number of subdivisions per side, optional, default 1
  24170. * @returns the VertexData of the Ground
  24171. */
  24172. static CreateGround(options: {
  24173. width?: number;
  24174. height?: number;
  24175. subdivisions?: number;
  24176. subdivisionsX?: number;
  24177. subdivisionsY?: number;
  24178. }): VertexData;
  24179. /**
  24180. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24181. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24182. * * xmin the ground minimum X coordinate, optional, default -1
  24183. * * zmin the ground minimum Z coordinate, optional, default -1
  24184. * * xmax the ground maximum X coordinate, optional, default 1
  24185. * * zmax the ground maximum Z coordinate, optional, default 1
  24186. * * 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}
  24187. * * 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}
  24188. * @returns the VertexData of the TiledGround
  24189. */
  24190. static CreateTiledGround(options: {
  24191. xmin: number;
  24192. zmin: number;
  24193. xmax: number;
  24194. zmax: number;
  24195. subdivisions?: {
  24196. w: number;
  24197. h: number;
  24198. };
  24199. precision?: {
  24200. w: number;
  24201. h: number;
  24202. };
  24203. }): VertexData;
  24204. /**
  24205. * Creates the VertexData of the Ground designed from a heightmap
  24206. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24207. * * width the width (x direction) of the ground
  24208. * * height the height (z direction) of the ground
  24209. * * subdivisions the number of subdivisions per side
  24210. * * minHeight the minimum altitude on the ground, optional, default 0
  24211. * * maxHeight the maximum altitude on the ground, optional default 1
  24212. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24213. * * buffer the array holding the image color data
  24214. * * bufferWidth the width of image
  24215. * * bufferHeight the height of image
  24216. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24217. * @returns the VertexData of the Ground designed from a heightmap
  24218. */
  24219. static CreateGroundFromHeightMap(options: {
  24220. width: number;
  24221. height: number;
  24222. subdivisions: number;
  24223. minHeight: number;
  24224. maxHeight: number;
  24225. colorFilter: Color3;
  24226. buffer: Uint8Array;
  24227. bufferWidth: number;
  24228. bufferHeight: number;
  24229. alphaFilter: number;
  24230. }): VertexData;
  24231. /**
  24232. * Creates the VertexData for a Plane
  24233. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24234. * * size sets the width and height of the plane to the value of size, optional default 1
  24235. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24236. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24238. * * 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)
  24239. * * 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)
  24240. * @returns the VertexData of the box
  24241. */
  24242. static CreatePlane(options: {
  24243. size?: number;
  24244. width?: number;
  24245. height?: number;
  24246. sideOrientation?: number;
  24247. frontUVs?: Vector4;
  24248. backUVs?: Vector4;
  24249. }): VertexData;
  24250. /**
  24251. * Creates the VertexData of the Disc or regular Polygon
  24252. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24253. * * radius the radius of the disc, optional default 0.5
  24254. * * tessellation the number of polygon sides, optional, default 64
  24255. * * 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
  24256. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24257. * * 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)
  24258. * * 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)
  24259. * @returns the VertexData of the box
  24260. */
  24261. static CreateDisc(options: {
  24262. radius?: number;
  24263. tessellation?: number;
  24264. arc?: number;
  24265. sideOrientation?: number;
  24266. frontUVs?: Vector4;
  24267. backUVs?: Vector4;
  24268. }): VertexData;
  24269. /**
  24270. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24271. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24272. * @param polygon a mesh built from polygonTriangulation.build()
  24273. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24274. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24275. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24276. * @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)
  24277. * @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)
  24278. * @returns the VertexData of the Polygon
  24279. */
  24280. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24281. /**
  24282. * Creates the VertexData of the IcoSphere
  24283. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24284. * * radius the radius of the IcoSphere, optional default 1
  24285. * * radiusX allows stretching in the x direction, optional, default radius
  24286. * * radiusY allows stretching in the y direction, optional, default radius
  24287. * * radiusZ allows stretching in the z direction, optional, default radius
  24288. * * flat when true creates a flat shaded mesh, optional, default true
  24289. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24291. * * 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)
  24292. * * 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)
  24293. * @returns the VertexData of the IcoSphere
  24294. */
  24295. static CreateIcoSphere(options: {
  24296. radius?: number;
  24297. radiusX?: number;
  24298. radiusY?: number;
  24299. radiusZ?: number;
  24300. flat?: boolean;
  24301. subdivisions?: number;
  24302. sideOrientation?: number;
  24303. frontUVs?: Vector4;
  24304. backUVs?: Vector4;
  24305. }): VertexData;
  24306. /**
  24307. * Creates the VertexData for a Polyhedron
  24308. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24309. * * type provided types are:
  24310. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24311. * * 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)
  24312. * * size the size of the IcoSphere, optional default 1
  24313. * * sizeX allows stretching in the x direction, optional, default size
  24314. * * sizeY allows stretching in the y direction, optional, default size
  24315. * * sizeZ allows stretching in the z direction, optional, default size
  24316. * * 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
  24317. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24318. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24319. * * flat when true creates a flat shaded mesh, optional, default true
  24320. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24322. * * 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)
  24323. * * 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)
  24324. * @returns the VertexData of the Polyhedron
  24325. */
  24326. static CreatePolyhedron(options: {
  24327. type?: number;
  24328. size?: number;
  24329. sizeX?: number;
  24330. sizeY?: number;
  24331. sizeZ?: number;
  24332. custom?: any;
  24333. faceUV?: Vector4[];
  24334. faceColors?: Color4[];
  24335. flat?: boolean;
  24336. sideOrientation?: number;
  24337. frontUVs?: Vector4;
  24338. backUVs?: Vector4;
  24339. }): VertexData;
  24340. /**
  24341. * Creates the VertexData for a TorusKnot
  24342. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24343. * * radius the radius of the torus knot, optional, default 2
  24344. * * tube the thickness of the tube, optional, default 0.5
  24345. * * radialSegments the number of sides on each tube segments, optional, default 32
  24346. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24347. * * p the number of windings around the z axis, optional, default 2
  24348. * * q the number of windings around the x axis, optional, default 3
  24349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24350. * * 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)
  24351. * * 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)
  24352. * @returns the VertexData of the Torus Knot
  24353. */
  24354. static CreateTorusKnot(options: {
  24355. radius?: number;
  24356. tube?: number;
  24357. radialSegments?: number;
  24358. tubularSegments?: number;
  24359. p?: number;
  24360. q?: number;
  24361. sideOrientation?: number;
  24362. frontUVs?: Vector4;
  24363. backUVs?: Vector4;
  24364. }): VertexData;
  24365. /**
  24366. * Compute normals for given positions and indices
  24367. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24368. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24369. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24370. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24371. * * facetNormals : optional array of facet normals (vector3)
  24372. * * facetPositions : optional array of facet positions (vector3)
  24373. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24374. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24375. * * bInfo : optional bounding info, required for facetPartitioning computation
  24376. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24377. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24378. * * useRightHandedSystem: optional boolean to for right handed system computation
  24379. * * depthSort : optional boolean to enable the facet depth sort computation
  24380. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24381. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24382. */
  24383. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24384. facetNormals?: any;
  24385. facetPositions?: any;
  24386. facetPartitioning?: any;
  24387. ratio?: number;
  24388. bInfo?: any;
  24389. bbSize?: Vector3;
  24390. subDiv?: any;
  24391. useRightHandedSystem?: boolean;
  24392. depthSort?: boolean;
  24393. distanceTo?: Vector3;
  24394. depthSortedFacets?: any;
  24395. }): void;
  24396. /** @hidden */
  24397. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24398. /**
  24399. * Applies VertexData created from the imported parameters to the geometry
  24400. * @param parsedVertexData the parsed data from an imported file
  24401. * @param geometry the geometry to apply the VertexData to
  24402. */
  24403. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24404. }
  24405. }
  24406. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24407. import { Nullable } from "babylonjs/types";
  24408. import { Scene } from "babylonjs/scene";
  24409. import { Vector4 } from "babylonjs/Maths/math";
  24410. import { Mesh } from "babylonjs/Meshes/mesh";
  24411. /**
  24412. * Class containing static functions to help procedurally build meshes
  24413. */
  24414. export class DiscBuilder {
  24415. /**
  24416. * Creates a plane polygonal mesh. By default, this is a disc
  24417. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24418. * * 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
  24419. * * 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
  24420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24423. * @param name defines the name of the mesh
  24424. * @param options defines the options used to create the mesh
  24425. * @param scene defines the hosting scene
  24426. * @returns the plane polygonal mesh
  24427. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24428. */
  24429. static CreateDisc(name: string, options: {
  24430. radius?: number;
  24431. tessellation?: number;
  24432. arc?: number;
  24433. updatable?: boolean;
  24434. sideOrientation?: number;
  24435. frontUVs?: Vector4;
  24436. backUVs?: Vector4;
  24437. }, scene?: Nullable<Scene>): Mesh;
  24438. }
  24439. }
  24440. declare module "babylonjs/Particles/solidParticleSystem" {
  24441. import { Vector3 } from "babylonjs/Maths/math";
  24442. import { Mesh } from "babylonjs/Meshes/mesh";
  24443. import { Scene, IDisposable } from "babylonjs/scene";
  24444. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24445. /**
  24446. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24447. *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.
  24448. * The SPS is also a particle system. It provides some methods to manage the particles.
  24449. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24450. *
  24451. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24452. */
  24453. export class SolidParticleSystem implements IDisposable {
  24454. /**
  24455. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24456. * Example : var p = SPS.particles[i];
  24457. */
  24458. particles: SolidParticle[];
  24459. /**
  24460. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24461. */
  24462. nbParticles: number;
  24463. /**
  24464. * If the particles must ever face the camera (default false). Useful for planar particles.
  24465. */
  24466. billboard: boolean;
  24467. /**
  24468. * Recompute normals when adding a shape
  24469. */
  24470. recomputeNormals: boolean;
  24471. /**
  24472. * This a counter ofr your own usage. It's not set by any SPS functions.
  24473. */
  24474. counter: number;
  24475. /**
  24476. * The SPS name. This name is also given to the underlying mesh.
  24477. */
  24478. name: string;
  24479. /**
  24480. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24481. */
  24482. mesh: Mesh;
  24483. /**
  24484. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24485. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24486. */
  24487. vars: any;
  24488. /**
  24489. * This array is populated when the SPS is set as 'pickable'.
  24490. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24491. * Each element of this array is an object `{idx: int, faceId: int}`.
  24492. * `idx` is the picked particle index in the `SPS.particles` array
  24493. * `faceId` is the picked face index counted within this particle.
  24494. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24495. */
  24496. pickedParticles: {
  24497. idx: number;
  24498. faceId: number;
  24499. }[];
  24500. /**
  24501. * This array is populated when `enableDepthSort` is set to true.
  24502. * Each element of this array is an instance of the class DepthSortedParticle.
  24503. */
  24504. depthSortedParticles: DepthSortedParticle[];
  24505. /**
  24506. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24507. * @hidden
  24508. */
  24509. _bSphereOnly: boolean;
  24510. /**
  24511. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24512. * @hidden
  24513. */
  24514. _bSphereRadiusFactor: number;
  24515. private _scene;
  24516. private _positions;
  24517. private _indices;
  24518. private _normals;
  24519. private _colors;
  24520. private _uvs;
  24521. private _indices32;
  24522. private _positions32;
  24523. private _normals32;
  24524. private _fixedNormal32;
  24525. private _colors32;
  24526. private _uvs32;
  24527. private _index;
  24528. private _updatable;
  24529. private _pickable;
  24530. private _isVisibilityBoxLocked;
  24531. private _alwaysVisible;
  24532. private _depthSort;
  24533. private _shapeCounter;
  24534. private _copy;
  24535. private _color;
  24536. private _computeParticleColor;
  24537. private _computeParticleTexture;
  24538. private _computeParticleRotation;
  24539. private _computeParticleVertex;
  24540. private _computeBoundingBox;
  24541. private _depthSortParticles;
  24542. private _camera;
  24543. private _mustUnrotateFixedNormals;
  24544. private _particlesIntersect;
  24545. private _needs32Bits;
  24546. /**
  24547. * Creates a SPS (Solid Particle System) object.
  24548. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24549. * @param scene (Scene) is the scene in which the SPS is added.
  24550. * @param options defines the options of the sps e.g.
  24551. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24552. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24553. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24554. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24555. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24556. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24557. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24558. */
  24559. constructor(name: string, scene: Scene, options?: {
  24560. updatable?: boolean;
  24561. isPickable?: boolean;
  24562. enableDepthSort?: boolean;
  24563. particleIntersection?: boolean;
  24564. boundingSphereOnly?: boolean;
  24565. bSphereRadiusFactor?: number;
  24566. });
  24567. /**
  24568. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24569. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24570. * @returns the created mesh
  24571. */
  24572. buildMesh(): Mesh;
  24573. /**
  24574. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24575. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24576. * Thus the particles generated from `digest()` have their property `position` set yet.
  24577. * @param mesh ( Mesh ) is the mesh to be digested
  24578. * @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
  24579. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24580. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24581. * @returns the current SPS
  24582. */
  24583. digest(mesh: Mesh, options?: {
  24584. facetNb?: number;
  24585. number?: number;
  24586. delta?: number;
  24587. }): SolidParticleSystem;
  24588. private _unrotateFixedNormals;
  24589. private _resetCopy;
  24590. private _meshBuilder;
  24591. private _posToShape;
  24592. private _uvsToShapeUV;
  24593. private _addParticle;
  24594. /**
  24595. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24596. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24597. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24598. * @param nb (positive integer) the number of particles to be created from this model
  24599. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24600. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24601. * @returns the number of shapes in the system
  24602. */
  24603. addShape(mesh: Mesh, nb: number, options?: {
  24604. positionFunction?: any;
  24605. vertexFunction?: any;
  24606. }): number;
  24607. private _rebuildParticle;
  24608. /**
  24609. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24610. * @returns the SPS.
  24611. */
  24612. rebuildMesh(): SolidParticleSystem;
  24613. /**
  24614. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24615. * This method calls `updateParticle()` for each particle of the SPS.
  24616. * For an animated SPS, it is usually called within the render loop.
  24617. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24618. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24619. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24620. * @returns the SPS.
  24621. */
  24622. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24623. /**
  24624. * Disposes the SPS.
  24625. */
  24626. dispose(): void;
  24627. /**
  24628. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24629. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24630. * @returns the SPS.
  24631. */
  24632. refreshVisibleSize(): SolidParticleSystem;
  24633. /**
  24634. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24635. * @param size the size (float) of the visibility box
  24636. * note : this doesn't lock the SPS mesh bounding box.
  24637. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24638. */
  24639. setVisibilityBox(size: number): void;
  24640. /**
  24641. * Gets whether the SPS as always visible or not
  24642. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24643. */
  24644. /**
  24645. * Sets the SPS as always visible or not
  24646. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24647. */
  24648. isAlwaysVisible: boolean;
  24649. /**
  24650. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24651. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24652. */
  24653. /**
  24654. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24655. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24656. */
  24657. isVisibilityBoxLocked: boolean;
  24658. /**
  24659. * Tells to `setParticles()` to compute the particle rotations or not.
  24660. * Default value : true. The SPS is faster when it's set to false.
  24661. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24662. */
  24663. /**
  24664. * Gets if `setParticles()` computes the particle rotations or not.
  24665. * Default value : true. The SPS is faster when it's set to false.
  24666. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24667. */
  24668. computeParticleRotation: boolean;
  24669. /**
  24670. * Tells to `setParticles()` to compute the particle colors or not.
  24671. * Default value : true. The SPS is faster when it's set to false.
  24672. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24673. */
  24674. /**
  24675. * Gets if `setParticles()` computes the particle colors or not.
  24676. * Default value : true. The SPS is faster when it's set to false.
  24677. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24678. */
  24679. computeParticleColor: boolean;
  24680. /**
  24681. * Gets if `setParticles()` computes the particle textures or not.
  24682. * Default value : true. The SPS is faster when it's set to false.
  24683. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24684. */
  24685. computeParticleTexture: boolean;
  24686. /**
  24687. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24688. * Default value : false. The SPS is faster when it's set to false.
  24689. * Note : the particle custom vertex positions aren't stored values.
  24690. */
  24691. /**
  24692. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24693. * Default value : false. The SPS is faster when it's set to false.
  24694. * Note : the particle custom vertex positions aren't stored values.
  24695. */
  24696. computeParticleVertex: boolean;
  24697. /**
  24698. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24699. */
  24700. /**
  24701. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24702. */
  24703. computeBoundingBox: boolean;
  24704. /**
  24705. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24706. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24707. * Default : `true`
  24708. */
  24709. /**
  24710. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24711. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24712. * Default : `true`
  24713. */
  24714. depthSortParticles: boolean;
  24715. /**
  24716. * This function does nothing. It may be overwritten to set all the particle first values.
  24717. * The SPS doesn't call this function, you may have to call it by your own.
  24718. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24719. */
  24720. initParticles(): void;
  24721. /**
  24722. * This function does nothing. It may be overwritten to recycle a particle.
  24723. * The SPS doesn't call this function, you may have to call it by your own.
  24724. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24725. * @param particle The particle to recycle
  24726. * @returns the recycled particle
  24727. */
  24728. recycleParticle(particle: SolidParticle): SolidParticle;
  24729. /**
  24730. * Updates a particle : this function should be overwritten by the user.
  24731. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24732. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24733. * @example : just set a particle position or velocity and recycle conditions
  24734. * @param particle The particle to update
  24735. * @returns the updated particle
  24736. */
  24737. updateParticle(particle: SolidParticle): SolidParticle;
  24738. /**
  24739. * Updates a vertex of a particle : it can be overwritten by the user.
  24740. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24741. * @param particle the current particle
  24742. * @param vertex the current index of the current particle
  24743. * @param pt the index of the current vertex in the particle shape
  24744. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24745. * @example : just set a vertex particle position
  24746. * @returns the updated vertex
  24747. */
  24748. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24749. /**
  24750. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24751. * This does nothing and may be overwritten by the user.
  24752. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24753. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24754. * @param update the boolean update value actually passed to setParticles()
  24755. */
  24756. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24757. /**
  24758. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24759. * This will be passed three parameters.
  24760. * This does nothing and may be overwritten by the user.
  24761. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24762. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24763. * @param update the boolean update value actually passed to setParticles()
  24764. */
  24765. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24766. }
  24767. }
  24768. declare module "babylonjs/Particles/solidParticle" {
  24769. import { Nullable } from "babylonjs/types";
  24770. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24771. import { Mesh } from "babylonjs/Meshes/mesh";
  24772. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24773. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24774. /**
  24775. * Represents one particle of a solid particle system.
  24776. */
  24777. export class SolidParticle {
  24778. /**
  24779. * particle global index
  24780. */
  24781. idx: number;
  24782. /**
  24783. * The color of the particle
  24784. */
  24785. color: Nullable<Color4>;
  24786. /**
  24787. * The world space position of the particle.
  24788. */
  24789. position: Vector3;
  24790. /**
  24791. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24792. */
  24793. rotation: Vector3;
  24794. /**
  24795. * The world space rotation quaternion of the particle.
  24796. */
  24797. rotationQuaternion: Nullable<Quaternion>;
  24798. /**
  24799. * The scaling of the particle.
  24800. */
  24801. scaling: Vector3;
  24802. /**
  24803. * The uvs of the particle.
  24804. */
  24805. uvs: Vector4;
  24806. /**
  24807. * The current speed of the particle.
  24808. */
  24809. velocity: Vector3;
  24810. /**
  24811. * The pivot point in the particle local space.
  24812. */
  24813. pivot: Vector3;
  24814. /**
  24815. * Must the particle be translated from its pivot point in its local space ?
  24816. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24817. * Default : false
  24818. */
  24819. translateFromPivot: boolean;
  24820. /**
  24821. * Is the particle active or not ?
  24822. */
  24823. alive: boolean;
  24824. /**
  24825. * Is the particle visible or not ?
  24826. */
  24827. isVisible: boolean;
  24828. /**
  24829. * Index of this particle in the global "positions" array (Internal use)
  24830. * @hidden
  24831. */
  24832. _pos: number;
  24833. /**
  24834. * @hidden Index of this particle in the global "indices" array (Internal use)
  24835. */
  24836. _ind: number;
  24837. /**
  24838. * @hidden ModelShape of this particle (Internal use)
  24839. */
  24840. _model: ModelShape;
  24841. /**
  24842. * ModelShape id of this particle
  24843. */
  24844. shapeId: number;
  24845. /**
  24846. * Index of the particle in its shape id (Internal use)
  24847. */
  24848. idxInShape: number;
  24849. /**
  24850. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24851. */
  24852. _modelBoundingInfo: BoundingInfo;
  24853. /**
  24854. * @hidden Particle BoundingInfo object (Internal use)
  24855. */
  24856. _boundingInfo: BoundingInfo;
  24857. /**
  24858. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24859. */
  24860. _sps: SolidParticleSystem;
  24861. /**
  24862. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24863. */
  24864. _stillInvisible: boolean;
  24865. /**
  24866. * @hidden Last computed particle rotation matrix
  24867. */
  24868. _rotationMatrix: number[];
  24869. /**
  24870. * Parent particle Id, if any.
  24871. * Default null.
  24872. */
  24873. parentId: Nullable<number>;
  24874. /**
  24875. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24876. * The possible values are :
  24877. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24878. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24879. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24880. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24881. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24882. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24883. * */
  24884. cullingStrategy: number;
  24885. /**
  24886. * @hidden Internal global position in the SPS.
  24887. */
  24888. _globalPosition: Vector3;
  24889. /**
  24890. * Creates a Solid Particle object.
  24891. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24892. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24893. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24894. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24895. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24896. * @param shapeId (integer) is the model shape identifier in the SPS.
  24897. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24898. * @param sps defines the sps it is associated to
  24899. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24900. */
  24901. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24902. /**
  24903. * Legacy support, changed scale to scaling
  24904. */
  24905. /**
  24906. * Legacy support, changed scale to scaling
  24907. */
  24908. scale: Vector3;
  24909. /**
  24910. * Legacy support, changed quaternion to rotationQuaternion
  24911. */
  24912. /**
  24913. * Legacy support, changed quaternion to rotationQuaternion
  24914. */
  24915. quaternion: Nullable<Quaternion>;
  24916. /**
  24917. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24918. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24919. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24920. * @returns true if it intersects
  24921. */
  24922. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24923. /**
  24924. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24925. * A particle is in the frustum if its bounding box intersects the frustum
  24926. * @param frustumPlanes defines the frustum to test
  24927. * @returns true if the particle is in the frustum planes
  24928. */
  24929. isInFrustum(frustumPlanes: Plane[]): boolean;
  24930. /**
  24931. * get the rotation matrix of the particle
  24932. * @hidden
  24933. */
  24934. getRotationMatrix(m: Matrix): void;
  24935. }
  24936. /**
  24937. * Represents the shape of the model used by one particle of a solid particle system.
  24938. * SPS internal tool, don't use it manually.
  24939. */
  24940. export class ModelShape {
  24941. /**
  24942. * The shape id
  24943. * @hidden
  24944. */
  24945. shapeID: number;
  24946. /**
  24947. * flat array of model positions (internal use)
  24948. * @hidden
  24949. */
  24950. _shape: Vector3[];
  24951. /**
  24952. * flat array of model UVs (internal use)
  24953. * @hidden
  24954. */
  24955. _shapeUV: number[];
  24956. /**
  24957. * length of the shape in the model indices array (internal use)
  24958. * @hidden
  24959. */
  24960. _indicesLength: number;
  24961. /**
  24962. * Custom position function (internal use)
  24963. * @hidden
  24964. */
  24965. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24966. /**
  24967. * Custom vertex function (internal use)
  24968. * @hidden
  24969. */
  24970. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24971. /**
  24972. * 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.
  24973. * SPS internal tool, don't use it manually.
  24974. * @hidden
  24975. */
  24976. 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>);
  24977. }
  24978. /**
  24979. * Represents a Depth Sorted Particle in the solid particle system.
  24980. */
  24981. export class DepthSortedParticle {
  24982. /**
  24983. * Index of the particle in the "indices" array
  24984. */
  24985. ind: number;
  24986. /**
  24987. * Length of the particle shape in the "indices" array
  24988. */
  24989. indicesLength: number;
  24990. /**
  24991. * Squared distance from the particle to the camera
  24992. */
  24993. sqDistance: number;
  24994. }
  24995. }
  24996. declare module "babylonjs/Collisions/meshCollisionData" {
  24997. import { Collider } from "babylonjs/Collisions/collider";
  24998. import { Vector3 } from "babylonjs/Maths/math";
  24999. import { Nullable } from "babylonjs/types";
  25000. import { Observer } from "babylonjs/Misc/observable";
  25001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25002. /**
  25003. * @hidden
  25004. */
  25005. export class _MeshCollisionData {
  25006. _checkCollisions: boolean;
  25007. _collisionMask: number;
  25008. _collisionGroup: number;
  25009. _collider: Nullable<Collider>;
  25010. _oldPositionForCollisions: Vector3;
  25011. _diffPositionForCollisions: Vector3;
  25012. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25013. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25014. }
  25015. }
  25016. declare module "babylonjs/Meshes/abstractMesh" {
  25017. import { Observable } from "babylonjs/Misc/observable";
  25018. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25019. import { Camera } from "babylonjs/Cameras/camera";
  25020. import { Scene, IDisposable } from "babylonjs/scene";
  25021. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25022. import { Node } from "babylonjs/node";
  25023. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25024. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25025. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25026. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25027. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25028. import { Material } from "babylonjs/Materials/material";
  25029. import { Light } from "babylonjs/Lights/light";
  25030. import { Skeleton } from "babylonjs/Bones/skeleton";
  25031. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25032. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25033. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25034. import { Ray } from "babylonjs/Culling/ray";
  25035. import { Collider } from "babylonjs/Collisions/collider";
  25036. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25037. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25038. /** @hidden */
  25039. class _FacetDataStorage {
  25040. facetPositions: Vector3[];
  25041. facetNormals: Vector3[];
  25042. facetPartitioning: number[][];
  25043. facetNb: number;
  25044. partitioningSubdivisions: number;
  25045. partitioningBBoxRatio: number;
  25046. facetDataEnabled: boolean;
  25047. facetParameters: any;
  25048. bbSize: Vector3;
  25049. subDiv: {
  25050. max: number;
  25051. X: number;
  25052. Y: number;
  25053. Z: number;
  25054. };
  25055. facetDepthSort: boolean;
  25056. facetDepthSortEnabled: boolean;
  25057. depthSortedIndices: IndicesArray;
  25058. depthSortedFacets: {
  25059. ind: number;
  25060. sqDistance: number;
  25061. }[];
  25062. facetDepthSortFunction: (f1: {
  25063. ind: number;
  25064. sqDistance: number;
  25065. }, f2: {
  25066. ind: number;
  25067. sqDistance: number;
  25068. }) => number;
  25069. facetDepthSortFrom: Vector3;
  25070. facetDepthSortOrigin: Vector3;
  25071. invertedMatrix: Matrix;
  25072. }
  25073. /**
  25074. * @hidden
  25075. **/
  25076. class _InternalAbstractMeshDataInfo {
  25077. _hasVertexAlpha: boolean;
  25078. _useVertexColors: boolean;
  25079. _numBoneInfluencers: number;
  25080. _applyFog: boolean;
  25081. _receiveShadows: boolean;
  25082. _facetData: _FacetDataStorage;
  25083. _visibility: number;
  25084. _skeleton: Nullable<Skeleton>;
  25085. _layerMask: number;
  25086. _computeBonesUsingShaders: boolean;
  25087. _isActive: boolean;
  25088. _onlyForInstances: boolean;
  25089. _isActiveIntermediate: boolean;
  25090. _onlyForInstancesIntermediate: boolean;
  25091. }
  25092. /**
  25093. * Class used to store all common mesh properties
  25094. */
  25095. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25096. /** No occlusion */
  25097. static OCCLUSION_TYPE_NONE: number;
  25098. /** Occlusion set to optimisitic */
  25099. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25100. /** Occlusion set to strict */
  25101. static OCCLUSION_TYPE_STRICT: number;
  25102. /** Use an accurante occlusion algorithm */
  25103. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25104. /** Use a conservative occlusion algorithm */
  25105. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25106. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25107. * Test order :
  25108. * Is the bounding sphere outside the frustum ?
  25109. * If not, are the bounding box vertices outside the frustum ?
  25110. * It not, then the cullable object is in the frustum.
  25111. */
  25112. static readonly CULLINGSTRATEGY_STANDARD: number;
  25113. /** Culling strategy : Bounding Sphere Only.
  25114. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25115. * It's also less accurate than the standard because some not visible objects can still be selected.
  25116. * Test : is the bounding sphere outside the frustum ?
  25117. * If not, then the cullable object is in the frustum.
  25118. */
  25119. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25120. /** Culling strategy : Optimistic Inclusion.
  25121. * This in an inclusion test first, then the standard exclusion test.
  25122. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25123. * 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.
  25124. * Anyway, it's as accurate as the standard strategy.
  25125. * Test :
  25126. * Is the cullable object bounding sphere center in the frustum ?
  25127. * If not, apply the default culling strategy.
  25128. */
  25129. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25130. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25131. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25132. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25133. * 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.
  25134. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25135. * Test :
  25136. * Is the cullable object bounding sphere center in the frustum ?
  25137. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25138. */
  25139. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25140. /**
  25141. * No billboard
  25142. */
  25143. static readonly BILLBOARDMODE_NONE: number;
  25144. /** Billboard on X axis */
  25145. static readonly BILLBOARDMODE_X: number;
  25146. /** Billboard on Y axis */
  25147. static readonly BILLBOARDMODE_Y: number;
  25148. /** Billboard on Z axis */
  25149. static readonly BILLBOARDMODE_Z: number;
  25150. /** Billboard on all axes */
  25151. static readonly BILLBOARDMODE_ALL: number;
  25152. /** @hidden */
  25153. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25154. /**
  25155. * The culling strategy to use to check whether the mesh must be rendered or not.
  25156. * This value can be changed at any time and will be used on the next render mesh selection.
  25157. * The possible values are :
  25158. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25159. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25160. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25161. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25162. * Please read each static variable documentation to get details about the culling process.
  25163. * */
  25164. cullingStrategy: number;
  25165. /**
  25166. * Gets the number of facets in the mesh
  25167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25168. */
  25169. readonly facetNb: number;
  25170. /**
  25171. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25173. */
  25174. partitioningSubdivisions: number;
  25175. /**
  25176. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25177. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25179. */
  25180. partitioningBBoxRatio: number;
  25181. /**
  25182. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25183. * Works only for updatable meshes.
  25184. * Doesn't work with multi-materials
  25185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25186. */
  25187. mustDepthSortFacets: boolean;
  25188. /**
  25189. * The location (Vector3) where the facet depth sort must be computed from.
  25190. * By default, the active camera position.
  25191. * Used only when facet depth sort is enabled
  25192. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25193. */
  25194. facetDepthSortFrom: Vector3;
  25195. /**
  25196. * gets a boolean indicating if facetData is enabled
  25197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25198. */
  25199. readonly isFacetDataEnabled: boolean;
  25200. /** @hidden */
  25201. _updateNonUniformScalingState(value: boolean): boolean;
  25202. /**
  25203. * An event triggered when this mesh collides with another one
  25204. */
  25205. onCollideObservable: Observable<AbstractMesh>;
  25206. /** Set a function to call when this mesh collides with another one */
  25207. onCollide: () => void;
  25208. /**
  25209. * An event triggered when the collision's position changes
  25210. */
  25211. onCollisionPositionChangeObservable: Observable<Vector3>;
  25212. /** Set a function to call when the collision's position changes */
  25213. onCollisionPositionChange: () => void;
  25214. /**
  25215. * An event triggered when material is changed
  25216. */
  25217. onMaterialChangedObservable: Observable<AbstractMesh>;
  25218. /**
  25219. * Gets or sets the orientation for POV movement & rotation
  25220. */
  25221. definedFacingForward: boolean;
  25222. /** @hidden */
  25223. _occlusionQuery: Nullable<WebGLQuery>;
  25224. /** @hidden */
  25225. _renderingGroup: Nullable<RenderingGroup>;
  25226. /**
  25227. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25228. */
  25229. /**
  25230. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25231. */
  25232. visibility: number;
  25233. /** Gets or sets the alpha index used to sort transparent meshes
  25234. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25235. */
  25236. alphaIndex: number;
  25237. /**
  25238. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25239. */
  25240. isVisible: boolean;
  25241. /**
  25242. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25243. */
  25244. isPickable: boolean;
  25245. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25246. showSubMeshesBoundingBox: boolean;
  25247. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25248. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25249. */
  25250. isBlocker: boolean;
  25251. /**
  25252. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25253. */
  25254. enablePointerMoveEvents: boolean;
  25255. /**
  25256. * Specifies the rendering group id for this mesh (0 by default)
  25257. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25258. */
  25259. renderingGroupId: number;
  25260. private _material;
  25261. /** Gets or sets current material */
  25262. material: Nullable<Material>;
  25263. /**
  25264. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25265. * @see http://doc.babylonjs.com/babylon101/shadows
  25266. */
  25267. receiveShadows: boolean;
  25268. /** Defines color to use when rendering outline */
  25269. outlineColor: Color3;
  25270. /** Define width to use when rendering outline */
  25271. outlineWidth: number;
  25272. /** Defines color to use when rendering overlay */
  25273. overlayColor: Color3;
  25274. /** Defines alpha to use when rendering overlay */
  25275. overlayAlpha: number;
  25276. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25277. hasVertexAlpha: boolean;
  25278. /** 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) */
  25279. useVertexColors: boolean;
  25280. /**
  25281. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25282. */
  25283. computeBonesUsingShaders: boolean;
  25284. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25285. numBoneInfluencers: number;
  25286. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25287. applyFog: boolean;
  25288. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25289. useOctreeForRenderingSelection: boolean;
  25290. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25291. useOctreeForPicking: boolean;
  25292. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25293. useOctreeForCollisions: boolean;
  25294. /**
  25295. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25296. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25297. */
  25298. layerMask: number;
  25299. /**
  25300. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25301. */
  25302. alwaysSelectAsActiveMesh: boolean;
  25303. /**
  25304. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25305. */
  25306. doNotSyncBoundingInfo: boolean;
  25307. /**
  25308. * Gets or sets the current action manager
  25309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25310. */
  25311. actionManager: Nullable<AbstractActionManager>;
  25312. private _meshCollisionData;
  25313. /**
  25314. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25316. */
  25317. ellipsoid: Vector3;
  25318. /**
  25319. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25321. */
  25322. ellipsoidOffset: Vector3;
  25323. /**
  25324. * Gets or sets a collision mask used to mask collisions (default is -1).
  25325. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25326. */
  25327. collisionMask: number;
  25328. /**
  25329. * Gets or sets the current collision group mask (-1 by default).
  25330. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25331. */
  25332. collisionGroup: number;
  25333. /**
  25334. * Defines edge width used when edgesRenderer is enabled
  25335. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25336. */
  25337. edgesWidth: number;
  25338. /**
  25339. * Defines edge color used when edgesRenderer is enabled
  25340. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25341. */
  25342. edgesColor: Color4;
  25343. /** @hidden */
  25344. _edgesRenderer: Nullable<IEdgesRenderer>;
  25345. /** @hidden */
  25346. _masterMesh: Nullable<AbstractMesh>;
  25347. /** @hidden */
  25348. _boundingInfo: Nullable<BoundingInfo>;
  25349. /** @hidden */
  25350. _renderId: number;
  25351. /**
  25352. * Gets or sets the list of subMeshes
  25353. * @see http://doc.babylonjs.com/how_to/multi_materials
  25354. */
  25355. subMeshes: SubMesh[];
  25356. /** @hidden */
  25357. _intersectionsInProgress: AbstractMesh[];
  25358. /** @hidden */
  25359. _unIndexed: boolean;
  25360. /** @hidden */
  25361. _lightSources: Light[];
  25362. /** Gets the list of lights affecting that mesh */
  25363. readonly lightSources: Light[];
  25364. /** @hidden */
  25365. readonly _positions: Nullable<Vector3[]>;
  25366. /** @hidden */
  25367. _waitingData: {
  25368. lods: Nullable<any>;
  25369. actions: Nullable<any>;
  25370. freezeWorldMatrix: Nullable<boolean>;
  25371. };
  25372. /** @hidden */
  25373. _bonesTransformMatrices: Nullable<Float32Array>;
  25374. /**
  25375. * Gets or sets a skeleton to apply skining transformations
  25376. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25377. */
  25378. skeleton: Nullable<Skeleton>;
  25379. /**
  25380. * An event triggered when the mesh is rebuilt.
  25381. */
  25382. onRebuildObservable: Observable<AbstractMesh>;
  25383. /**
  25384. * Creates a new AbstractMesh
  25385. * @param name defines the name of the mesh
  25386. * @param scene defines the hosting scene
  25387. */
  25388. constructor(name: string, scene?: Nullable<Scene>);
  25389. /**
  25390. * Returns the string "AbstractMesh"
  25391. * @returns "AbstractMesh"
  25392. */
  25393. getClassName(): string;
  25394. /**
  25395. * Gets a string representation of the current mesh
  25396. * @param fullDetails defines a boolean indicating if full details must be included
  25397. * @returns a string representation of the current mesh
  25398. */
  25399. toString(fullDetails?: boolean): string;
  25400. /**
  25401. * @hidden
  25402. */
  25403. protected _getEffectiveParent(): Nullable<Node>;
  25404. /** @hidden */
  25405. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25406. /** @hidden */
  25407. _rebuild(): void;
  25408. /** @hidden */
  25409. _resyncLightSources(): void;
  25410. /** @hidden */
  25411. _resyncLighSource(light: Light): void;
  25412. /** @hidden */
  25413. _unBindEffect(): void;
  25414. /** @hidden */
  25415. _removeLightSource(light: Light): void;
  25416. private _markSubMeshesAsDirty;
  25417. /** @hidden */
  25418. _markSubMeshesAsLightDirty(): void;
  25419. /** @hidden */
  25420. _markSubMeshesAsAttributesDirty(): void;
  25421. /** @hidden */
  25422. _markSubMeshesAsMiscDirty(): void;
  25423. /**
  25424. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25425. */
  25426. scaling: Vector3;
  25427. /**
  25428. * Returns true if the mesh is blocked. Implemented by child classes
  25429. */
  25430. readonly isBlocked: boolean;
  25431. /**
  25432. * Returns the mesh itself by default. Implemented by child classes
  25433. * @param camera defines the camera to use to pick the right LOD level
  25434. * @returns the currentAbstractMesh
  25435. */
  25436. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25437. /**
  25438. * Returns 0 by default. Implemented by child classes
  25439. * @returns an integer
  25440. */
  25441. getTotalVertices(): number;
  25442. /**
  25443. * Returns a positive integer : the total number of indices in this mesh geometry.
  25444. * @returns the numner of indices or zero if the mesh has no geometry.
  25445. */
  25446. getTotalIndices(): number;
  25447. /**
  25448. * Returns null by default. Implemented by child classes
  25449. * @returns null
  25450. */
  25451. getIndices(): Nullable<IndicesArray>;
  25452. /**
  25453. * Returns the array of the requested vertex data kind. Implemented by child classes
  25454. * @param kind defines the vertex data kind to use
  25455. * @returns null
  25456. */
  25457. getVerticesData(kind: string): Nullable<FloatArray>;
  25458. /**
  25459. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25460. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25461. * Note that a new underlying VertexBuffer object is created each call.
  25462. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25463. * @param kind defines vertex data kind:
  25464. * * VertexBuffer.PositionKind
  25465. * * VertexBuffer.UVKind
  25466. * * VertexBuffer.UV2Kind
  25467. * * VertexBuffer.UV3Kind
  25468. * * VertexBuffer.UV4Kind
  25469. * * VertexBuffer.UV5Kind
  25470. * * VertexBuffer.UV6Kind
  25471. * * VertexBuffer.ColorKind
  25472. * * VertexBuffer.MatricesIndicesKind
  25473. * * VertexBuffer.MatricesIndicesExtraKind
  25474. * * VertexBuffer.MatricesWeightsKind
  25475. * * VertexBuffer.MatricesWeightsExtraKind
  25476. * @param data defines the data source
  25477. * @param updatable defines if the data must be flagged as updatable (or static)
  25478. * @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
  25479. * @returns the current mesh
  25480. */
  25481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25482. /**
  25483. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25484. * If the mesh has no geometry, it is simply returned as it is.
  25485. * @param kind defines vertex data kind:
  25486. * * VertexBuffer.PositionKind
  25487. * * VertexBuffer.UVKind
  25488. * * VertexBuffer.UV2Kind
  25489. * * VertexBuffer.UV3Kind
  25490. * * VertexBuffer.UV4Kind
  25491. * * VertexBuffer.UV5Kind
  25492. * * VertexBuffer.UV6Kind
  25493. * * VertexBuffer.ColorKind
  25494. * * VertexBuffer.MatricesIndicesKind
  25495. * * VertexBuffer.MatricesIndicesExtraKind
  25496. * * VertexBuffer.MatricesWeightsKind
  25497. * * VertexBuffer.MatricesWeightsExtraKind
  25498. * @param data defines the data source
  25499. * @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
  25500. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25501. * @returns the current mesh
  25502. */
  25503. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25504. /**
  25505. * Sets the mesh indices,
  25506. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25507. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25508. * @param totalVertices Defines the total number of vertices
  25509. * @returns the current mesh
  25510. */
  25511. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25512. /**
  25513. * Gets a boolean indicating if specific vertex data is present
  25514. * @param kind defines the vertex data kind to use
  25515. * @returns true is data kind is present
  25516. */
  25517. isVerticesDataPresent(kind: string): boolean;
  25518. /**
  25519. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25520. * @returns a BoundingInfo
  25521. */
  25522. getBoundingInfo(): BoundingInfo;
  25523. /**
  25524. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25525. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25526. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25527. * @returns the current mesh
  25528. */
  25529. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25530. /**
  25531. * Overwrite the current bounding info
  25532. * @param boundingInfo defines the new bounding info
  25533. * @returns the current mesh
  25534. */
  25535. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25536. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25537. readonly useBones: boolean;
  25538. /** @hidden */
  25539. _preActivate(): void;
  25540. /** @hidden */
  25541. _preActivateForIntermediateRendering(renderId: number): void;
  25542. /** @hidden */
  25543. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25544. /** @hidden */
  25545. _postActivate(): void;
  25546. /** @hidden */
  25547. _freeze(): void;
  25548. /** @hidden */
  25549. _unFreeze(): void;
  25550. /**
  25551. * Gets the current world matrix
  25552. * @returns a Matrix
  25553. */
  25554. getWorldMatrix(): Matrix;
  25555. /** @hidden */
  25556. _getWorldMatrixDeterminant(): number;
  25557. /**
  25558. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25559. */
  25560. readonly isAnInstance: boolean;
  25561. /**
  25562. * Perform relative position change from the point of view of behind the front of the mesh.
  25563. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25564. * Supports definition of mesh facing forward or backward
  25565. * @param amountRight defines the distance on the right axis
  25566. * @param amountUp defines the distance on the up axis
  25567. * @param amountForward defines the distance on the forward axis
  25568. * @returns the current mesh
  25569. */
  25570. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25571. /**
  25572. * Calculate relative position change from the point of view of behind the front of the mesh.
  25573. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25574. * Supports definition of mesh facing forward or backward
  25575. * @param amountRight defines the distance on the right axis
  25576. * @param amountUp defines the distance on the up axis
  25577. * @param amountForward defines the distance on the forward axis
  25578. * @returns the new displacement vector
  25579. */
  25580. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25581. /**
  25582. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25583. * Supports definition of mesh facing forward or backward
  25584. * @param flipBack defines the flip
  25585. * @param twirlClockwise defines the twirl
  25586. * @param tiltRight defines the tilt
  25587. * @returns the current mesh
  25588. */
  25589. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25590. /**
  25591. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25592. * Supports definition of mesh facing forward or backward.
  25593. * @param flipBack defines the flip
  25594. * @param twirlClockwise defines the twirl
  25595. * @param tiltRight defines the tilt
  25596. * @returns the new rotation vector
  25597. */
  25598. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25599. /**
  25600. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25601. * This means the mesh underlying bounding box and sphere are recomputed.
  25602. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25603. * @returns the current mesh
  25604. */
  25605. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25606. /** @hidden */
  25607. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25608. /** @hidden */
  25609. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25610. /** @hidden */
  25611. _updateBoundingInfo(): AbstractMesh;
  25612. /** @hidden */
  25613. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25614. /** @hidden */
  25615. protected _afterComputeWorldMatrix(): void;
  25616. /** @hidden */
  25617. readonly _effectiveMesh: AbstractMesh;
  25618. /**
  25619. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25620. * A mesh is in the frustum if its bounding box intersects the frustum
  25621. * @param frustumPlanes defines the frustum to test
  25622. * @returns true if the mesh is in the frustum planes
  25623. */
  25624. isInFrustum(frustumPlanes: Plane[]): boolean;
  25625. /**
  25626. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25627. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25628. * @param frustumPlanes defines the frustum to test
  25629. * @returns true if the mesh is completely in the frustum planes
  25630. */
  25631. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25632. /**
  25633. * True if the mesh intersects another mesh or a SolidParticle object
  25634. * @param mesh defines a target mesh or SolidParticle to test
  25635. * @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)
  25636. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25637. * @returns true if there is an intersection
  25638. */
  25639. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25640. /**
  25641. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25642. * @param point defines the point to test
  25643. * @returns true if there is an intersection
  25644. */
  25645. intersectsPoint(point: Vector3): boolean;
  25646. /**
  25647. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25648. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25649. */
  25650. checkCollisions: boolean;
  25651. /**
  25652. * Gets Collider object used to compute collisions (not physics)
  25653. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25654. */
  25655. readonly collider: Nullable<Collider>;
  25656. /**
  25657. * Move the mesh using collision engine
  25658. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25659. * @param displacement defines the requested displacement vector
  25660. * @returns the current mesh
  25661. */
  25662. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25663. private _onCollisionPositionChange;
  25664. /** @hidden */
  25665. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25666. /** @hidden */
  25667. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25668. /** @hidden */
  25669. _checkCollision(collider: Collider): AbstractMesh;
  25670. /** @hidden */
  25671. _generatePointsArray(): boolean;
  25672. /**
  25673. * Checks if the passed Ray intersects with the mesh
  25674. * @param ray defines the ray to use
  25675. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25676. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25677. * @returns the picking info
  25678. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25679. */
  25680. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25681. /**
  25682. * Clones the current mesh
  25683. * @param name defines the mesh name
  25684. * @param newParent defines the new mesh parent
  25685. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25686. * @returns the new mesh
  25687. */
  25688. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25689. /**
  25690. * Disposes all the submeshes of the current meshnp
  25691. * @returns the current mesh
  25692. */
  25693. releaseSubMeshes(): AbstractMesh;
  25694. /**
  25695. * Releases resources associated with this abstract mesh.
  25696. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25697. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25698. */
  25699. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25700. /**
  25701. * Adds the passed mesh as a child to the current mesh
  25702. * @param mesh defines the child mesh
  25703. * @returns the current mesh
  25704. */
  25705. addChild(mesh: AbstractMesh): AbstractMesh;
  25706. /**
  25707. * Removes the passed mesh from the current mesh children list
  25708. * @param mesh defines the child mesh
  25709. * @returns the current mesh
  25710. */
  25711. removeChild(mesh: AbstractMesh): AbstractMesh;
  25712. /** @hidden */
  25713. private _initFacetData;
  25714. /**
  25715. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25716. * This method can be called within the render loop.
  25717. * 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
  25718. * @returns the current mesh
  25719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25720. */
  25721. updateFacetData(): AbstractMesh;
  25722. /**
  25723. * Returns the facetLocalNormals array.
  25724. * The normals are expressed in the mesh local spac
  25725. * @returns an array of Vector3
  25726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25727. */
  25728. getFacetLocalNormals(): Vector3[];
  25729. /**
  25730. * Returns the facetLocalPositions array.
  25731. * The facet positions are expressed in the mesh local space
  25732. * @returns an array of Vector3
  25733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25734. */
  25735. getFacetLocalPositions(): Vector3[];
  25736. /**
  25737. * Returns the facetLocalPartioning array
  25738. * @returns an array of array of numbers
  25739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25740. */
  25741. getFacetLocalPartitioning(): number[][];
  25742. /**
  25743. * Returns the i-th facet position in the world system.
  25744. * This method allocates a new Vector3 per call
  25745. * @param i defines the facet index
  25746. * @returns a new Vector3
  25747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25748. */
  25749. getFacetPosition(i: number): Vector3;
  25750. /**
  25751. * Sets the reference Vector3 with the i-th facet position in the world system
  25752. * @param i defines the facet index
  25753. * @param ref defines the target vector
  25754. * @returns the current mesh
  25755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25756. */
  25757. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25758. /**
  25759. * Returns the i-th facet normal in the world system.
  25760. * This method allocates a new Vector3 per call
  25761. * @param i defines the facet index
  25762. * @returns a new Vector3
  25763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25764. */
  25765. getFacetNormal(i: number): Vector3;
  25766. /**
  25767. * Sets the reference Vector3 with the i-th facet normal in the world system
  25768. * @param i defines the facet index
  25769. * @param ref defines the target vector
  25770. * @returns the current mesh
  25771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25772. */
  25773. getFacetNormalToRef(i: number, ref: Vector3): this;
  25774. /**
  25775. * 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)
  25776. * @param x defines x coordinate
  25777. * @param y defines y coordinate
  25778. * @param z defines z coordinate
  25779. * @returns the array of facet indexes
  25780. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25781. */
  25782. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25783. /**
  25784. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25785. * @param projected sets as the (x,y,z) world projection on the facet
  25786. * @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
  25787. * @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
  25788. * @param x defines x coordinate
  25789. * @param y defines y coordinate
  25790. * @param z defines z coordinate
  25791. * @returns the face index if found (or null instead)
  25792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25793. */
  25794. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25795. /**
  25796. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25797. * @param projected sets as the (x,y,z) local projection on the facet
  25798. * @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
  25799. * @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
  25800. * @param x defines x coordinate
  25801. * @param y defines y coordinate
  25802. * @param z defines z coordinate
  25803. * @returns the face index if found (or null instead)
  25804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25805. */
  25806. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25807. /**
  25808. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25809. * @returns the parameters
  25810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25811. */
  25812. getFacetDataParameters(): any;
  25813. /**
  25814. * Disables the feature FacetData and frees the related memory
  25815. * @returns the current mesh
  25816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25817. */
  25818. disableFacetData(): AbstractMesh;
  25819. /**
  25820. * Updates the AbstractMesh indices array
  25821. * @param indices defines the data source
  25822. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25823. * @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)
  25824. * @returns the current mesh
  25825. */
  25826. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25827. /**
  25828. * Creates new normals data for the mesh
  25829. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25830. * @returns the current mesh
  25831. */
  25832. createNormals(updatable: boolean): AbstractMesh;
  25833. /**
  25834. * Align the mesh with a normal
  25835. * @param normal defines the normal to use
  25836. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25837. * @returns the current mesh
  25838. */
  25839. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25840. /** @hidden */
  25841. _checkOcclusionQuery(): boolean;
  25842. /**
  25843. * Disables the mesh edge rendering mode
  25844. * @returns the currentAbstractMesh
  25845. */
  25846. disableEdgesRendering(): AbstractMesh;
  25847. /**
  25848. * Enables the edge rendering mode on the mesh.
  25849. * This mode makes the mesh edges visible
  25850. * @param epsilon defines the maximal distance between two angles to detect a face
  25851. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25852. * @returns the currentAbstractMesh
  25853. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25854. */
  25855. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25856. }
  25857. }
  25858. declare module "babylonjs/Actions/actionEvent" {
  25859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25860. import { Nullable } from "babylonjs/types";
  25861. import { Sprite } from "babylonjs/Sprites/sprite";
  25862. import { Scene } from "babylonjs/scene";
  25863. import { Vector2 } from "babylonjs/Maths/math";
  25864. /**
  25865. * Interface used to define ActionEvent
  25866. */
  25867. export interface IActionEvent {
  25868. /** The mesh or sprite that triggered the action */
  25869. source: any;
  25870. /** The X mouse cursor position at the time of the event */
  25871. pointerX: number;
  25872. /** The Y mouse cursor position at the time of the event */
  25873. pointerY: number;
  25874. /** The mesh that is currently pointed at (can be null) */
  25875. meshUnderPointer: Nullable<AbstractMesh>;
  25876. /** the original (browser) event that triggered the ActionEvent */
  25877. sourceEvent?: any;
  25878. /** additional data for the event */
  25879. additionalData?: any;
  25880. }
  25881. /**
  25882. * ActionEvent is the event being sent when an action is triggered.
  25883. */
  25884. export class ActionEvent implements IActionEvent {
  25885. /** The mesh or sprite that triggered the action */
  25886. source: any;
  25887. /** The X mouse cursor position at the time of the event */
  25888. pointerX: number;
  25889. /** The Y mouse cursor position at the time of the event */
  25890. pointerY: number;
  25891. /** The mesh that is currently pointed at (can be null) */
  25892. meshUnderPointer: Nullable<AbstractMesh>;
  25893. /** the original (browser) event that triggered the ActionEvent */
  25894. sourceEvent?: any;
  25895. /** additional data for the event */
  25896. additionalData?: any;
  25897. /**
  25898. * Creates a new ActionEvent
  25899. * @param source The mesh or sprite that triggered the action
  25900. * @param pointerX The X mouse cursor position at the time of the event
  25901. * @param pointerY The Y mouse cursor position at the time of the event
  25902. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25903. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25904. * @param additionalData additional data for the event
  25905. */
  25906. constructor(
  25907. /** The mesh or sprite that triggered the action */
  25908. source: any,
  25909. /** The X mouse cursor position at the time of the event */
  25910. pointerX: number,
  25911. /** The Y mouse cursor position at the time of the event */
  25912. pointerY: number,
  25913. /** The mesh that is currently pointed at (can be null) */
  25914. meshUnderPointer: Nullable<AbstractMesh>,
  25915. /** the original (browser) event that triggered the ActionEvent */
  25916. sourceEvent?: any,
  25917. /** additional data for the event */
  25918. additionalData?: any);
  25919. /**
  25920. * Helper function to auto-create an ActionEvent from a source mesh.
  25921. * @param source The source mesh that triggered the event
  25922. * @param evt The original (browser) event
  25923. * @param additionalData additional data for the event
  25924. * @returns the new ActionEvent
  25925. */
  25926. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25927. /**
  25928. * Helper function to auto-create an ActionEvent from a source sprite
  25929. * @param source The source sprite that triggered the event
  25930. * @param scene Scene associated with the sprite
  25931. * @param evt The original (browser) event
  25932. * @param additionalData additional data for the event
  25933. * @returns the new ActionEvent
  25934. */
  25935. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25936. /**
  25937. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25938. * @param scene the scene where the event occurred
  25939. * @param evt The original (browser) event
  25940. * @returns the new ActionEvent
  25941. */
  25942. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25943. /**
  25944. * Helper function to auto-create an ActionEvent from a primitive
  25945. * @param prim defines the target primitive
  25946. * @param pointerPos defines the pointer position
  25947. * @param evt The original (browser) event
  25948. * @param additionalData additional data for the event
  25949. * @returns the new ActionEvent
  25950. */
  25951. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25952. }
  25953. }
  25954. declare module "babylonjs/Actions/abstractActionManager" {
  25955. import { IDisposable } from "babylonjs/scene";
  25956. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25957. import { IAction } from "babylonjs/Actions/action";
  25958. import { Nullable } from "babylonjs/types";
  25959. /**
  25960. * Abstract class used to decouple action Manager from scene and meshes.
  25961. * Do not instantiate.
  25962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25963. */
  25964. export abstract class AbstractActionManager implements IDisposable {
  25965. /** Gets the list of active triggers */
  25966. static Triggers: {
  25967. [key: string]: number;
  25968. };
  25969. /** Gets the cursor to use when hovering items */
  25970. hoverCursor: string;
  25971. /** Gets the list of actions */
  25972. actions: IAction[];
  25973. /**
  25974. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25975. */
  25976. isRecursive: boolean;
  25977. /**
  25978. * Releases all associated resources
  25979. */
  25980. abstract dispose(): void;
  25981. /**
  25982. * Does this action manager has pointer triggers
  25983. */
  25984. abstract readonly hasPointerTriggers: boolean;
  25985. /**
  25986. * Does this action manager has pick triggers
  25987. */
  25988. abstract readonly hasPickTriggers: boolean;
  25989. /**
  25990. * Process a specific trigger
  25991. * @param trigger defines the trigger to process
  25992. * @param evt defines the event details to be processed
  25993. */
  25994. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25995. /**
  25996. * Does this action manager handles actions of any of the given triggers
  25997. * @param triggers defines the triggers to be tested
  25998. * @return a boolean indicating whether one (or more) of the triggers is handled
  25999. */
  26000. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26001. /**
  26002. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26003. * speed.
  26004. * @param triggerA defines the trigger to be tested
  26005. * @param triggerB defines the trigger to be tested
  26006. * @return a boolean indicating whether one (or more) of the triggers is handled
  26007. */
  26008. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26009. /**
  26010. * Does this action manager handles actions of a given trigger
  26011. * @param trigger defines the trigger to be tested
  26012. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26013. * @return whether the trigger is handled
  26014. */
  26015. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26016. /**
  26017. * Serialize this manager to a JSON object
  26018. * @param name defines the property name to store this manager
  26019. * @returns a JSON representation of this manager
  26020. */
  26021. abstract serialize(name: string): any;
  26022. /**
  26023. * Registers an action to this action manager
  26024. * @param action defines the action to be registered
  26025. * @return the action amended (prepared) after registration
  26026. */
  26027. abstract registerAction(action: IAction): Nullable<IAction>;
  26028. /**
  26029. * Unregisters an action to this action manager
  26030. * @param action defines the action to be unregistered
  26031. * @return a boolean indicating whether the action has been unregistered
  26032. */
  26033. abstract unregisterAction(action: IAction): Boolean;
  26034. /**
  26035. * Does exist one action manager with at least one trigger
  26036. **/
  26037. static readonly HasTriggers: boolean;
  26038. /**
  26039. * Does exist one action manager with at least one pick trigger
  26040. **/
  26041. static readonly HasPickTriggers: boolean;
  26042. /**
  26043. * Does exist one action manager that handles actions of a given trigger
  26044. * @param trigger defines the trigger to be tested
  26045. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26046. **/
  26047. static HasSpecificTrigger(trigger: number): boolean;
  26048. }
  26049. }
  26050. declare module "babylonjs/node" {
  26051. import { Scene } from "babylonjs/scene";
  26052. import { Nullable } from "babylonjs/types";
  26053. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26054. import { Engine } from "babylonjs/Engines/engine";
  26055. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26056. import { Observable } from "babylonjs/Misc/observable";
  26057. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26058. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26059. import { Animatable } from "babylonjs/Animations/animatable";
  26060. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26061. import { Animation } from "babylonjs/Animations/animation";
  26062. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26064. /**
  26065. * Defines how a node can be built from a string name.
  26066. */
  26067. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26068. /**
  26069. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26070. */
  26071. export class Node implements IBehaviorAware<Node> {
  26072. /** @hidden */
  26073. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26074. private static _NodeConstructors;
  26075. /**
  26076. * Add a new node constructor
  26077. * @param type defines the type name of the node to construct
  26078. * @param constructorFunc defines the constructor function
  26079. */
  26080. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26081. /**
  26082. * Returns a node constructor based on type name
  26083. * @param type defines the type name
  26084. * @param name defines the new node name
  26085. * @param scene defines the hosting scene
  26086. * @param options defines optional options to transmit to constructors
  26087. * @returns the new constructor or null
  26088. */
  26089. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26090. /**
  26091. * Gets or sets the name of the node
  26092. */
  26093. name: string;
  26094. /**
  26095. * Gets or sets the id of the node
  26096. */
  26097. id: string;
  26098. /**
  26099. * Gets or sets the unique id of the node
  26100. */
  26101. uniqueId: number;
  26102. /**
  26103. * Gets or sets a string used to store user defined state for the node
  26104. */
  26105. state: string;
  26106. /**
  26107. * Gets or sets an object used to store user defined information for the node
  26108. */
  26109. metadata: any;
  26110. /**
  26111. * For internal use only. Please do not use.
  26112. */
  26113. reservedDataStore: any;
  26114. /**
  26115. * List of inspectable custom properties (used by the Inspector)
  26116. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26117. */
  26118. inspectableCustomProperties: IInspectable[];
  26119. /**
  26120. * Gets or sets a boolean used to define if the node must be serialized
  26121. */
  26122. doNotSerialize: boolean;
  26123. /** @hidden */
  26124. _isDisposed: boolean;
  26125. /**
  26126. * Gets a list of Animations associated with the node
  26127. */
  26128. animations: import("babylonjs/Animations/animation").Animation[];
  26129. protected _ranges: {
  26130. [name: string]: Nullable<AnimationRange>;
  26131. };
  26132. /**
  26133. * Callback raised when the node is ready to be used
  26134. */
  26135. onReady: Nullable<(node: Node) => void>;
  26136. private _isEnabled;
  26137. private _isParentEnabled;
  26138. private _isReady;
  26139. /** @hidden */
  26140. _currentRenderId: number;
  26141. private _parentUpdateId;
  26142. /** @hidden */
  26143. _childUpdateId: number;
  26144. /** @hidden */
  26145. _waitingParentId: Nullable<string>;
  26146. /** @hidden */
  26147. _scene: Scene;
  26148. /** @hidden */
  26149. _cache: any;
  26150. private _parentNode;
  26151. private _children;
  26152. /** @hidden */
  26153. _worldMatrix: Matrix;
  26154. /** @hidden */
  26155. _worldMatrixDeterminant: number;
  26156. /** @hidden */
  26157. _worldMatrixDeterminantIsDirty: boolean;
  26158. /** @hidden */
  26159. private _sceneRootNodesIndex;
  26160. /**
  26161. * Gets a boolean indicating if the node has been disposed
  26162. * @returns true if the node was disposed
  26163. */
  26164. isDisposed(): boolean;
  26165. /**
  26166. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26167. * @see https://doc.babylonjs.com/how_to/parenting
  26168. */
  26169. parent: Nullable<Node>;
  26170. private addToSceneRootNodes;
  26171. private removeFromSceneRootNodes;
  26172. private _animationPropertiesOverride;
  26173. /**
  26174. * Gets or sets the animation properties override
  26175. */
  26176. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26177. /**
  26178. * Gets a string idenfifying the name of the class
  26179. * @returns "Node" string
  26180. */
  26181. getClassName(): string;
  26182. /** @hidden */
  26183. readonly _isNode: boolean;
  26184. /**
  26185. * An event triggered when the mesh is disposed
  26186. */
  26187. onDisposeObservable: Observable<Node>;
  26188. private _onDisposeObserver;
  26189. /**
  26190. * Sets a callback that will be raised when the node will be disposed
  26191. */
  26192. onDispose: () => void;
  26193. /**
  26194. * Creates a new Node
  26195. * @param name the name and id to be given to this node
  26196. * @param scene the scene this node will be added to
  26197. * @param addToRootNodes the node will be added to scene.rootNodes
  26198. */
  26199. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26200. /**
  26201. * Gets the scene of the node
  26202. * @returns a scene
  26203. */
  26204. getScene(): Scene;
  26205. /**
  26206. * Gets the engine of the node
  26207. * @returns a Engine
  26208. */
  26209. getEngine(): Engine;
  26210. private _behaviors;
  26211. /**
  26212. * Attach a behavior to the node
  26213. * @see http://doc.babylonjs.com/features/behaviour
  26214. * @param behavior defines the behavior to attach
  26215. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26216. * @returns the current Node
  26217. */
  26218. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26219. /**
  26220. * Remove an attached behavior
  26221. * @see http://doc.babylonjs.com/features/behaviour
  26222. * @param behavior defines the behavior to attach
  26223. * @returns the current Node
  26224. */
  26225. removeBehavior(behavior: Behavior<Node>): Node;
  26226. /**
  26227. * Gets the list of attached behaviors
  26228. * @see http://doc.babylonjs.com/features/behaviour
  26229. */
  26230. readonly behaviors: Behavior<Node>[];
  26231. /**
  26232. * Gets an attached behavior by name
  26233. * @param name defines the name of the behavior to look for
  26234. * @see http://doc.babylonjs.com/features/behaviour
  26235. * @returns null if behavior was not found else the requested behavior
  26236. */
  26237. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26238. /**
  26239. * Returns the latest update of the World matrix
  26240. * @returns a Matrix
  26241. */
  26242. getWorldMatrix(): Matrix;
  26243. /** @hidden */
  26244. _getWorldMatrixDeterminant(): number;
  26245. /**
  26246. * Returns directly the latest state of the mesh World matrix.
  26247. * A Matrix is returned.
  26248. */
  26249. readonly worldMatrixFromCache: Matrix;
  26250. /** @hidden */
  26251. _initCache(): void;
  26252. /** @hidden */
  26253. updateCache(force?: boolean): void;
  26254. /** @hidden */
  26255. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26256. /** @hidden */
  26257. _updateCache(ignoreParentClass?: boolean): void;
  26258. /** @hidden */
  26259. _isSynchronized(): boolean;
  26260. /** @hidden */
  26261. _markSyncedWithParent(): void;
  26262. /** @hidden */
  26263. isSynchronizedWithParent(): boolean;
  26264. /** @hidden */
  26265. isSynchronized(): boolean;
  26266. /**
  26267. * Is this node ready to be used/rendered
  26268. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26269. * @return true if the node is ready
  26270. */
  26271. isReady(completeCheck?: boolean): boolean;
  26272. /**
  26273. * Is this node enabled?
  26274. * 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
  26275. * @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
  26276. * @return whether this node (and its parent) is enabled
  26277. */
  26278. isEnabled(checkAncestors?: boolean): boolean;
  26279. /** @hidden */
  26280. protected _syncParentEnabledState(): void;
  26281. /**
  26282. * Set the enabled state of this node
  26283. * @param value defines the new enabled state
  26284. */
  26285. setEnabled(value: boolean): void;
  26286. /**
  26287. * Is this node a descendant of the given node?
  26288. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26289. * @param ancestor defines the parent node to inspect
  26290. * @returns a boolean indicating if this node is a descendant of the given node
  26291. */
  26292. isDescendantOf(ancestor: Node): boolean;
  26293. /** @hidden */
  26294. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26295. /**
  26296. * Will return all nodes that have this node as ascendant
  26297. * @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
  26298. * @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
  26299. * @return all children nodes of all types
  26300. */
  26301. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26302. /**
  26303. * Get all child-meshes of this node
  26304. * @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)
  26305. * @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
  26306. * @returns an array of AbstractMesh
  26307. */
  26308. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26309. /**
  26310. * Get all direct children of this node
  26311. * @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
  26312. * @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)
  26313. * @returns an array of Node
  26314. */
  26315. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26316. /** @hidden */
  26317. _setReady(state: boolean): void;
  26318. /**
  26319. * Get an animation by name
  26320. * @param name defines the name of the animation to look for
  26321. * @returns null if not found else the requested animation
  26322. */
  26323. getAnimationByName(name: string): Nullable<Animation>;
  26324. /**
  26325. * Creates an animation range for this node
  26326. * @param name defines the name of the range
  26327. * @param from defines the starting key
  26328. * @param to defines the end key
  26329. */
  26330. createAnimationRange(name: string, from: number, to: number): void;
  26331. /**
  26332. * Delete a specific animation range
  26333. * @param name defines the name of the range to delete
  26334. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26335. */
  26336. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26337. /**
  26338. * Get an animation range by name
  26339. * @param name defines the name of the animation range to look for
  26340. * @returns null if not found else the requested animation range
  26341. */
  26342. getAnimationRange(name: string): Nullable<AnimationRange>;
  26343. /**
  26344. * Gets the list of all animation ranges defined on this node
  26345. * @returns an array
  26346. */
  26347. getAnimationRanges(): Nullable<AnimationRange>[];
  26348. /**
  26349. * Will start the animation sequence
  26350. * @param name defines the range frames for animation sequence
  26351. * @param loop defines if the animation should loop (false by default)
  26352. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26353. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26354. * @returns the object created for this animation. If range does not exist, it will return null
  26355. */
  26356. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26357. /**
  26358. * Serialize animation ranges into a JSON compatible object
  26359. * @returns serialization object
  26360. */
  26361. serializeAnimationRanges(): any;
  26362. /**
  26363. * Computes the world matrix of the node
  26364. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26365. * @returns the world matrix
  26366. */
  26367. computeWorldMatrix(force?: boolean): Matrix;
  26368. /**
  26369. * Releases resources associated with this node.
  26370. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26371. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26372. */
  26373. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26374. /**
  26375. * Parse animation range data from a serialization object and store them into a given node
  26376. * @param node defines where to store the animation ranges
  26377. * @param parsedNode defines the serialization object to read data from
  26378. * @param scene defines the hosting scene
  26379. */
  26380. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26381. /**
  26382. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26383. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26384. * @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
  26385. * @returns the new bounding vectors
  26386. */
  26387. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26388. min: Vector3;
  26389. max: Vector3;
  26390. };
  26391. }
  26392. }
  26393. declare module "babylonjs/Animations/animation" {
  26394. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26395. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26396. import { Nullable } from "babylonjs/types";
  26397. import { Scene } from "babylonjs/scene";
  26398. import { IAnimatable } from "babylonjs/Misc/tools";
  26399. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26400. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26401. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26402. import { Node } from "babylonjs/node";
  26403. import { Animatable } from "babylonjs/Animations/animatable";
  26404. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26405. /**
  26406. * @hidden
  26407. */
  26408. export class _IAnimationState {
  26409. key: number;
  26410. repeatCount: number;
  26411. workValue?: any;
  26412. loopMode?: number;
  26413. offsetValue?: any;
  26414. highLimitValue?: any;
  26415. }
  26416. /**
  26417. * Class used to store any kind of animation
  26418. */
  26419. export class Animation {
  26420. /**Name of the animation */
  26421. name: string;
  26422. /**Property to animate */
  26423. targetProperty: string;
  26424. /**The frames per second of the animation */
  26425. framePerSecond: number;
  26426. /**The data type of the animation */
  26427. dataType: number;
  26428. /**The loop mode of the animation */
  26429. loopMode?: number | undefined;
  26430. /**Specifies if blending should be enabled */
  26431. enableBlending?: boolean | undefined;
  26432. /**
  26433. * Use matrix interpolation instead of using direct key value when animating matrices
  26434. */
  26435. static AllowMatricesInterpolation: boolean;
  26436. /**
  26437. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26438. */
  26439. static AllowMatrixDecomposeForInterpolation: boolean;
  26440. /**
  26441. * Stores the key frames of the animation
  26442. */
  26443. private _keys;
  26444. /**
  26445. * Stores the easing function of the animation
  26446. */
  26447. private _easingFunction;
  26448. /**
  26449. * @hidden Internal use only
  26450. */
  26451. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26452. /**
  26453. * The set of event that will be linked to this animation
  26454. */
  26455. private _events;
  26456. /**
  26457. * Stores an array of target property paths
  26458. */
  26459. targetPropertyPath: string[];
  26460. /**
  26461. * Stores the blending speed of the animation
  26462. */
  26463. blendingSpeed: number;
  26464. /**
  26465. * Stores the animation ranges for the animation
  26466. */
  26467. private _ranges;
  26468. /**
  26469. * @hidden Internal use
  26470. */
  26471. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26472. /**
  26473. * Sets up an animation
  26474. * @param property The property to animate
  26475. * @param animationType The animation type to apply
  26476. * @param framePerSecond The frames per second of the animation
  26477. * @param easingFunction The easing function used in the animation
  26478. * @returns The created animation
  26479. */
  26480. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26481. /**
  26482. * Create and start an animation on a node
  26483. * @param name defines the name of the global animation that will be run on all nodes
  26484. * @param node defines the root node where the animation will take place
  26485. * @param targetProperty defines property to animate
  26486. * @param framePerSecond defines the number of frame per second yo use
  26487. * @param totalFrame defines the number of frames in total
  26488. * @param from defines the initial value
  26489. * @param to defines the final value
  26490. * @param loopMode defines which loop mode you want to use (off by default)
  26491. * @param easingFunction defines the easing function to use (linear by default)
  26492. * @param onAnimationEnd defines the callback to call when animation end
  26493. * @returns the animatable created for this animation
  26494. */
  26495. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26496. /**
  26497. * Create and start an animation on a node and its descendants
  26498. * @param name defines the name of the global animation that will be run on all nodes
  26499. * @param node defines the root node where the animation will take place
  26500. * @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
  26501. * @param targetProperty defines property to animate
  26502. * @param framePerSecond defines the number of frame per second to use
  26503. * @param totalFrame defines the number of frames in total
  26504. * @param from defines the initial value
  26505. * @param to defines the final value
  26506. * @param loopMode defines which loop mode you want to use (off by default)
  26507. * @param easingFunction defines the easing function to use (linear by default)
  26508. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26509. * @returns the list of animatables created for all nodes
  26510. * @example https://www.babylonjs-playground.com/#MH0VLI
  26511. */
  26512. 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[]>;
  26513. /**
  26514. * Creates a new animation, merges it with the existing animations and starts it
  26515. * @param name Name of the animation
  26516. * @param node Node which contains the scene that begins the animations
  26517. * @param targetProperty Specifies which property to animate
  26518. * @param framePerSecond The frames per second of the animation
  26519. * @param totalFrame The total number of frames
  26520. * @param from The frame at the beginning of the animation
  26521. * @param to The frame at the end of the animation
  26522. * @param loopMode Specifies the loop mode of the animation
  26523. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26524. * @param onAnimationEnd Callback to run once the animation is complete
  26525. * @returns Nullable animation
  26526. */
  26527. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26528. /**
  26529. * Transition property of an host to the target Value
  26530. * @param property The property to transition
  26531. * @param targetValue The target Value of the property
  26532. * @param host The object where the property to animate belongs
  26533. * @param scene Scene used to run the animation
  26534. * @param frameRate Framerate (in frame/s) to use
  26535. * @param transition The transition type we want to use
  26536. * @param duration The duration of the animation, in milliseconds
  26537. * @param onAnimationEnd Callback trigger at the end of the animation
  26538. * @returns Nullable animation
  26539. */
  26540. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26541. /**
  26542. * Return the array of runtime animations currently using this animation
  26543. */
  26544. readonly runtimeAnimations: RuntimeAnimation[];
  26545. /**
  26546. * Specifies if any of the runtime animations are currently running
  26547. */
  26548. readonly hasRunningRuntimeAnimations: boolean;
  26549. /**
  26550. * Initializes the animation
  26551. * @param name Name of the animation
  26552. * @param targetProperty Property to animate
  26553. * @param framePerSecond The frames per second of the animation
  26554. * @param dataType The data type of the animation
  26555. * @param loopMode The loop mode of the animation
  26556. * @param enableBlending Specifies if blending should be enabled
  26557. */
  26558. constructor(
  26559. /**Name of the animation */
  26560. name: string,
  26561. /**Property to animate */
  26562. targetProperty: string,
  26563. /**The frames per second of the animation */
  26564. framePerSecond: number,
  26565. /**The data type of the animation */
  26566. dataType: number,
  26567. /**The loop mode of the animation */
  26568. loopMode?: number | undefined,
  26569. /**Specifies if blending should be enabled */
  26570. enableBlending?: boolean | undefined);
  26571. /**
  26572. * Converts the animation to a string
  26573. * @param fullDetails support for multiple levels of logging within scene loading
  26574. * @returns String form of the animation
  26575. */
  26576. toString(fullDetails?: boolean): string;
  26577. /**
  26578. * Add an event to this animation
  26579. * @param event Event to add
  26580. */
  26581. addEvent(event: AnimationEvent): void;
  26582. /**
  26583. * Remove all events found at the given frame
  26584. * @param frame The frame to remove events from
  26585. */
  26586. removeEvents(frame: number): void;
  26587. /**
  26588. * Retrieves all the events from the animation
  26589. * @returns Events from the animation
  26590. */
  26591. getEvents(): AnimationEvent[];
  26592. /**
  26593. * Creates an animation range
  26594. * @param name Name of the animation range
  26595. * @param from Starting frame of the animation range
  26596. * @param to Ending frame of the animation
  26597. */
  26598. createRange(name: string, from: number, to: number): void;
  26599. /**
  26600. * Deletes an animation range by name
  26601. * @param name Name of the animation range to delete
  26602. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26603. */
  26604. deleteRange(name: string, deleteFrames?: boolean): void;
  26605. /**
  26606. * Gets the animation range by name, or null if not defined
  26607. * @param name Name of the animation range
  26608. * @returns Nullable animation range
  26609. */
  26610. getRange(name: string): Nullable<AnimationRange>;
  26611. /**
  26612. * Gets the key frames from the animation
  26613. * @returns The key frames of the animation
  26614. */
  26615. getKeys(): Array<IAnimationKey>;
  26616. /**
  26617. * Gets the highest frame rate of the animation
  26618. * @returns Highest frame rate of the animation
  26619. */
  26620. getHighestFrame(): number;
  26621. /**
  26622. * Gets the easing function of the animation
  26623. * @returns Easing function of the animation
  26624. */
  26625. getEasingFunction(): IEasingFunction;
  26626. /**
  26627. * Sets the easing function of the animation
  26628. * @param easingFunction A custom mathematical formula for animation
  26629. */
  26630. setEasingFunction(easingFunction: EasingFunction): void;
  26631. /**
  26632. * Interpolates a scalar linearly
  26633. * @param startValue Start value of the animation curve
  26634. * @param endValue End value of the animation curve
  26635. * @param gradient Scalar amount to interpolate
  26636. * @returns Interpolated scalar value
  26637. */
  26638. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26639. /**
  26640. * Interpolates a scalar cubically
  26641. * @param startValue Start value of the animation curve
  26642. * @param outTangent End tangent of the animation
  26643. * @param endValue End value of the animation curve
  26644. * @param inTangent Start tangent of the animation curve
  26645. * @param gradient Scalar amount to interpolate
  26646. * @returns Interpolated scalar value
  26647. */
  26648. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26649. /**
  26650. * Interpolates a quaternion using a spherical linear interpolation
  26651. * @param startValue Start value of the animation curve
  26652. * @param endValue End value of the animation curve
  26653. * @param gradient Scalar amount to interpolate
  26654. * @returns Interpolated quaternion value
  26655. */
  26656. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26657. /**
  26658. * Interpolates a quaternion cubically
  26659. * @param startValue Start value of the animation curve
  26660. * @param outTangent End tangent of the animation curve
  26661. * @param endValue End value of the animation curve
  26662. * @param inTangent Start tangent of the animation curve
  26663. * @param gradient Scalar amount to interpolate
  26664. * @returns Interpolated quaternion value
  26665. */
  26666. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26667. /**
  26668. * Interpolates a Vector3 linearl
  26669. * @param startValue Start value of the animation curve
  26670. * @param endValue End value of the animation curve
  26671. * @param gradient Scalar amount to interpolate
  26672. * @returns Interpolated scalar value
  26673. */
  26674. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26675. /**
  26676. * Interpolates a Vector3 cubically
  26677. * @param startValue Start value of the animation curve
  26678. * @param outTangent End tangent of the animation
  26679. * @param endValue End value of the animation curve
  26680. * @param inTangent Start tangent of the animation curve
  26681. * @param gradient Scalar amount to interpolate
  26682. * @returns InterpolatedVector3 value
  26683. */
  26684. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26685. /**
  26686. * Interpolates a Vector2 linearly
  26687. * @param startValue Start value of the animation curve
  26688. * @param endValue End value of the animation curve
  26689. * @param gradient Scalar amount to interpolate
  26690. * @returns Interpolated Vector2 value
  26691. */
  26692. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26693. /**
  26694. * Interpolates a Vector2 cubically
  26695. * @param startValue Start value of the animation curve
  26696. * @param outTangent End tangent of the animation
  26697. * @param endValue End value of the animation curve
  26698. * @param inTangent Start tangent of the animation curve
  26699. * @param gradient Scalar amount to interpolate
  26700. * @returns Interpolated Vector2 value
  26701. */
  26702. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26703. /**
  26704. * Interpolates a size linearly
  26705. * @param startValue Start value of the animation curve
  26706. * @param endValue End value of the animation curve
  26707. * @param gradient Scalar amount to interpolate
  26708. * @returns Interpolated Size value
  26709. */
  26710. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26711. /**
  26712. * Interpolates a Color3 linearly
  26713. * @param startValue Start value of the animation curve
  26714. * @param endValue End value of the animation curve
  26715. * @param gradient Scalar amount to interpolate
  26716. * @returns Interpolated Color3 value
  26717. */
  26718. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26719. /**
  26720. * @hidden Internal use only
  26721. */
  26722. _getKeyValue(value: any): any;
  26723. /**
  26724. * @hidden Internal use only
  26725. */
  26726. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26727. /**
  26728. * Defines the function to use to interpolate matrices
  26729. * @param startValue defines the start matrix
  26730. * @param endValue defines the end matrix
  26731. * @param gradient defines the gradient between both matrices
  26732. * @param result defines an optional target matrix where to store the interpolation
  26733. * @returns the interpolated matrix
  26734. */
  26735. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26736. /**
  26737. * Makes a copy of the animation
  26738. * @returns Cloned animation
  26739. */
  26740. clone(): Animation;
  26741. /**
  26742. * Sets the key frames of the animation
  26743. * @param values The animation key frames to set
  26744. */
  26745. setKeys(values: Array<IAnimationKey>): void;
  26746. /**
  26747. * Serializes the animation to an object
  26748. * @returns Serialized object
  26749. */
  26750. serialize(): any;
  26751. /**
  26752. * Float animation type
  26753. */
  26754. private static _ANIMATIONTYPE_FLOAT;
  26755. /**
  26756. * Vector3 animation type
  26757. */
  26758. private static _ANIMATIONTYPE_VECTOR3;
  26759. /**
  26760. * Quaternion animation type
  26761. */
  26762. private static _ANIMATIONTYPE_QUATERNION;
  26763. /**
  26764. * Matrix animation type
  26765. */
  26766. private static _ANIMATIONTYPE_MATRIX;
  26767. /**
  26768. * Color3 animation type
  26769. */
  26770. private static _ANIMATIONTYPE_COLOR3;
  26771. /**
  26772. * Vector2 animation type
  26773. */
  26774. private static _ANIMATIONTYPE_VECTOR2;
  26775. /**
  26776. * Size animation type
  26777. */
  26778. private static _ANIMATIONTYPE_SIZE;
  26779. /**
  26780. * Relative Loop Mode
  26781. */
  26782. private static _ANIMATIONLOOPMODE_RELATIVE;
  26783. /**
  26784. * Cycle Loop Mode
  26785. */
  26786. private static _ANIMATIONLOOPMODE_CYCLE;
  26787. /**
  26788. * Constant Loop Mode
  26789. */
  26790. private static _ANIMATIONLOOPMODE_CONSTANT;
  26791. /**
  26792. * Get the float animation type
  26793. */
  26794. static readonly ANIMATIONTYPE_FLOAT: number;
  26795. /**
  26796. * Get the Vector3 animation type
  26797. */
  26798. static readonly ANIMATIONTYPE_VECTOR3: number;
  26799. /**
  26800. * Get the Vector2 animation type
  26801. */
  26802. static readonly ANIMATIONTYPE_VECTOR2: number;
  26803. /**
  26804. * Get the Size animation type
  26805. */
  26806. static readonly ANIMATIONTYPE_SIZE: number;
  26807. /**
  26808. * Get the Quaternion animation type
  26809. */
  26810. static readonly ANIMATIONTYPE_QUATERNION: number;
  26811. /**
  26812. * Get the Matrix animation type
  26813. */
  26814. static readonly ANIMATIONTYPE_MATRIX: number;
  26815. /**
  26816. * Get the Color3 animation type
  26817. */
  26818. static readonly ANIMATIONTYPE_COLOR3: number;
  26819. /**
  26820. * Get the Relative Loop Mode
  26821. */
  26822. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26823. /**
  26824. * Get the Cycle Loop Mode
  26825. */
  26826. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26827. /**
  26828. * Get the Constant Loop Mode
  26829. */
  26830. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26831. /** @hidden */
  26832. static _UniversalLerp(left: any, right: any, amount: number): any;
  26833. /**
  26834. * Parses an animation object and creates an animation
  26835. * @param parsedAnimation Parsed animation object
  26836. * @returns Animation object
  26837. */
  26838. static Parse(parsedAnimation: any): Animation;
  26839. /**
  26840. * Appends the serialized animations from the source animations
  26841. * @param source Source containing the animations
  26842. * @param destination Target to store the animations
  26843. */
  26844. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26845. }
  26846. }
  26847. declare module "babylonjs/Materials/Textures/baseTexture" {
  26848. import { Observable } from "babylonjs/Misc/observable";
  26849. import { IAnimatable } from "babylonjs/Misc/tools";
  26850. import { Nullable } from "babylonjs/types";
  26851. import { Scene } from "babylonjs/scene";
  26852. import { Matrix, ISize } from "babylonjs/Maths/math";
  26853. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26854. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26855. /**
  26856. * Base class of all the textures in babylon.
  26857. * It groups all the common properties the materials, post process, lights... might need
  26858. * in order to make a correct use of the texture.
  26859. */
  26860. export class BaseTexture implements IAnimatable {
  26861. /**
  26862. * Default anisotropic filtering level for the application.
  26863. * It is set to 4 as a good tradeoff between perf and quality.
  26864. */
  26865. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26866. /**
  26867. * Gets or sets the unique id of the texture
  26868. */
  26869. uniqueId: number;
  26870. /**
  26871. * Define the name of the texture.
  26872. */
  26873. name: string;
  26874. /**
  26875. * Gets or sets an object used to store user defined information.
  26876. */
  26877. metadata: any;
  26878. /**
  26879. * For internal use only. Please do not use.
  26880. */
  26881. reservedDataStore: any;
  26882. private _hasAlpha;
  26883. /**
  26884. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26885. */
  26886. hasAlpha: boolean;
  26887. /**
  26888. * Defines if the alpha value should be determined via the rgb values.
  26889. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26890. */
  26891. getAlphaFromRGB: boolean;
  26892. /**
  26893. * Intensity or strength of the texture.
  26894. * It is commonly used by materials to fine tune the intensity of the texture
  26895. */
  26896. level: number;
  26897. /**
  26898. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26899. * This is part of the texture as textures usually maps to one uv set.
  26900. */
  26901. coordinatesIndex: number;
  26902. private _coordinatesMode;
  26903. /**
  26904. * How a texture is mapped.
  26905. *
  26906. * | Value | Type | Description |
  26907. * | ----- | ----------------------------------- | ----------- |
  26908. * | 0 | EXPLICIT_MODE | |
  26909. * | 1 | SPHERICAL_MODE | |
  26910. * | 2 | PLANAR_MODE | |
  26911. * | 3 | CUBIC_MODE | |
  26912. * | 4 | PROJECTION_MODE | |
  26913. * | 5 | SKYBOX_MODE | |
  26914. * | 6 | INVCUBIC_MODE | |
  26915. * | 7 | EQUIRECTANGULAR_MODE | |
  26916. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26917. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26918. */
  26919. coordinatesMode: number;
  26920. /**
  26921. * | Value | Type | Description |
  26922. * | ----- | ------------------ | ----------- |
  26923. * | 0 | CLAMP_ADDRESSMODE | |
  26924. * | 1 | WRAP_ADDRESSMODE | |
  26925. * | 2 | MIRROR_ADDRESSMODE | |
  26926. */
  26927. wrapU: number;
  26928. /**
  26929. * | Value | Type | Description |
  26930. * | ----- | ------------------ | ----------- |
  26931. * | 0 | CLAMP_ADDRESSMODE | |
  26932. * | 1 | WRAP_ADDRESSMODE | |
  26933. * | 2 | MIRROR_ADDRESSMODE | |
  26934. */
  26935. wrapV: number;
  26936. /**
  26937. * | Value | Type | Description |
  26938. * | ----- | ------------------ | ----------- |
  26939. * | 0 | CLAMP_ADDRESSMODE | |
  26940. * | 1 | WRAP_ADDRESSMODE | |
  26941. * | 2 | MIRROR_ADDRESSMODE | |
  26942. */
  26943. wrapR: number;
  26944. /**
  26945. * With compliant hardware and browser (supporting anisotropic filtering)
  26946. * this defines the level of anisotropic filtering in the texture.
  26947. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26948. */
  26949. anisotropicFilteringLevel: number;
  26950. /**
  26951. * Define if the texture is a cube texture or if false a 2d texture.
  26952. */
  26953. isCube: boolean;
  26954. /**
  26955. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26956. */
  26957. is3D: boolean;
  26958. /**
  26959. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26960. * HDR texture are usually stored in linear space.
  26961. * This only impacts the PBR and Background materials
  26962. */
  26963. gammaSpace: boolean;
  26964. /**
  26965. * Gets whether or not the texture contains RGBD data.
  26966. */
  26967. readonly isRGBD: boolean;
  26968. /**
  26969. * Is Z inverted in the texture (useful in a cube texture).
  26970. */
  26971. invertZ: boolean;
  26972. /**
  26973. * Are mip maps generated for this texture or not.
  26974. */
  26975. readonly noMipmap: boolean;
  26976. /**
  26977. * @hidden
  26978. */
  26979. lodLevelInAlpha: boolean;
  26980. /**
  26981. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26982. */
  26983. lodGenerationOffset: number;
  26984. /**
  26985. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26986. */
  26987. lodGenerationScale: number;
  26988. /**
  26989. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26990. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26991. * average roughness values.
  26992. */
  26993. linearSpecularLOD: boolean;
  26994. /**
  26995. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26996. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26997. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26998. */
  26999. irradianceTexture: Nullable<BaseTexture>;
  27000. /**
  27001. * Define if the texture is a render target.
  27002. */
  27003. isRenderTarget: boolean;
  27004. /**
  27005. * Define the unique id of the texture in the scene.
  27006. */
  27007. readonly uid: string;
  27008. /**
  27009. * Return a string representation of the texture.
  27010. * @returns the texture as a string
  27011. */
  27012. toString(): string;
  27013. /**
  27014. * Get the class name of the texture.
  27015. * @returns "BaseTexture"
  27016. */
  27017. getClassName(): string;
  27018. /**
  27019. * Define the list of animation attached to the texture.
  27020. */
  27021. animations: import("babylonjs/Animations/animation").Animation[];
  27022. /**
  27023. * An event triggered when the texture is disposed.
  27024. */
  27025. onDisposeObservable: Observable<BaseTexture>;
  27026. private _onDisposeObserver;
  27027. /**
  27028. * Callback triggered when the texture has been disposed.
  27029. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27030. */
  27031. onDispose: () => void;
  27032. /**
  27033. * Define the current state of the loading sequence when in delayed load mode.
  27034. */
  27035. delayLoadState: number;
  27036. private _scene;
  27037. /** @hidden */
  27038. _texture: Nullable<InternalTexture>;
  27039. private _uid;
  27040. /**
  27041. * Define if the texture is preventinga material to render or not.
  27042. * If not and the texture is not ready, the engine will use a default black texture instead.
  27043. */
  27044. readonly isBlocking: boolean;
  27045. /**
  27046. * Instantiates a new BaseTexture.
  27047. * Base class of all the textures in babylon.
  27048. * It groups all the common properties the materials, post process, lights... might need
  27049. * in order to make a correct use of the texture.
  27050. * @param scene Define the scene the texture blongs to
  27051. */
  27052. constructor(scene: Nullable<Scene>);
  27053. /**
  27054. * Get the scene the texture belongs to.
  27055. * @returns the scene or null if undefined
  27056. */
  27057. getScene(): Nullable<Scene>;
  27058. /**
  27059. * Get the texture transform matrix used to offset tile the texture for istance.
  27060. * @returns the transformation matrix
  27061. */
  27062. getTextureMatrix(): Matrix;
  27063. /**
  27064. * Get the texture reflection matrix used to rotate/transform the reflection.
  27065. * @returns the reflection matrix
  27066. */
  27067. getReflectionTextureMatrix(): Matrix;
  27068. /**
  27069. * Get the underlying lower level texture from Babylon.
  27070. * @returns the insternal texture
  27071. */
  27072. getInternalTexture(): Nullable<InternalTexture>;
  27073. /**
  27074. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27075. * @returns true if ready or not blocking
  27076. */
  27077. isReadyOrNotBlocking(): boolean;
  27078. /**
  27079. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27080. * @returns true if fully ready
  27081. */
  27082. isReady(): boolean;
  27083. private _cachedSize;
  27084. /**
  27085. * Get the size of the texture.
  27086. * @returns the texture size.
  27087. */
  27088. getSize(): ISize;
  27089. /**
  27090. * Get the base size of the texture.
  27091. * It can be different from the size if the texture has been resized for POT for instance
  27092. * @returns the base size
  27093. */
  27094. getBaseSize(): ISize;
  27095. /**
  27096. * Update the sampling mode of the texture.
  27097. * Default is Trilinear mode.
  27098. *
  27099. * | Value | Type | Description |
  27100. * | ----- | ------------------ | ----------- |
  27101. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27102. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27103. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27104. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27105. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27106. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27107. * | 7 | NEAREST_LINEAR | |
  27108. * | 8 | NEAREST_NEAREST | |
  27109. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27110. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27111. * | 11 | LINEAR_LINEAR | |
  27112. * | 12 | LINEAR_NEAREST | |
  27113. *
  27114. * > _mag_: magnification filter (close to the viewer)
  27115. * > _min_: minification filter (far from the viewer)
  27116. * > _mip_: filter used between mip map levels
  27117. *@param samplingMode Define the new sampling mode of the texture
  27118. */
  27119. updateSamplingMode(samplingMode: number): void;
  27120. /**
  27121. * Scales the texture if is `canRescale()`
  27122. * @param ratio the resize factor we want to use to rescale
  27123. */
  27124. scale(ratio: number): void;
  27125. /**
  27126. * Get if the texture can rescale.
  27127. */
  27128. readonly canRescale: boolean;
  27129. /** @hidden */
  27130. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27131. /** @hidden */
  27132. _rebuild(): void;
  27133. /**
  27134. * Triggers the load sequence in delayed load mode.
  27135. */
  27136. delayLoad(): void;
  27137. /**
  27138. * Clones the texture.
  27139. * @returns the cloned texture
  27140. */
  27141. clone(): Nullable<BaseTexture>;
  27142. /**
  27143. * Get the texture underlying type (INT, FLOAT...)
  27144. */
  27145. readonly textureType: number;
  27146. /**
  27147. * Get the texture underlying format (RGB, RGBA...)
  27148. */
  27149. readonly textureFormat: number;
  27150. /**
  27151. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27152. * This will returns an RGBA array buffer containing either in values (0-255) or
  27153. * float values (0-1) depending of the underlying buffer type.
  27154. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27155. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27156. * @param buffer defines a user defined buffer to fill with data (can be null)
  27157. * @returns The Array buffer containing the pixels data.
  27158. */
  27159. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27160. /**
  27161. * Release and destroy the underlying lower level texture aka internalTexture.
  27162. */
  27163. releaseInternalTexture(): void;
  27164. /**
  27165. * Get the polynomial representation of the texture data.
  27166. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27167. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27168. */
  27169. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27170. /** @hidden */
  27171. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27172. /** @hidden */
  27173. readonly _lodTextureMid: Nullable<BaseTexture>;
  27174. /** @hidden */
  27175. readonly _lodTextureLow: Nullable<BaseTexture>;
  27176. /**
  27177. * Dispose the texture and release its associated resources.
  27178. */
  27179. dispose(): void;
  27180. /**
  27181. * Serialize the texture into a JSON representation that can be parsed later on.
  27182. * @returns the JSON representation of the texture
  27183. */
  27184. serialize(): any;
  27185. /**
  27186. * Helper function to be called back once a list of texture contains only ready textures.
  27187. * @param textures Define the list of textures to wait for
  27188. * @param callback Define the callback triggered once the entire list will be ready
  27189. */
  27190. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27191. }
  27192. }
  27193. declare module "babylonjs/Materials/uniformBuffer" {
  27194. import { Nullable, FloatArray } from "babylonjs/types";
  27195. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27196. import { Engine } from "babylonjs/Engines/engine";
  27197. import { Effect } from "babylonjs/Materials/effect";
  27198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27199. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27200. /**
  27201. * Uniform buffer objects.
  27202. *
  27203. * Handles blocks of uniform on the GPU.
  27204. *
  27205. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27206. *
  27207. * For more information, please refer to :
  27208. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27209. */
  27210. export class UniformBuffer {
  27211. private _engine;
  27212. private _buffer;
  27213. private _data;
  27214. private _bufferData;
  27215. private _dynamic?;
  27216. private _uniformLocations;
  27217. private _uniformSizes;
  27218. private _uniformLocationPointer;
  27219. private _needSync;
  27220. private _noUBO;
  27221. private _currentEffect;
  27222. private static _MAX_UNIFORM_SIZE;
  27223. private static _tempBuffer;
  27224. /**
  27225. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27226. * This is dynamic to allow compat with webgl 1 and 2.
  27227. * You will need to pass the name of the uniform as well as the value.
  27228. */
  27229. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27230. /**
  27231. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27232. * This is dynamic to allow compat with webgl 1 and 2.
  27233. * You will need to pass the name of the uniform as well as the value.
  27234. */
  27235. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27236. /**
  27237. * Lambda to Update a single float in a uniform buffer.
  27238. * This is dynamic to allow compat with webgl 1 and 2.
  27239. * You will need to pass the name of the uniform as well as the value.
  27240. */
  27241. updateFloat: (name: string, x: number) => void;
  27242. /**
  27243. * Lambda to Update a vec2 of float in a uniform buffer.
  27244. * This is dynamic to allow compat with webgl 1 and 2.
  27245. * You will need to pass the name of the uniform as well as the value.
  27246. */
  27247. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27248. /**
  27249. * Lambda to Update a vec3 of float in a uniform buffer.
  27250. * This is dynamic to allow compat with webgl 1 and 2.
  27251. * You will need to pass the name of the uniform as well as the value.
  27252. */
  27253. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27254. /**
  27255. * Lambda to Update a vec4 of float in a uniform buffer.
  27256. * This is dynamic to allow compat with webgl 1 and 2.
  27257. * You will need to pass the name of the uniform as well as the value.
  27258. */
  27259. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27260. /**
  27261. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27262. * This is dynamic to allow compat with webgl 1 and 2.
  27263. * You will need to pass the name of the uniform as well as the value.
  27264. */
  27265. updateMatrix: (name: string, mat: Matrix) => void;
  27266. /**
  27267. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27268. * This is dynamic to allow compat with webgl 1 and 2.
  27269. * You will need to pass the name of the uniform as well as the value.
  27270. */
  27271. updateVector3: (name: string, vector: Vector3) => void;
  27272. /**
  27273. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27274. * This is dynamic to allow compat with webgl 1 and 2.
  27275. * You will need to pass the name of the uniform as well as the value.
  27276. */
  27277. updateVector4: (name: string, vector: Vector4) => void;
  27278. /**
  27279. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27280. * This is dynamic to allow compat with webgl 1 and 2.
  27281. * You will need to pass the name of the uniform as well as the value.
  27282. */
  27283. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27284. /**
  27285. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27286. * This is dynamic to allow compat with webgl 1 and 2.
  27287. * You will need to pass the name of the uniform as well as the value.
  27288. */
  27289. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27290. /**
  27291. * Instantiates a new Uniform buffer objects.
  27292. *
  27293. * Handles blocks of uniform on the GPU.
  27294. *
  27295. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27296. *
  27297. * For more information, please refer to :
  27298. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27299. * @param engine Define the engine the buffer is associated with
  27300. * @param data Define the data contained in the buffer
  27301. * @param dynamic Define if the buffer is updatable
  27302. */
  27303. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27304. /**
  27305. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27306. * or just falling back on setUniformXXX calls.
  27307. */
  27308. readonly useUbo: boolean;
  27309. /**
  27310. * Indicates if the WebGL underlying uniform buffer is in sync
  27311. * with the javascript cache data.
  27312. */
  27313. readonly isSync: boolean;
  27314. /**
  27315. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27316. * Also, a dynamic UniformBuffer will disable cache verification and always
  27317. * update the underlying WebGL uniform buffer to the GPU.
  27318. * @returns if Dynamic, otherwise false
  27319. */
  27320. isDynamic(): boolean;
  27321. /**
  27322. * The data cache on JS side.
  27323. * @returns the underlying data as a float array
  27324. */
  27325. getData(): Float32Array;
  27326. /**
  27327. * The underlying WebGL Uniform buffer.
  27328. * @returns the webgl buffer
  27329. */
  27330. getBuffer(): Nullable<DataBuffer>;
  27331. /**
  27332. * std140 layout specifies how to align data within an UBO structure.
  27333. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27334. * for specs.
  27335. */
  27336. private _fillAlignment;
  27337. /**
  27338. * Adds an uniform in the buffer.
  27339. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27340. * for the layout to be correct !
  27341. * @param name Name of the uniform, as used in the uniform block in the shader.
  27342. * @param size Data size, or data directly.
  27343. */
  27344. addUniform(name: string, size: number | number[]): void;
  27345. /**
  27346. * Adds a Matrix 4x4 to the uniform buffer.
  27347. * @param name Name of the uniform, as used in the uniform block in the shader.
  27348. * @param mat A 4x4 matrix.
  27349. */
  27350. addMatrix(name: string, mat: Matrix): void;
  27351. /**
  27352. * Adds a vec2 to the uniform buffer.
  27353. * @param name Name of the uniform, as used in the uniform block in the shader.
  27354. * @param x Define the x component value of the vec2
  27355. * @param y Define the y component value of the vec2
  27356. */
  27357. addFloat2(name: string, x: number, y: number): void;
  27358. /**
  27359. * Adds a vec3 to the uniform buffer.
  27360. * @param name Name of the uniform, as used in the uniform block in the shader.
  27361. * @param x Define the x component value of the vec3
  27362. * @param y Define the y component value of the vec3
  27363. * @param z Define the z component value of the vec3
  27364. */
  27365. addFloat3(name: string, x: number, y: number, z: number): void;
  27366. /**
  27367. * Adds a vec3 to the uniform buffer.
  27368. * @param name Name of the uniform, as used in the uniform block in the shader.
  27369. * @param color Define the vec3 from a Color
  27370. */
  27371. addColor3(name: string, color: Color3): void;
  27372. /**
  27373. * Adds a vec4 to the uniform buffer.
  27374. * @param name Name of the uniform, as used in the uniform block in the shader.
  27375. * @param color Define the rgb components from a Color
  27376. * @param alpha Define the a component of the vec4
  27377. */
  27378. addColor4(name: string, color: Color3, alpha: number): void;
  27379. /**
  27380. * Adds a vec3 to the uniform buffer.
  27381. * @param name Name of the uniform, as used in the uniform block in the shader.
  27382. * @param vector Define the vec3 components from a Vector
  27383. */
  27384. addVector3(name: string, vector: Vector3): void;
  27385. /**
  27386. * Adds a Matrix 3x3 to the uniform buffer.
  27387. * @param name Name of the uniform, as used in the uniform block in the shader.
  27388. */
  27389. addMatrix3x3(name: string): void;
  27390. /**
  27391. * Adds a Matrix 2x2 to the uniform buffer.
  27392. * @param name Name of the uniform, as used in the uniform block in the shader.
  27393. */
  27394. addMatrix2x2(name: string): void;
  27395. /**
  27396. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27397. */
  27398. create(): void;
  27399. /** @hidden */
  27400. _rebuild(): void;
  27401. /**
  27402. * Updates the WebGL Uniform Buffer on the GPU.
  27403. * If the `dynamic` flag is set to true, no cache comparison is done.
  27404. * Otherwise, the buffer will be updated only if the cache differs.
  27405. */
  27406. update(): void;
  27407. /**
  27408. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27409. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27410. * @param data Define the flattened data
  27411. * @param size Define the size of the data.
  27412. */
  27413. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27414. private _updateMatrix3x3ForUniform;
  27415. private _updateMatrix3x3ForEffect;
  27416. private _updateMatrix2x2ForEffect;
  27417. private _updateMatrix2x2ForUniform;
  27418. private _updateFloatForEffect;
  27419. private _updateFloatForUniform;
  27420. private _updateFloat2ForEffect;
  27421. private _updateFloat2ForUniform;
  27422. private _updateFloat3ForEffect;
  27423. private _updateFloat3ForUniform;
  27424. private _updateFloat4ForEffect;
  27425. private _updateFloat4ForUniform;
  27426. private _updateMatrixForEffect;
  27427. private _updateMatrixForUniform;
  27428. private _updateVector3ForEffect;
  27429. private _updateVector3ForUniform;
  27430. private _updateVector4ForEffect;
  27431. private _updateVector4ForUniform;
  27432. private _updateColor3ForEffect;
  27433. private _updateColor3ForUniform;
  27434. private _updateColor4ForEffect;
  27435. private _updateColor4ForUniform;
  27436. /**
  27437. * Sets a sampler uniform on the effect.
  27438. * @param name Define the name of the sampler.
  27439. * @param texture Define the texture to set in the sampler
  27440. */
  27441. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27442. /**
  27443. * Directly updates the value of the uniform in the cache AND on the GPU.
  27444. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27445. * @param data Define the flattened data
  27446. */
  27447. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27448. /**
  27449. * Binds this uniform buffer to an effect.
  27450. * @param effect Define the effect to bind the buffer to
  27451. * @param name Name of the uniform block in the shader.
  27452. */
  27453. bindToEffect(effect: Effect, name: string): void;
  27454. /**
  27455. * Disposes the uniform buffer.
  27456. */
  27457. dispose(): void;
  27458. }
  27459. }
  27460. declare module "babylonjs/Audio/analyser" {
  27461. import { Scene } from "babylonjs/scene";
  27462. /**
  27463. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27465. */
  27466. export class Analyser {
  27467. /**
  27468. * Gets or sets the smoothing
  27469. * @ignorenaming
  27470. */
  27471. SMOOTHING: number;
  27472. /**
  27473. * Gets or sets the FFT table size
  27474. * @ignorenaming
  27475. */
  27476. FFT_SIZE: number;
  27477. /**
  27478. * Gets or sets the bar graph amplitude
  27479. * @ignorenaming
  27480. */
  27481. BARGRAPHAMPLITUDE: number;
  27482. /**
  27483. * Gets or sets the position of the debug canvas
  27484. * @ignorenaming
  27485. */
  27486. DEBUGCANVASPOS: {
  27487. x: number;
  27488. y: number;
  27489. };
  27490. /**
  27491. * Gets or sets the debug canvas size
  27492. * @ignorenaming
  27493. */
  27494. DEBUGCANVASSIZE: {
  27495. width: number;
  27496. height: number;
  27497. };
  27498. private _byteFreqs;
  27499. private _byteTime;
  27500. private _floatFreqs;
  27501. private _webAudioAnalyser;
  27502. private _debugCanvas;
  27503. private _debugCanvasContext;
  27504. private _scene;
  27505. private _registerFunc;
  27506. private _audioEngine;
  27507. /**
  27508. * Creates a new analyser
  27509. * @param scene defines hosting scene
  27510. */
  27511. constructor(scene: Scene);
  27512. /**
  27513. * Get the number of data values you will have to play with for the visualization
  27514. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27515. * @returns a number
  27516. */
  27517. getFrequencyBinCount(): number;
  27518. /**
  27519. * Gets the current frequency data as a byte array
  27520. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27521. * @returns a Uint8Array
  27522. */
  27523. getByteFrequencyData(): Uint8Array;
  27524. /**
  27525. * Gets the current waveform as a byte array
  27526. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27527. * @returns a Uint8Array
  27528. */
  27529. getByteTimeDomainData(): Uint8Array;
  27530. /**
  27531. * Gets the current frequency data as a float array
  27532. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27533. * @returns a Float32Array
  27534. */
  27535. getFloatFrequencyData(): Float32Array;
  27536. /**
  27537. * Renders the debug canvas
  27538. */
  27539. drawDebugCanvas(): void;
  27540. /**
  27541. * Stops rendering the debug canvas and removes it
  27542. */
  27543. stopDebugCanvas(): void;
  27544. /**
  27545. * Connects two audio nodes
  27546. * @param inputAudioNode defines first node to connect
  27547. * @param outputAudioNode defines second node to connect
  27548. */
  27549. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27550. /**
  27551. * Releases all associated resources
  27552. */
  27553. dispose(): void;
  27554. }
  27555. }
  27556. declare module "babylonjs/Audio/audioEngine" {
  27557. import { IDisposable } from "babylonjs/scene";
  27558. import { Analyser } from "babylonjs/Audio/analyser";
  27559. import { Nullable } from "babylonjs/types";
  27560. import { Observable } from "babylonjs/Misc/observable";
  27561. /**
  27562. * This represents an audio engine and it is responsible
  27563. * to play, synchronize and analyse sounds throughout the application.
  27564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27565. */
  27566. export interface IAudioEngine extends IDisposable {
  27567. /**
  27568. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27569. */
  27570. readonly canUseWebAudio: boolean;
  27571. /**
  27572. * Gets the current AudioContext if available.
  27573. */
  27574. readonly audioContext: Nullable<AudioContext>;
  27575. /**
  27576. * The master gain node defines the global audio volume of your audio engine.
  27577. */
  27578. readonly masterGain: GainNode;
  27579. /**
  27580. * Gets whether or not mp3 are supported by your browser.
  27581. */
  27582. readonly isMP3supported: boolean;
  27583. /**
  27584. * Gets whether or not ogg are supported by your browser.
  27585. */
  27586. readonly isOGGsupported: boolean;
  27587. /**
  27588. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27589. * @ignoreNaming
  27590. */
  27591. WarnedWebAudioUnsupported: boolean;
  27592. /**
  27593. * Defines if the audio engine relies on a custom unlocked button.
  27594. * In this case, the embedded button will not be displayed.
  27595. */
  27596. useCustomUnlockedButton: boolean;
  27597. /**
  27598. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27599. */
  27600. readonly unlocked: boolean;
  27601. /**
  27602. * Event raised when audio has been unlocked on the browser.
  27603. */
  27604. onAudioUnlockedObservable: Observable<AudioEngine>;
  27605. /**
  27606. * Event raised when audio has been locked on the browser.
  27607. */
  27608. onAudioLockedObservable: Observable<AudioEngine>;
  27609. /**
  27610. * Flags the audio engine in Locked state.
  27611. * This happens due to new browser policies preventing audio to autoplay.
  27612. */
  27613. lock(): void;
  27614. /**
  27615. * Unlocks the audio engine once a user action has been done on the dom.
  27616. * This is helpful to resume play once browser policies have been satisfied.
  27617. */
  27618. unlock(): void;
  27619. }
  27620. /**
  27621. * This represents the default audio engine used in babylon.
  27622. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27624. */
  27625. export class AudioEngine implements IAudioEngine {
  27626. private _audioContext;
  27627. private _audioContextInitialized;
  27628. private _muteButton;
  27629. private _hostElement;
  27630. /**
  27631. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27632. */
  27633. canUseWebAudio: boolean;
  27634. /**
  27635. * The master gain node defines the global audio volume of your audio engine.
  27636. */
  27637. masterGain: GainNode;
  27638. /**
  27639. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27640. * @ignoreNaming
  27641. */
  27642. WarnedWebAudioUnsupported: boolean;
  27643. /**
  27644. * Gets whether or not mp3 are supported by your browser.
  27645. */
  27646. isMP3supported: boolean;
  27647. /**
  27648. * Gets whether or not ogg are supported by your browser.
  27649. */
  27650. isOGGsupported: boolean;
  27651. /**
  27652. * Gets whether audio has been unlocked on the device.
  27653. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27654. * a user interaction has happened.
  27655. */
  27656. unlocked: boolean;
  27657. /**
  27658. * Defines if the audio engine relies on a custom unlocked button.
  27659. * In this case, the embedded button will not be displayed.
  27660. */
  27661. useCustomUnlockedButton: boolean;
  27662. /**
  27663. * Event raised when audio has been unlocked on the browser.
  27664. */
  27665. onAudioUnlockedObservable: Observable<AudioEngine>;
  27666. /**
  27667. * Event raised when audio has been locked on the browser.
  27668. */
  27669. onAudioLockedObservable: Observable<AudioEngine>;
  27670. /**
  27671. * Gets the current AudioContext if available.
  27672. */
  27673. readonly audioContext: Nullable<AudioContext>;
  27674. private _connectedAnalyser;
  27675. /**
  27676. * Instantiates a new audio engine.
  27677. *
  27678. * There should be only one per page as some browsers restrict the number
  27679. * of audio contexts you can create.
  27680. * @param hostElement defines the host element where to display the mute icon if necessary
  27681. */
  27682. constructor(hostElement?: Nullable<HTMLElement>);
  27683. /**
  27684. * Flags the audio engine in Locked state.
  27685. * This happens due to new browser policies preventing audio to autoplay.
  27686. */
  27687. lock(): void;
  27688. /**
  27689. * Unlocks the audio engine once a user action has been done on the dom.
  27690. * This is helpful to resume play once browser policies have been satisfied.
  27691. */
  27692. unlock(): void;
  27693. private _resumeAudioContext;
  27694. private _initializeAudioContext;
  27695. private _tryToRun;
  27696. private _triggerRunningState;
  27697. private _triggerSuspendedState;
  27698. private _displayMuteButton;
  27699. private _moveButtonToTopLeft;
  27700. private _onResize;
  27701. private _hideMuteButton;
  27702. /**
  27703. * Destroy and release the resources associated with the audio ccontext.
  27704. */
  27705. dispose(): void;
  27706. /**
  27707. * Gets the global volume sets on the master gain.
  27708. * @returns the global volume if set or -1 otherwise
  27709. */
  27710. getGlobalVolume(): number;
  27711. /**
  27712. * Sets the global volume of your experience (sets on the master gain).
  27713. * @param newVolume Defines the new global volume of the application
  27714. */
  27715. setGlobalVolume(newVolume: number): void;
  27716. /**
  27717. * Connect the audio engine to an audio analyser allowing some amazing
  27718. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27720. * @param analyser The analyser to connect to the engine
  27721. */
  27722. connectToAnalyser(analyser: Analyser): void;
  27723. }
  27724. }
  27725. declare module "babylonjs/Loading/loadingScreen" {
  27726. /**
  27727. * Interface used to present a loading screen while loading a scene
  27728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27729. */
  27730. export interface ILoadingScreen {
  27731. /**
  27732. * Function called to display the loading screen
  27733. */
  27734. displayLoadingUI: () => void;
  27735. /**
  27736. * Function called to hide the loading screen
  27737. */
  27738. hideLoadingUI: () => void;
  27739. /**
  27740. * Gets or sets the color to use for the background
  27741. */
  27742. loadingUIBackgroundColor: string;
  27743. /**
  27744. * Gets or sets the text to display while loading
  27745. */
  27746. loadingUIText: string;
  27747. }
  27748. /**
  27749. * Class used for the default loading screen
  27750. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27751. */
  27752. export class DefaultLoadingScreen implements ILoadingScreen {
  27753. private _renderingCanvas;
  27754. private _loadingText;
  27755. private _loadingDivBackgroundColor;
  27756. private _loadingDiv;
  27757. private _loadingTextDiv;
  27758. /** Gets or sets the logo url to use for the default loading screen */
  27759. static DefaultLogoUrl: string;
  27760. /** Gets or sets the spinner url to use for the default loading screen */
  27761. static DefaultSpinnerUrl: string;
  27762. /**
  27763. * Creates a new default loading screen
  27764. * @param _renderingCanvas defines the canvas used to render the scene
  27765. * @param _loadingText defines the default text to display
  27766. * @param _loadingDivBackgroundColor defines the default background color
  27767. */
  27768. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27769. /**
  27770. * Function called to display the loading screen
  27771. */
  27772. displayLoadingUI(): void;
  27773. /**
  27774. * Function called to hide the loading screen
  27775. */
  27776. hideLoadingUI(): void;
  27777. /**
  27778. * Gets or sets the text to display while loading
  27779. */
  27780. loadingUIText: string;
  27781. /**
  27782. * Gets or sets the color to use for the background
  27783. */
  27784. loadingUIBackgroundColor: string;
  27785. private _resizeLoadingUI;
  27786. }
  27787. }
  27788. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27789. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27790. import { Engine } from "babylonjs/Engines/engine";
  27791. import { Nullable } from "babylonjs/types";
  27792. /** @hidden */
  27793. export class WebGLPipelineContext implements IPipelineContext {
  27794. engine: Engine;
  27795. program: Nullable<WebGLProgram>;
  27796. context?: WebGLRenderingContext;
  27797. vertexShader?: WebGLShader;
  27798. fragmentShader?: WebGLShader;
  27799. isParallelCompiled: boolean;
  27800. onCompiled?: () => void;
  27801. transformFeedback?: WebGLTransformFeedback | null;
  27802. readonly isAsync: boolean;
  27803. readonly isReady: boolean;
  27804. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27805. }
  27806. }
  27807. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27808. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27809. /** @hidden */
  27810. export class WebGLDataBuffer extends DataBuffer {
  27811. private _buffer;
  27812. constructor(resource: WebGLBuffer);
  27813. readonly underlyingResource: any;
  27814. }
  27815. }
  27816. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27817. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27818. /** @hidden */
  27819. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27820. attributeProcessor(attribute: string): string;
  27821. varyingProcessor(varying: string, isFragment: boolean): string;
  27822. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27823. }
  27824. }
  27825. declare module "babylonjs/Materials/Textures/videoTexture" {
  27826. import { Observable } from "babylonjs/Misc/observable";
  27827. import { Nullable } from "babylonjs/types";
  27828. import { Scene } from "babylonjs/scene";
  27829. import { Texture } from "babylonjs/Materials/Textures/texture";
  27830. /**
  27831. * Settings for finer control over video usage
  27832. */
  27833. export interface VideoTextureSettings {
  27834. /**
  27835. * Applies `autoplay` to video, if specified
  27836. */
  27837. autoPlay?: boolean;
  27838. /**
  27839. * Applies `loop` to video, if specified
  27840. */
  27841. loop?: boolean;
  27842. /**
  27843. * Automatically updates internal texture from video at every frame in the render loop
  27844. */
  27845. autoUpdateTexture: boolean;
  27846. /**
  27847. * Image src displayed during the video loading or until the user interacts with the video.
  27848. */
  27849. poster?: string;
  27850. }
  27851. /**
  27852. * If you want to display a video in your scene, this is the special texture for that.
  27853. * This special texture works similar to other textures, with the exception of a few parameters.
  27854. * @see https://doc.babylonjs.com/how_to/video_texture
  27855. */
  27856. export class VideoTexture extends Texture {
  27857. /**
  27858. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27859. */
  27860. readonly autoUpdateTexture: boolean;
  27861. /**
  27862. * The video instance used by the texture internally
  27863. */
  27864. readonly video: HTMLVideoElement;
  27865. private _onUserActionRequestedObservable;
  27866. /**
  27867. * Event triggerd when a dom action is required by the user to play the video.
  27868. * This happens due to recent changes in browser policies preventing video to auto start.
  27869. */
  27870. readonly onUserActionRequestedObservable: Observable<Texture>;
  27871. private _generateMipMaps;
  27872. private _engine;
  27873. private _stillImageCaptured;
  27874. private _displayingPosterTexture;
  27875. private _settings;
  27876. private _createInternalTextureOnEvent;
  27877. /**
  27878. * Creates a video texture.
  27879. * If you want to display a video in your scene, this is the special texture for that.
  27880. * This special texture works similar to other textures, with the exception of a few parameters.
  27881. * @see https://doc.babylonjs.com/how_to/video_texture
  27882. * @param name optional name, will detect from video source, if not defined
  27883. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27884. * @param scene is obviously the current scene.
  27885. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27886. * @param invertY is false by default but can be used to invert video on Y axis
  27887. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27888. * @param settings allows finer control over video usage
  27889. */
  27890. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27891. private _getName;
  27892. private _getVideo;
  27893. private _createInternalTexture;
  27894. private reset;
  27895. /**
  27896. * @hidden Internal method to initiate `update`.
  27897. */
  27898. _rebuild(): void;
  27899. /**
  27900. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27901. */
  27902. update(): void;
  27903. /**
  27904. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27905. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27906. */
  27907. updateTexture(isVisible: boolean): void;
  27908. protected _updateInternalTexture: () => void;
  27909. /**
  27910. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27911. * @param url New url.
  27912. */
  27913. updateURL(url: string): void;
  27914. /**
  27915. * Dispose the texture and release its associated resources.
  27916. */
  27917. dispose(): void;
  27918. /**
  27919. * Creates a video texture straight from a stream.
  27920. * @param scene Define the scene the texture should be created in
  27921. * @param stream Define the stream the texture should be created from
  27922. * @returns The created video texture as a promise
  27923. */
  27924. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27925. /**
  27926. * Creates a video texture straight from your WebCam video feed.
  27927. * @param scene Define the scene the texture should be created in
  27928. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27929. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27930. * @returns The created video texture as a promise
  27931. */
  27932. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27933. minWidth: number;
  27934. maxWidth: number;
  27935. minHeight: number;
  27936. maxHeight: number;
  27937. deviceId: string;
  27938. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27939. /**
  27940. * Creates a video texture straight from your WebCam video feed.
  27941. * @param scene Define the scene the texture should be created in
  27942. * @param onReady Define a callback to triggered once the texture will be ready
  27943. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27944. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27945. */
  27946. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27947. minWidth: number;
  27948. maxWidth: number;
  27949. minHeight: number;
  27950. maxHeight: number;
  27951. deviceId: string;
  27952. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27953. }
  27954. }
  27955. declare module "babylonjs/Engines/engine" {
  27956. import { Observable } from "babylonjs/Misc/observable";
  27957. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27958. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27959. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27960. import { Camera } from "babylonjs/Cameras/camera";
  27961. import { Scene } from "babylonjs/scene";
  27962. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27963. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27964. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27965. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27966. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27969. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27970. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27971. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27972. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27973. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27974. import { WebRequest } from "babylonjs/Misc/webRequest";
  27975. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27976. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27977. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27978. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27979. import { Material } from "babylonjs/Materials/material";
  27980. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27981. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27982. /**
  27983. * Interface for attribute information associated with buffer instanciation
  27984. */
  27985. export class InstancingAttributeInfo {
  27986. /**
  27987. * Index/offset of the attribute in the vertex shader
  27988. */
  27989. index: number;
  27990. /**
  27991. * size of the attribute, 1, 2, 3 or 4
  27992. */
  27993. attributeSize: number;
  27994. /**
  27995. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27996. * default is FLOAT
  27997. */
  27998. attribyteType: number;
  27999. /**
  28000. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28001. */
  28002. normalized: boolean;
  28003. /**
  28004. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28005. */
  28006. offset: number;
  28007. /**
  28008. * Name of the GLSL attribute, for debugging purpose only
  28009. */
  28010. attributeName: string;
  28011. }
  28012. /**
  28013. * Define options used to create a depth texture
  28014. */
  28015. export class DepthTextureCreationOptions {
  28016. /** Specifies whether or not a stencil should be allocated in the texture */
  28017. generateStencil?: boolean;
  28018. /** Specifies whether or not bilinear filtering is enable on the texture */
  28019. bilinearFiltering?: boolean;
  28020. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28021. comparisonFunction?: number;
  28022. /** Specifies if the created texture is a cube texture */
  28023. isCube?: boolean;
  28024. }
  28025. /**
  28026. * Class used to describe the capabilities of the engine relatively to the current browser
  28027. */
  28028. export class EngineCapabilities {
  28029. /** Maximum textures units per fragment shader */
  28030. maxTexturesImageUnits: number;
  28031. /** Maximum texture units per vertex shader */
  28032. maxVertexTextureImageUnits: number;
  28033. /** Maximum textures units in the entire pipeline */
  28034. maxCombinedTexturesImageUnits: number;
  28035. /** Maximum texture size */
  28036. maxTextureSize: number;
  28037. /** Maximum cube texture size */
  28038. maxCubemapTextureSize: number;
  28039. /** Maximum render texture size */
  28040. maxRenderTextureSize: number;
  28041. /** Maximum number of vertex attributes */
  28042. maxVertexAttribs: number;
  28043. /** Maximum number of varyings */
  28044. maxVaryingVectors: number;
  28045. /** Maximum number of uniforms per vertex shader */
  28046. maxVertexUniformVectors: number;
  28047. /** Maximum number of uniforms per fragment shader */
  28048. maxFragmentUniformVectors: number;
  28049. /** Defines if standard derivates (dx/dy) are supported */
  28050. standardDerivatives: boolean;
  28051. /** Defines if s3tc texture compression is supported */
  28052. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28053. /** Defines if pvrtc texture compression is supported */
  28054. pvrtc: any;
  28055. /** Defines if etc1 texture compression is supported */
  28056. etc1: any;
  28057. /** Defines if etc2 texture compression is supported */
  28058. etc2: any;
  28059. /** Defines if astc texture compression is supported */
  28060. astc: any;
  28061. /** Defines if float textures are supported */
  28062. textureFloat: boolean;
  28063. /** Defines if vertex array objects are supported */
  28064. vertexArrayObject: boolean;
  28065. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28066. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28067. /** Gets the maximum level of anisotropy supported */
  28068. maxAnisotropy: number;
  28069. /** Defines if instancing is supported */
  28070. instancedArrays: boolean;
  28071. /** Defines if 32 bits indices are supported */
  28072. uintIndices: boolean;
  28073. /** Defines if high precision shaders are supported */
  28074. highPrecisionShaderSupported: boolean;
  28075. /** Defines if depth reading in the fragment shader is supported */
  28076. fragmentDepthSupported: boolean;
  28077. /** Defines if float texture linear filtering is supported*/
  28078. textureFloatLinearFiltering: boolean;
  28079. /** Defines if rendering to float textures is supported */
  28080. textureFloatRender: boolean;
  28081. /** Defines if half float textures are supported*/
  28082. textureHalfFloat: boolean;
  28083. /** Defines if half float texture linear filtering is supported*/
  28084. textureHalfFloatLinearFiltering: boolean;
  28085. /** Defines if rendering to half float textures is supported */
  28086. textureHalfFloatRender: boolean;
  28087. /** Defines if textureLOD shader command is supported */
  28088. textureLOD: boolean;
  28089. /** Defines if draw buffers extension is supported */
  28090. drawBuffersExtension: boolean;
  28091. /** Defines if depth textures are supported */
  28092. depthTextureExtension: boolean;
  28093. /** Defines if float color buffer are supported */
  28094. colorBufferFloat: boolean;
  28095. /** Gets disjoint timer query extension (null if not supported) */
  28096. timerQuery: EXT_disjoint_timer_query;
  28097. /** Defines if timestamp can be used with timer query */
  28098. canUseTimestampForTimerQuery: boolean;
  28099. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28100. multiview: any;
  28101. /** Function used to let the system compiles shaders in background */
  28102. parallelShaderCompile: {
  28103. COMPLETION_STATUS_KHR: number;
  28104. };
  28105. }
  28106. /** Interface defining initialization parameters for Engine class */
  28107. export interface EngineOptions extends WebGLContextAttributes {
  28108. /**
  28109. * Defines if the engine should no exceed a specified device ratio
  28110. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28111. */
  28112. limitDeviceRatio?: number;
  28113. /**
  28114. * Defines if webvr should be enabled automatically
  28115. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28116. */
  28117. autoEnableWebVR?: boolean;
  28118. /**
  28119. * Defines if webgl2 should be turned off even if supported
  28120. * @see http://doc.babylonjs.com/features/webgl2
  28121. */
  28122. disableWebGL2Support?: boolean;
  28123. /**
  28124. * Defines if webaudio should be initialized as well
  28125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28126. */
  28127. audioEngine?: boolean;
  28128. /**
  28129. * Defines if animations should run using a deterministic lock step
  28130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28131. */
  28132. deterministicLockstep?: boolean;
  28133. /** Defines the maximum steps to use with deterministic lock step mode */
  28134. lockstepMaxSteps?: number;
  28135. /**
  28136. * Defines that engine should ignore context lost events
  28137. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28138. */
  28139. doNotHandleContextLost?: boolean;
  28140. /**
  28141. * Defines that engine should ignore modifying touch action attribute and style
  28142. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28143. */
  28144. doNotHandleTouchAction?: boolean;
  28145. /**
  28146. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28147. */
  28148. useHighPrecisionFloats?: boolean;
  28149. }
  28150. /**
  28151. * Defines the interface used by display changed events
  28152. */
  28153. export interface IDisplayChangedEventArgs {
  28154. /** Gets the vrDisplay object (if any) */
  28155. vrDisplay: Nullable<any>;
  28156. /** Gets a boolean indicating if webVR is supported */
  28157. vrSupported: boolean;
  28158. }
  28159. /**
  28160. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28161. */
  28162. export class Engine {
  28163. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28164. static ExceptionList: ({
  28165. key: string;
  28166. capture: string;
  28167. captureConstraint: number;
  28168. targets: string[];
  28169. } | {
  28170. key: string;
  28171. capture: null;
  28172. captureConstraint: null;
  28173. targets: string[];
  28174. })[];
  28175. /** Gets the list of created engines */
  28176. static readonly Instances: Engine[];
  28177. /**
  28178. * Gets the latest created engine
  28179. */
  28180. static readonly LastCreatedEngine: Nullable<Engine>;
  28181. /**
  28182. * Gets the latest created scene
  28183. */
  28184. static readonly LastCreatedScene: Nullable<Scene>;
  28185. /**
  28186. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28187. * @param flag defines which part of the materials must be marked as dirty
  28188. * @param predicate defines a predicate used to filter which materials should be affected
  28189. */
  28190. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28191. /** @hidden */
  28192. static _TextureLoaders: IInternalTextureLoader[];
  28193. /** Defines that alpha blending is disabled */
  28194. static readonly ALPHA_DISABLE: number;
  28195. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28196. static readonly ALPHA_ADD: number;
  28197. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28198. static readonly ALPHA_COMBINE: number;
  28199. /** Defines that alpha blending to DEST - SRC * DEST */
  28200. static readonly ALPHA_SUBTRACT: number;
  28201. /** Defines that alpha blending to SRC * DEST */
  28202. static readonly ALPHA_MULTIPLY: number;
  28203. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28204. static readonly ALPHA_MAXIMIZED: number;
  28205. /** Defines that alpha blending to SRC + DEST */
  28206. static readonly ALPHA_ONEONE: number;
  28207. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28208. static readonly ALPHA_PREMULTIPLIED: number;
  28209. /**
  28210. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28211. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28212. */
  28213. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28214. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28215. static readonly ALPHA_INTERPOLATE: number;
  28216. /**
  28217. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28218. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28219. */
  28220. static readonly ALPHA_SCREENMODE: number;
  28221. /** Defines that the ressource is not delayed*/
  28222. static readonly DELAYLOADSTATE_NONE: number;
  28223. /** Defines that the ressource was successfully delay loaded */
  28224. static readonly DELAYLOADSTATE_LOADED: number;
  28225. /** Defines that the ressource is currently delay loading */
  28226. static readonly DELAYLOADSTATE_LOADING: number;
  28227. /** Defines that the ressource is delayed and has not started loading */
  28228. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28229. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28230. static readonly NEVER: number;
  28231. /** 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 */
  28232. static readonly ALWAYS: number;
  28233. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28234. static readonly LESS: number;
  28235. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28236. static readonly EQUAL: number;
  28237. /** 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 */
  28238. static readonly LEQUAL: number;
  28239. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28240. static readonly GREATER: number;
  28241. /** 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 */
  28242. static readonly GEQUAL: number;
  28243. /** 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 */
  28244. static readonly NOTEQUAL: number;
  28245. /** Passed to stencilOperation to specify that stencil value must be kept */
  28246. static readonly KEEP: number;
  28247. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28248. static readonly REPLACE: number;
  28249. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28250. static readonly INCR: number;
  28251. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28252. static readonly DECR: number;
  28253. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28254. static readonly INVERT: number;
  28255. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28256. static readonly INCR_WRAP: number;
  28257. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28258. static readonly DECR_WRAP: number;
  28259. /** Texture is not repeating outside of 0..1 UVs */
  28260. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28261. /** Texture is repeating outside of 0..1 UVs */
  28262. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28263. /** Texture is repeating and mirrored */
  28264. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28265. /** ALPHA */
  28266. static readonly TEXTUREFORMAT_ALPHA: number;
  28267. /** LUMINANCE */
  28268. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28269. /** LUMINANCE_ALPHA */
  28270. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28271. /** RGB */
  28272. static readonly TEXTUREFORMAT_RGB: number;
  28273. /** RGBA */
  28274. static readonly TEXTUREFORMAT_RGBA: number;
  28275. /** RED */
  28276. static readonly TEXTUREFORMAT_RED: number;
  28277. /** RED (2nd reference) */
  28278. static readonly TEXTUREFORMAT_R: number;
  28279. /** RG */
  28280. static readonly TEXTUREFORMAT_RG: number;
  28281. /** RED_INTEGER */
  28282. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28283. /** RED_INTEGER (2nd reference) */
  28284. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28285. /** RG_INTEGER */
  28286. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28287. /** RGB_INTEGER */
  28288. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28289. /** RGBA_INTEGER */
  28290. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28291. /** UNSIGNED_BYTE */
  28292. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28293. /** UNSIGNED_BYTE (2nd reference) */
  28294. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28295. /** FLOAT */
  28296. static readonly TEXTURETYPE_FLOAT: number;
  28297. /** HALF_FLOAT */
  28298. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28299. /** BYTE */
  28300. static readonly TEXTURETYPE_BYTE: number;
  28301. /** SHORT */
  28302. static readonly TEXTURETYPE_SHORT: number;
  28303. /** UNSIGNED_SHORT */
  28304. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28305. /** INT */
  28306. static readonly TEXTURETYPE_INT: number;
  28307. /** UNSIGNED_INT */
  28308. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28309. /** UNSIGNED_SHORT_4_4_4_4 */
  28310. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28311. /** UNSIGNED_SHORT_5_5_5_1 */
  28312. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28313. /** UNSIGNED_SHORT_5_6_5 */
  28314. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28315. /** UNSIGNED_INT_2_10_10_10_REV */
  28316. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28317. /** UNSIGNED_INT_24_8 */
  28318. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28319. /** UNSIGNED_INT_10F_11F_11F_REV */
  28320. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28321. /** UNSIGNED_INT_5_9_9_9_REV */
  28322. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28323. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28324. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28325. /** nearest is mag = nearest and min = nearest and mip = linear */
  28326. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28327. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28328. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28329. /** Trilinear is mag = linear and min = linear and mip = linear */
  28330. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28331. /** nearest is mag = nearest and min = nearest and mip = linear */
  28332. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28333. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28334. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28335. /** Trilinear is mag = linear and min = linear and mip = linear */
  28336. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28337. /** mag = nearest and min = nearest and mip = nearest */
  28338. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28339. /** mag = nearest and min = linear and mip = nearest */
  28340. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28341. /** mag = nearest and min = linear and mip = linear */
  28342. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28343. /** mag = nearest and min = linear and mip = none */
  28344. static readonly TEXTURE_NEAREST_LINEAR: number;
  28345. /** mag = nearest and min = nearest and mip = none */
  28346. static readonly TEXTURE_NEAREST_NEAREST: number;
  28347. /** mag = linear and min = nearest and mip = nearest */
  28348. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28349. /** mag = linear and min = nearest and mip = linear */
  28350. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28351. /** mag = linear and min = linear and mip = none */
  28352. static readonly TEXTURE_LINEAR_LINEAR: number;
  28353. /** mag = linear and min = nearest and mip = none */
  28354. static readonly TEXTURE_LINEAR_NEAREST: number;
  28355. /** Explicit coordinates mode */
  28356. static readonly TEXTURE_EXPLICIT_MODE: number;
  28357. /** Spherical coordinates mode */
  28358. static readonly TEXTURE_SPHERICAL_MODE: number;
  28359. /** Planar coordinates mode */
  28360. static readonly TEXTURE_PLANAR_MODE: number;
  28361. /** Cubic coordinates mode */
  28362. static readonly TEXTURE_CUBIC_MODE: number;
  28363. /** Projection coordinates mode */
  28364. static readonly TEXTURE_PROJECTION_MODE: number;
  28365. /** Skybox coordinates mode */
  28366. static readonly TEXTURE_SKYBOX_MODE: number;
  28367. /** Inverse Cubic coordinates mode */
  28368. static readonly TEXTURE_INVCUBIC_MODE: number;
  28369. /** Equirectangular coordinates mode */
  28370. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28371. /** Equirectangular Fixed coordinates mode */
  28372. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28373. /** Equirectangular Fixed Mirrored coordinates mode */
  28374. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28375. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28376. static readonly SCALEMODE_FLOOR: number;
  28377. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28378. static readonly SCALEMODE_NEAREST: number;
  28379. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28380. static readonly SCALEMODE_CEILING: number;
  28381. /**
  28382. * Returns the current npm package of the sdk
  28383. */
  28384. static readonly NpmPackage: string;
  28385. /**
  28386. * Returns the current version of the framework
  28387. */
  28388. static readonly Version: string;
  28389. /**
  28390. * Returns a string describing the current engine
  28391. */
  28392. readonly description: string;
  28393. /**
  28394. * Gets or sets the epsilon value used by collision engine
  28395. */
  28396. static CollisionsEpsilon: number;
  28397. /**
  28398. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28399. */
  28400. static ShadersRepository: string;
  28401. /**
  28402. * Method called to create the default loading screen.
  28403. * This can be overriden in your own app.
  28404. * @param canvas The rendering canvas element
  28405. * @returns The loading screen
  28406. */
  28407. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28408. /**
  28409. * Method called to create the default rescale post process on each engine.
  28410. */
  28411. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28412. /** @hidden */
  28413. _shaderProcessor: IShaderProcessor;
  28414. /**
  28415. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28416. */
  28417. forcePOTTextures: boolean;
  28418. /**
  28419. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28420. */
  28421. isFullscreen: boolean;
  28422. /**
  28423. * Gets a boolean indicating if the pointer is currently locked
  28424. */
  28425. isPointerLock: boolean;
  28426. /**
  28427. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28428. */
  28429. cullBackFaces: boolean;
  28430. /**
  28431. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28432. */
  28433. renderEvenInBackground: boolean;
  28434. /**
  28435. * Gets or sets a boolean indicating that cache can be kept between frames
  28436. */
  28437. preventCacheWipeBetweenFrames: boolean;
  28438. /**
  28439. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28440. **/
  28441. enableOfflineSupport: boolean;
  28442. /**
  28443. * 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)
  28444. **/
  28445. disableManifestCheck: boolean;
  28446. /**
  28447. * Gets the list of created scenes
  28448. */
  28449. scenes: Scene[];
  28450. /**
  28451. * Event raised when a new scene is created
  28452. */
  28453. onNewSceneAddedObservable: Observable<Scene>;
  28454. /**
  28455. * Gets the list of created postprocesses
  28456. */
  28457. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28458. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28459. validateShaderPrograms: boolean;
  28460. /**
  28461. * Observable event triggered each time the rendering canvas is resized
  28462. */
  28463. onResizeObservable: Observable<Engine>;
  28464. /**
  28465. * Observable event triggered each time the canvas loses focus
  28466. */
  28467. onCanvasBlurObservable: Observable<Engine>;
  28468. /**
  28469. * Observable event triggered each time the canvas gains focus
  28470. */
  28471. onCanvasFocusObservable: Observable<Engine>;
  28472. /**
  28473. * Observable event triggered each time the canvas receives pointerout event
  28474. */
  28475. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28476. /**
  28477. * Observable event triggered before each texture is initialized
  28478. */
  28479. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28480. /**
  28481. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28482. */
  28483. disableUniformBuffers: boolean;
  28484. /** @hidden */
  28485. _uniformBuffers: UniformBuffer[];
  28486. /**
  28487. * Gets a boolean indicating that the engine supports uniform buffers
  28488. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28489. */
  28490. readonly supportsUniformBuffers: boolean;
  28491. /**
  28492. * Observable raised when the engine begins a new frame
  28493. */
  28494. onBeginFrameObservable: Observable<Engine>;
  28495. /**
  28496. * If set, will be used to request the next animation frame for the render loop
  28497. */
  28498. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28499. /**
  28500. * Observable raised when the engine ends the current frame
  28501. */
  28502. onEndFrameObservable: Observable<Engine>;
  28503. /**
  28504. * Observable raised when the engine is about to compile a shader
  28505. */
  28506. onBeforeShaderCompilationObservable: Observable<Engine>;
  28507. /**
  28508. * Observable raised when the engine has jsut compiled a shader
  28509. */
  28510. onAfterShaderCompilationObservable: Observable<Engine>;
  28511. /** @hidden */
  28512. _gl: WebGLRenderingContext;
  28513. private _renderingCanvas;
  28514. private _windowIsBackground;
  28515. private _webGLVersion;
  28516. protected _highPrecisionShadersAllowed: boolean;
  28517. /** @hidden */
  28518. readonly _shouldUseHighPrecisionShader: boolean;
  28519. /**
  28520. * Gets a boolean indicating that only power of 2 textures are supported
  28521. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28522. */
  28523. readonly needPOTTextures: boolean;
  28524. /** @hidden */
  28525. _badOS: boolean;
  28526. /** @hidden */
  28527. _badDesktopOS: boolean;
  28528. /**
  28529. * Gets the audio engine
  28530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28531. * @ignorenaming
  28532. */
  28533. static audioEngine: IAudioEngine;
  28534. /**
  28535. * Default AudioEngine factory responsible of creating the Audio Engine.
  28536. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28537. */
  28538. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28539. /**
  28540. * Default offline support factory responsible of creating a tool used to store data locally.
  28541. * By default, this will create a Database object if the workload has been embedded.
  28542. */
  28543. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28544. private _onFocus;
  28545. private _onBlur;
  28546. private _onCanvasPointerOut;
  28547. private _onCanvasBlur;
  28548. private _onCanvasFocus;
  28549. private _onFullscreenChange;
  28550. private _onPointerLockChange;
  28551. private _hardwareScalingLevel;
  28552. /** @hidden */
  28553. _caps: EngineCapabilities;
  28554. private _pointerLockRequested;
  28555. private _isStencilEnable;
  28556. private _colorWrite;
  28557. private _loadingScreen;
  28558. /** @hidden */
  28559. _drawCalls: PerfCounter;
  28560. private _glVersion;
  28561. private _glRenderer;
  28562. private _glVendor;
  28563. private _videoTextureSupported;
  28564. private _renderingQueueLaunched;
  28565. private _activeRenderLoops;
  28566. private _deterministicLockstep;
  28567. private _lockstepMaxSteps;
  28568. /**
  28569. * Observable signaled when a context lost event is raised
  28570. */
  28571. onContextLostObservable: Observable<Engine>;
  28572. /**
  28573. * Observable signaled when a context restored event is raised
  28574. */
  28575. onContextRestoredObservable: Observable<Engine>;
  28576. private _onContextLost;
  28577. private _onContextRestored;
  28578. private _contextWasLost;
  28579. /** @hidden */
  28580. _doNotHandleContextLost: boolean;
  28581. /**
  28582. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28584. */
  28585. doNotHandleContextLost: boolean;
  28586. private _performanceMonitor;
  28587. private _fps;
  28588. private _deltaTime;
  28589. /**
  28590. * Turn this value on if you want to pause FPS computation when in background
  28591. */
  28592. disablePerformanceMonitorInBackground: boolean;
  28593. /**
  28594. * Gets the performance monitor attached to this engine
  28595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28596. */
  28597. readonly performanceMonitor: PerformanceMonitor;
  28598. /**
  28599. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28600. */
  28601. disableVertexArrayObjects: boolean;
  28602. /** @hidden */
  28603. protected _depthCullingState: _DepthCullingState;
  28604. /** @hidden */
  28605. protected _stencilState: _StencilState;
  28606. /** @hidden */
  28607. protected _alphaState: _AlphaState;
  28608. /** @hidden */
  28609. protected _alphaMode: number;
  28610. /** @hidden */
  28611. _internalTexturesCache: InternalTexture[];
  28612. /** @hidden */
  28613. protected _activeChannel: number;
  28614. private _currentTextureChannel;
  28615. /** @hidden */
  28616. protected _boundTexturesCache: {
  28617. [key: string]: Nullable<InternalTexture>;
  28618. };
  28619. /** @hidden */
  28620. protected _currentEffect: Nullable<Effect>;
  28621. /** @hidden */
  28622. protected _currentProgram: Nullable<WebGLProgram>;
  28623. private _compiledEffects;
  28624. private _vertexAttribArraysEnabled;
  28625. /** @hidden */
  28626. protected _cachedViewport: Nullable<Viewport>;
  28627. private _cachedVertexArrayObject;
  28628. /** @hidden */
  28629. protected _cachedVertexBuffers: any;
  28630. /** @hidden */
  28631. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28632. /** @hidden */
  28633. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28634. /** @hidden */
  28635. _currentRenderTarget: Nullable<InternalTexture>;
  28636. private _uintIndicesCurrentlySet;
  28637. private _currentBoundBuffer;
  28638. /** @hidden */
  28639. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28640. private _currentBufferPointers;
  28641. private _currentInstanceLocations;
  28642. private _currentInstanceBuffers;
  28643. private _textureUnits;
  28644. /** @hidden */
  28645. _workingCanvas: Nullable<HTMLCanvasElement>;
  28646. /** @hidden */
  28647. _workingContext: Nullable<CanvasRenderingContext2D>;
  28648. private _rescalePostProcess;
  28649. private _dummyFramebuffer;
  28650. private _externalData;
  28651. /** @hidden */
  28652. _bindedRenderFunction: any;
  28653. private _vaoRecordInProgress;
  28654. private _mustWipeVertexAttributes;
  28655. private _emptyTexture;
  28656. private _emptyCubeTexture;
  28657. private _emptyTexture3D;
  28658. /** @hidden */
  28659. _frameHandler: number;
  28660. private _nextFreeTextureSlots;
  28661. private _maxSimultaneousTextures;
  28662. private _activeRequests;
  28663. private _texturesSupported;
  28664. /** @hidden */
  28665. _textureFormatInUse: Nullable<string>;
  28666. /**
  28667. * Gets the list of texture formats supported
  28668. */
  28669. readonly texturesSupported: Array<string>;
  28670. /**
  28671. * Gets the list of texture formats in use
  28672. */
  28673. readonly textureFormatInUse: Nullable<string>;
  28674. /**
  28675. * Gets the current viewport
  28676. */
  28677. readonly currentViewport: Nullable<Viewport>;
  28678. /**
  28679. * Gets the default empty texture
  28680. */
  28681. readonly emptyTexture: InternalTexture;
  28682. /**
  28683. * Gets the default empty 3D texture
  28684. */
  28685. readonly emptyTexture3D: InternalTexture;
  28686. /**
  28687. * Gets the default empty cube texture
  28688. */
  28689. readonly emptyCubeTexture: InternalTexture;
  28690. /**
  28691. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28692. */
  28693. readonly premultipliedAlpha: boolean;
  28694. /**
  28695. * Creates a new engine
  28696. * @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
  28697. * @param antialias defines enable antialiasing (default: false)
  28698. * @param options defines further options to be sent to the getContext() function
  28699. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28700. */
  28701. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28702. /**
  28703. * Initializes a webVR display and starts listening to display change events
  28704. * The onVRDisplayChangedObservable will be notified upon these changes
  28705. * @returns The onVRDisplayChangedObservable
  28706. */
  28707. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28708. /** @hidden */
  28709. _prepareVRComponent(): void;
  28710. /** @hidden */
  28711. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28712. /** @hidden */
  28713. _submitVRFrame(): void;
  28714. /**
  28715. * Call this function to leave webVR mode
  28716. * Will do nothing if webVR is not supported or if there is no webVR device
  28717. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28718. */
  28719. disableVR(): void;
  28720. /**
  28721. * Gets a boolean indicating that the system is in VR mode and is presenting
  28722. * @returns true if VR mode is engaged
  28723. */
  28724. isVRPresenting(): boolean;
  28725. /** @hidden */
  28726. _requestVRFrame(): void;
  28727. private _disableTouchAction;
  28728. private _rebuildInternalTextures;
  28729. private _rebuildEffects;
  28730. /**
  28731. * Gets a boolean indicating if all created effects are ready
  28732. * @returns true if all effects are ready
  28733. */
  28734. areAllEffectsReady(): boolean;
  28735. private _rebuildBuffers;
  28736. private _initGLContext;
  28737. /**
  28738. * Gets version of the current webGL context
  28739. */
  28740. readonly webGLVersion: number;
  28741. /**
  28742. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28743. */
  28744. readonly isStencilEnable: boolean;
  28745. /** @hidden */
  28746. _prepareWorkingCanvas(): void;
  28747. /**
  28748. * Reset the texture cache to empty state
  28749. */
  28750. resetTextureCache(): void;
  28751. /**
  28752. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28754. * @returns true if engine is in deterministic lock step mode
  28755. */
  28756. isDeterministicLockStep(): boolean;
  28757. /**
  28758. * Gets the max steps when engine is running in deterministic lock step
  28759. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28760. * @returns the max steps
  28761. */
  28762. getLockstepMaxSteps(): number;
  28763. /**
  28764. * Gets an object containing information about the current webGL context
  28765. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28766. */
  28767. getGlInfo(): {
  28768. vendor: string;
  28769. renderer: string;
  28770. version: string;
  28771. };
  28772. /**
  28773. * Gets current aspect ratio
  28774. * @param camera defines the camera to use to get the aspect ratio
  28775. * @param useScreen defines if screen size must be used (or the current render target if any)
  28776. * @returns a number defining the aspect ratio
  28777. */
  28778. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28779. /**
  28780. * Gets current screen aspect ratio
  28781. * @returns a number defining the aspect ratio
  28782. */
  28783. getScreenAspectRatio(): number;
  28784. /**
  28785. * Gets the current render width
  28786. * @param useScreen defines if screen size must be used (or the current render target if any)
  28787. * @returns a number defining the current render width
  28788. */
  28789. getRenderWidth(useScreen?: boolean): number;
  28790. /**
  28791. * Gets the current render height
  28792. * @param useScreen defines if screen size must be used (or the current render target if any)
  28793. * @returns a number defining the current render height
  28794. */
  28795. getRenderHeight(useScreen?: boolean): number;
  28796. /**
  28797. * Gets the HTML canvas attached with the current webGL context
  28798. * @returns a HTML canvas
  28799. */
  28800. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28801. /**
  28802. * Gets the client rect of the HTML canvas attached with the current webGL context
  28803. * @returns a client rectanglee
  28804. */
  28805. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28806. /**
  28807. * Defines the hardware scaling level.
  28808. * By default the hardware scaling level is computed from the window device ratio.
  28809. * 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.
  28810. * @param level defines the level to use
  28811. */
  28812. setHardwareScalingLevel(level: number): void;
  28813. /**
  28814. * Gets the current hardware scaling level.
  28815. * By default the hardware scaling level is computed from the window device ratio.
  28816. * 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.
  28817. * @returns a number indicating the current hardware scaling level
  28818. */
  28819. getHardwareScalingLevel(): number;
  28820. /**
  28821. * Gets the list of loaded textures
  28822. * @returns an array containing all loaded textures
  28823. */
  28824. getLoadedTexturesCache(): InternalTexture[];
  28825. /**
  28826. * Gets the object containing all engine capabilities
  28827. * @returns the EngineCapabilities object
  28828. */
  28829. getCaps(): EngineCapabilities;
  28830. /**
  28831. * Gets the current depth function
  28832. * @returns a number defining the depth function
  28833. */
  28834. getDepthFunction(): Nullable<number>;
  28835. /**
  28836. * Sets the current depth function
  28837. * @param depthFunc defines the function to use
  28838. */
  28839. setDepthFunction(depthFunc: number): void;
  28840. /**
  28841. * Sets the current depth function to GREATER
  28842. */
  28843. setDepthFunctionToGreater(): void;
  28844. /**
  28845. * Sets the current depth function to GEQUAL
  28846. */
  28847. setDepthFunctionToGreaterOrEqual(): void;
  28848. /**
  28849. * Sets the current depth function to LESS
  28850. */
  28851. setDepthFunctionToLess(): void;
  28852. private _cachedStencilBuffer;
  28853. private _cachedStencilFunction;
  28854. private _cachedStencilMask;
  28855. private _cachedStencilOperationPass;
  28856. private _cachedStencilOperationFail;
  28857. private _cachedStencilOperationDepthFail;
  28858. private _cachedStencilReference;
  28859. /**
  28860. * Caches the the state of the stencil buffer
  28861. */
  28862. cacheStencilState(): void;
  28863. /**
  28864. * Restores the state of the stencil buffer
  28865. */
  28866. restoreStencilState(): void;
  28867. /**
  28868. * Sets the current depth function to LEQUAL
  28869. */
  28870. setDepthFunctionToLessOrEqual(): void;
  28871. /**
  28872. * Gets a boolean indicating if stencil buffer is enabled
  28873. * @returns the current stencil buffer state
  28874. */
  28875. getStencilBuffer(): boolean;
  28876. /**
  28877. * Enable or disable the stencil buffer
  28878. * @param enable defines if the stencil buffer must be enabled or disabled
  28879. */
  28880. setStencilBuffer(enable: boolean): void;
  28881. /**
  28882. * Gets the current stencil mask
  28883. * @returns a number defining the new stencil mask to use
  28884. */
  28885. getStencilMask(): number;
  28886. /**
  28887. * Sets the current stencil mask
  28888. * @param mask defines the new stencil mask to use
  28889. */
  28890. setStencilMask(mask: number): void;
  28891. /**
  28892. * Gets the current stencil function
  28893. * @returns a number defining the stencil function to use
  28894. */
  28895. getStencilFunction(): number;
  28896. /**
  28897. * Gets the current stencil reference value
  28898. * @returns a number defining the stencil reference value to use
  28899. */
  28900. getStencilFunctionReference(): number;
  28901. /**
  28902. * Gets the current stencil mask
  28903. * @returns a number defining the stencil mask to use
  28904. */
  28905. getStencilFunctionMask(): number;
  28906. /**
  28907. * Sets the current stencil function
  28908. * @param stencilFunc defines the new stencil function to use
  28909. */
  28910. setStencilFunction(stencilFunc: number): void;
  28911. /**
  28912. * Sets the current stencil reference
  28913. * @param reference defines the new stencil reference to use
  28914. */
  28915. setStencilFunctionReference(reference: number): void;
  28916. /**
  28917. * Sets the current stencil mask
  28918. * @param mask defines the new stencil mask to use
  28919. */
  28920. setStencilFunctionMask(mask: number): void;
  28921. /**
  28922. * Gets the current stencil operation when stencil fails
  28923. * @returns a number defining stencil operation to use when stencil fails
  28924. */
  28925. getStencilOperationFail(): number;
  28926. /**
  28927. * Gets the current stencil operation when depth fails
  28928. * @returns a number defining stencil operation to use when depth fails
  28929. */
  28930. getStencilOperationDepthFail(): number;
  28931. /**
  28932. * Gets the current stencil operation when stencil passes
  28933. * @returns a number defining stencil operation to use when stencil passes
  28934. */
  28935. getStencilOperationPass(): number;
  28936. /**
  28937. * Sets the stencil operation to use when stencil fails
  28938. * @param operation defines the stencil operation to use when stencil fails
  28939. */
  28940. setStencilOperationFail(operation: number): void;
  28941. /**
  28942. * Sets the stencil operation to use when depth fails
  28943. * @param operation defines the stencil operation to use when depth fails
  28944. */
  28945. setStencilOperationDepthFail(operation: number): void;
  28946. /**
  28947. * Sets the stencil operation to use when stencil passes
  28948. * @param operation defines the stencil operation to use when stencil passes
  28949. */
  28950. setStencilOperationPass(operation: number): void;
  28951. /**
  28952. * Sets a boolean indicating if the dithering state is enabled or disabled
  28953. * @param value defines the dithering state
  28954. */
  28955. setDitheringState(value: boolean): void;
  28956. /**
  28957. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28958. * @param value defines the rasterizer state
  28959. */
  28960. setRasterizerState(value: boolean): void;
  28961. /**
  28962. * stop executing a render loop function and remove it from the execution array
  28963. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28964. */
  28965. stopRenderLoop(renderFunction?: () => void): void;
  28966. /** @hidden */
  28967. _renderLoop(): void;
  28968. /**
  28969. * Register and execute a render loop. The engine can have more than one render function
  28970. * @param renderFunction defines the function to continuously execute
  28971. */
  28972. runRenderLoop(renderFunction: () => void): void;
  28973. /**
  28974. * Toggle full screen mode
  28975. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28976. */
  28977. switchFullscreen(requestPointerLock: boolean): void;
  28978. /**
  28979. * Enters full screen mode
  28980. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28981. */
  28982. enterFullscreen(requestPointerLock: boolean): void;
  28983. /**
  28984. * Exits full screen mode
  28985. */
  28986. exitFullscreen(): void;
  28987. /**
  28988. * Enters Pointerlock mode
  28989. */
  28990. enterPointerlock(): void;
  28991. /**
  28992. * Exits Pointerlock mode
  28993. */
  28994. exitPointerlock(): void;
  28995. /**
  28996. * Clear the current render buffer or the current render target (if any is set up)
  28997. * @param color defines the color to use
  28998. * @param backBuffer defines if the back buffer must be cleared
  28999. * @param depth defines if the depth buffer must be cleared
  29000. * @param stencil defines if the stencil buffer must be cleared
  29001. */
  29002. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29003. /**
  29004. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29005. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29006. * @param y defines the y-coordinate of the corner of the clear rectangle
  29007. * @param width defines the width of the clear rectangle
  29008. * @param height defines the height of the clear rectangle
  29009. * @param clearColor defines the clear color
  29010. */
  29011. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29012. /**
  29013. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29014. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29015. * @param y defines the y-coordinate of the corner of the clear rectangle
  29016. * @param width defines the width of the clear rectangle
  29017. * @param height defines the height of the clear rectangle
  29018. */
  29019. enableScissor(x: number, y: number, width: number, height: number): void;
  29020. /**
  29021. * Disable previously set scissor test rectangle
  29022. */
  29023. disableScissor(): void;
  29024. private _viewportCached;
  29025. /** @hidden */
  29026. _viewport(x: number, y: number, width: number, height: number): void;
  29027. /**
  29028. * Set the WebGL's viewport
  29029. * @param viewport defines the viewport element to be used
  29030. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29031. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29032. */
  29033. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29034. /**
  29035. * Directly set the WebGL Viewport
  29036. * @param x defines the x coordinate of the viewport (in screen space)
  29037. * @param y defines the y coordinate of the viewport (in screen space)
  29038. * @param width defines the width of the viewport (in screen space)
  29039. * @param height defines the height of the viewport (in screen space)
  29040. * @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
  29041. */
  29042. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29043. /**
  29044. * Begin a new frame
  29045. */
  29046. beginFrame(): void;
  29047. /**
  29048. * Enf the current frame
  29049. */
  29050. endFrame(): void;
  29051. /**
  29052. * Resize the view according to the canvas' size
  29053. */
  29054. resize(): void;
  29055. /**
  29056. * Force a specific size of the canvas
  29057. * @param width defines the new canvas' width
  29058. * @param height defines the new canvas' height
  29059. */
  29060. setSize(width: number, height: number): void;
  29061. /**
  29062. * Binds the frame buffer to the specified texture.
  29063. * @param texture The texture to render to or null for the default canvas
  29064. * @param faceIndex The face of the texture to render to in case of cube texture
  29065. * @param requiredWidth The width of the target to render to
  29066. * @param requiredHeight The height of the target to render to
  29067. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29068. * @param depthStencilTexture The depth stencil texture to use to render
  29069. * @param lodLevel defines le lod level to bind to the frame buffer
  29070. */
  29071. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29072. /** @hidden */
  29073. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29074. /**
  29075. * Unbind the current render target texture from the webGL context
  29076. * @param texture defines the render target texture to unbind
  29077. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29078. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29079. */
  29080. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29081. /**
  29082. * Force the mipmap generation for the given render target texture
  29083. * @param texture defines the render target texture to use
  29084. */
  29085. generateMipMapsForCubemap(texture: InternalTexture): void;
  29086. /**
  29087. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29088. */
  29089. flushFramebuffer(): void;
  29090. /**
  29091. * Unbind the current render target and bind the default framebuffer
  29092. */
  29093. restoreDefaultFramebuffer(): void;
  29094. /**
  29095. * Create an uniform buffer
  29096. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29097. * @param elements defines the content of the uniform buffer
  29098. * @returns the webGL uniform buffer
  29099. */
  29100. createUniformBuffer(elements: FloatArray): DataBuffer;
  29101. /**
  29102. * Create a dynamic uniform buffer
  29103. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29104. * @param elements defines the content of the uniform buffer
  29105. * @returns the webGL uniform buffer
  29106. */
  29107. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29108. /**
  29109. * Update an existing uniform buffer
  29110. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29111. * @param uniformBuffer defines the target uniform buffer
  29112. * @param elements defines the content to update
  29113. * @param offset defines the offset in the uniform buffer where update should start
  29114. * @param count defines the size of the data to update
  29115. */
  29116. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29117. private _resetVertexBufferBinding;
  29118. /**
  29119. * Creates a vertex buffer
  29120. * @param data the data for the vertex buffer
  29121. * @returns the new WebGL static buffer
  29122. */
  29123. createVertexBuffer(data: DataArray): DataBuffer;
  29124. /**
  29125. * Creates a dynamic vertex buffer
  29126. * @param data the data for the dynamic vertex buffer
  29127. * @returns the new WebGL dynamic buffer
  29128. */
  29129. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29130. /**
  29131. * Update a dynamic index buffer
  29132. * @param indexBuffer defines the target index buffer
  29133. * @param indices defines the data to update
  29134. * @param offset defines the offset in the target index buffer where update should start
  29135. */
  29136. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29137. /**
  29138. * Updates a dynamic vertex buffer.
  29139. * @param vertexBuffer the vertex buffer to update
  29140. * @param data the data used to update the vertex buffer
  29141. * @param byteOffset the byte offset of the data
  29142. * @param byteLength the byte length of the data
  29143. */
  29144. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29145. private _resetIndexBufferBinding;
  29146. /**
  29147. * Creates a new index buffer
  29148. * @param indices defines the content of the index buffer
  29149. * @param updatable defines if the index buffer must be updatable
  29150. * @returns a new webGL buffer
  29151. */
  29152. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29153. /**
  29154. * Bind a webGL buffer to the webGL context
  29155. * @param buffer defines the buffer to bind
  29156. */
  29157. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29158. /**
  29159. * Bind an uniform buffer to the current webGL context
  29160. * @param buffer defines the buffer to bind
  29161. */
  29162. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29163. /**
  29164. * Bind a buffer to the current webGL context at a given location
  29165. * @param buffer defines the buffer to bind
  29166. * @param location defines the index where to bind the buffer
  29167. */
  29168. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29169. /**
  29170. * Bind a specific block at a given index in a specific shader program
  29171. * @param pipelineContext defines the pipeline context to use
  29172. * @param blockName defines the block name
  29173. * @param index defines the index where to bind the block
  29174. */
  29175. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29176. private bindIndexBuffer;
  29177. private bindBuffer;
  29178. /**
  29179. * update the bound buffer with the given data
  29180. * @param data defines the data to update
  29181. */
  29182. updateArrayBuffer(data: Float32Array): void;
  29183. private _vertexAttribPointer;
  29184. private _bindIndexBufferWithCache;
  29185. private _bindVertexBuffersAttributes;
  29186. /**
  29187. * Records a vertex array object
  29188. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29189. * @param vertexBuffers defines the list of vertex buffers to store
  29190. * @param indexBuffer defines the index buffer to store
  29191. * @param effect defines the effect to store
  29192. * @returns the new vertex array object
  29193. */
  29194. recordVertexArrayObject(vertexBuffers: {
  29195. [key: string]: VertexBuffer;
  29196. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29197. /**
  29198. * Bind a specific vertex array object
  29199. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29200. * @param vertexArrayObject defines the vertex array object to bind
  29201. * @param indexBuffer defines the index buffer to bind
  29202. */
  29203. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29204. /**
  29205. * Bind webGl buffers directly to the webGL context
  29206. * @param vertexBuffer defines the vertex buffer to bind
  29207. * @param indexBuffer defines the index buffer to bind
  29208. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29209. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29210. * @param effect defines the effect associated with the vertex buffer
  29211. */
  29212. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29213. private _unbindVertexArrayObject;
  29214. /**
  29215. * Bind a list of vertex buffers to the webGL context
  29216. * @param vertexBuffers defines the list of vertex buffers to bind
  29217. * @param indexBuffer defines the index buffer to bind
  29218. * @param effect defines the effect associated with the vertex buffers
  29219. */
  29220. bindBuffers(vertexBuffers: {
  29221. [key: string]: Nullable<VertexBuffer>;
  29222. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29223. /**
  29224. * Unbind all instance attributes
  29225. */
  29226. unbindInstanceAttributes(): void;
  29227. /**
  29228. * Release and free the memory of a vertex array object
  29229. * @param vao defines the vertex array object to delete
  29230. */
  29231. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29232. /** @hidden */
  29233. _releaseBuffer(buffer: DataBuffer): boolean;
  29234. /**
  29235. * Creates a webGL buffer to use with instanciation
  29236. * @param capacity defines the size of the buffer
  29237. * @returns the webGL buffer
  29238. */
  29239. createInstancesBuffer(capacity: number): DataBuffer;
  29240. /**
  29241. * Delete a webGL buffer used with instanciation
  29242. * @param buffer defines the webGL buffer to delete
  29243. */
  29244. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29245. /**
  29246. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29247. * @param instancesBuffer defines the webGL buffer to update and bind
  29248. * @param data defines the data to store in the buffer
  29249. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29250. */
  29251. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29252. /**
  29253. * Apply all cached states (depth, culling, stencil and alpha)
  29254. */
  29255. applyStates(): void;
  29256. /**
  29257. * Send a draw order
  29258. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29259. * @param indexStart defines the starting index
  29260. * @param indexCount defines the number of index to draw
  29261. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29262. */
  29263. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29264. /**
  29265. * Draw a list of points
  29266. * @param verticesStart defines the index of first vertex to draw
  29267. * @param verticesCount defines the count of vertices to draw
  29268. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29269. */
  29270. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29271. /**
  29272. * Draw a list of unindexed primitives
  29273. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29274. * @param verticesStart defines the index of first vertex to draw
  29275. * @param verticesCount defines the count of vertices to draw
  29276. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29277. */
  29278. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29279. /**
  29280. * Draw a list of indexed primitives
  29281. * @param fillMode defines the primitive to use
  29282. * @param indexStart defines the starting index
  29283. * @param indexCount defines the number of index to draw
  29284. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29285. */
  29286. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29287. /**
  29288. * Draw a list of unindexed primitives
  29289. * @param fillMode defines the primitive to use
  29290. * @param verticesStart defines the index of first vertex to draw
  29291. * @param verticesCount defines the count of vertices to draw
  29292. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29293. */
  29294. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29295. private _drawMode;
  29296. /** @hidden */
  29297. _releaseEffect(effect: Effect): void;
  29298. /** @hidden */
  29299. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29300. /**
  29301. * Create a new effect (used to store vertex/fragment shaders)
  29302. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29303. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29304. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29305. * @param samplers defines an array of string used to represent textures
  29306. * @param defines defines the string containing the defines to use to compile the shaders
  29307. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29308. * @param onCompiled defines a function to call when the effect creation is successful
  29309. * @param onError defines a function to call when the effect creation has failed
  29310. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29311. * @returns the new Effect
  29312. */
  29313. 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;
  29314. private _compileShader;
  29315. private _compileRawShader;
  29316. /**
  29317. * Directly creates a webGL program
  29318. * @param pipelineContext defines the pipeline context to attach to
  29319. * @param vertexCode defines the vertex shader code to use
  29320. * @param fragmentCode defines the fragment shader code to use
  29321. * @param context defines the webGL context to use (if not set, the current one will be used)
  29322. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29323. * @returns the new webGL program
  29324. */
  29325. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29326. /**
  29327. * Creates a webGL program
  29328. * @param pipelineContext defines the pipeline context to attach to
  29329. * @param vertexCode defines the vertex shader code to use
  29330. * @param fragmentCode defines the fragment shader code to use
  29331. * @param defines defines the string containing the defines to use to compile the shaders
  29332. * @param context defines the webGL context to use (if not set, the current one will be used)
  29333. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29334. * @returns the new webGL program
  29335. */
  29336. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29337. /**
  29338. * Creates a new pipeline context
  29339. * @returns the new pipeline
  29340. */
  29341. createPipelineContext(): WebGLPipelineContext;
  29342. private _createShaderProgram;
  29343. private _finalizePipelineContext;
  29344. /** @hidden */
  29345. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29346. /** @hidden */
  29347. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29348. /** @hidden */
  29349. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29350. /**
  29351. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29352. * @param pipelineContext defines the pipeline context to use
  29353. * @param uniformsNames defines the list of uniform names
  29354. * @returns an array of webGL uniform locations
  29355. */
  29356. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29357. /**
  29358. * Gets the lsit of active attributes for a given webGL program
  29359. * @param pipelineContext defines the pipeline context to use
  29360. * @param attributesNames defines the list of attribute names to get
  29361. * @returns an array of indices indicating the offset of each attribute
  29362. */
  29363. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29364. /**
  29365. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29366. * @param effect defines the effect to activate
  29367. */
  29368. enableEffect(effect: Nullable<Effect>): void;
  29369. /**
  29370. * Set the value of an uniform to an array of int32
  29371. * @param uniform defines the webGL uniform location where to store the value
  29372. * @param array defines the array of int32 to store
  29373. */
  29374. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29375. /**
  29376. * Set the value of an uniform to an array of int32 (stored as vec2)
  29377. * @param uniform defines the webGL uniform location where to store the value
  29378. * @param array defines the array of int32 to store
  29379. */
  29380. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29381. /**
  29382. * Set the value of an uniform to an array of int32 (stored as vec3)
  29383. * @param uniform defines the webGL uniform location where to store the value
  29384. * @param array defines the array of int32 to store
  29385. */
  29386. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29387. /**
  29388. * Set the value of an uniform to an array of int32 (stored as vec4)
  29389. * @param uniform defines the webGL uniform location where to store the value
  29390. * @param array defines the array of int32 to store
  29391. */
  29392. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29393. /**
  29394. * Set the value of an uniform to an array of float32
  29395. * @param uniform defines the webGL uniform location where to store the value
  29396. * @param array defines the array of float32 to store
  29397. */
  29398. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29399. /**
  29400. * Set the value of an uniform to an array of float32 (stored as vec2)
  29401. * @param uniform defines the webGL uniform location where to store the value
  29402. * @param array defines the array of float32 to store
  29403. */
  29404. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29405. /**
  29406. * Set the value of an uniform to an array of float32 (stored as vec3)
  29407. * @param uniform defines the webGL uniform location where to store the value
  29408. * @param array defines the array of float32 to store
  29409. */
  29410. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29411. /**
  29412. * Set the value of an uniform to an array of float32 (stored as vec4)
  29413. * @param uniform defines the webGL uniform location where to store the value
  29414. * @param array defines the array of float32 to store
  29415. */
  29416. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29417. /**
  29418. * Set the value of an uniform to an array of number
  29419. * @param uniform defines the webGL uniform location where to store the value
  29420. * @param array defines the array of number to store
  29421. */
  29422. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29423. /**
  29424. * Set the value of an uniform to an array of number (stored as vec2)
  29425. * @param uniform defines the webGL uniform location where to store the value
  29426. * @param array defines the array of number to store
  29427. */
  29428. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29429. /**
  29430. * Set the value of an uniform to an array of number (stored as vec3)
  29431. * @param uniform defines the webGL uniform location where to store the value
  29432. * @param array defines the array of number to store
  29433. */
  29434. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29435. /**
  29436. * Set the value of an uniform to an array of number (stored as vec4)
  29437. * @param uniform defines the webGL uniform location where to store the value
  29438. * @param array defines the array of number to store
  29439. */
  29440. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29441. /**
  29442. * Set the value of an uniform to an array of float32 (stored as matrices)
  29443. * @param uniform defines the webGL uniform location where to store the value
  29444. * @param matrices defines the array of float32 to store
  29445. */
  29446. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29447. /**
  29448. * Set the value of an uniform to a matrix
  29449. * @param uniform defines the webGL uniform location where to store the value
  29450. * @param matrix defines the matrix to store
  29451. */
  29452. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29453. /**
  29454. * Set the value of an uniform to a matrix (3x3)
  29455. * @param uniform defines the webGL uniform location where to store the value
  29456. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29457. */
  29458. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29459. /**
  29460. * Set the value of an uniform to a matrix (2x2)
  29461. * @param uniform defines the webGL uniform location where to store the value
  29462. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29463. */
  29464. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29465. /**
  29466. * Set the value of an uniform to a number (int)
  29467. * @param uniform defines the webGL uniform location where to store the value
  29468. * @param value defines the int number to store
  29469. */
  29470. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29471. /**
  29472. * Set the value of an uniform to a number (float)
  29473. * @param uniform defines the webGL uniform location where to store the value
  29474. * @param value defines the float number to store
  29475. */
  29476. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29477. /**
  29478. * Set the value of an uniform to a vec2
  29479. * @param uniform defines the webGL uniform location where to store the value
  29480. * @param x defines the 1st component of the value
  29481. * @param y defines the 2nd component of the value
  29482. */
  29483. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29484. /**
  29485. * Set the value of an uniform to a vec3
  29486. * @param uniform defines the webGL uniform location where to store the value
  29487. * @param x defines the 1st component of the value
  29488. * @param y defines the 2nd component of the value
  29489. * @param z defines the 3rd component of the value
  29490. */
  29491. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29492. /**
  29493. * Set the value of an uniform to a boolean
  29494. * @param uniform defines the webGL uniform location where to store the value
  29495. * @param bool defines the boolean to store
  29496. */
  29497. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29498. /**
  29499. * Set the value of an uniform to a vec4
  29500. * @param uniform defines the webGL uniform location where to store the value
  29501. * @param x defines the 1st component of the value
  29502. * @param y defines the 2nd component of the value
  29503. * @param z defines the 3rd component of the value
  29504. * @param w defines the 4th component of the value
  29505. */
  29506. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29507. /**
  29508. * Set the value of an uniform to a Color3
  29509. * @param uniform defines the webGL uniform location where to store the value
  29510. * @param color3 defines the color to store
  29511. */
  29512. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29513. /**
  29514. * Set the value of an uniform to a Color3 and an alpha value
  29515. * @param uniform defines the webGL uniform location where to store the value
  29516. * @param color3 defines the color to store
  29517. * @param alpha defines the alpha component to store
  29518. */
  29519. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29520. /**
  29521. * Sets a Color4 on a uniform variable
  29522. * @param uniform defines the uniform location
  29523. * @param color4 defines the value to be set
  29524. */
  29525. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29526. /**
  29527. * Set various states to the webGL context
  29528. * @param culling defines backface culling state
  29529. * @param zOffset defines the value to apply to zOffset (0 by default)
  29530. * @param force defines if states must be applied even if cache is up to date
  29531. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29532. */
  29533. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29534. /**
  29535. * Set the z offset to apply to current rendering
  29536. * @param value defines the offset to apply
  29537. */
  29538. setZOffset(value: number): void;
  29539. /**
  29540. * Gets the current value of the zOffset
  29541. * @returns the current zOffset state
  29542. */
  29543. getZOffset(): number;
  29544. /**
  29545. * Enable or disable depth buffering
  29546. * @param enable defines the state to set
  29547. */
  29548. setDepthBuffer(enable: boolean): void;
  29549. /**
  29550. * Gets a boolean indicating if depth writing is enabled
  29551. * @returns the current depth writing state
  29552. */
  29553. getDepthWrite(): boolean;
  29554. /**
  29555. * Enable or disable depth writing
  29556. * @param enable defines the state to set
  29557. */
  29558. setDepthWrite(enable: boolean): void;
  29559. /**
  29560. * Enable or disable color writing
  29561. * @param enable defines the state to set
  29562. */
  29563. setColorWrite(enable: boolean): void;
  29564. /**
  29565. * Gets a boolean indicating if color writing is enabled
  29566. * @returns the current color writing state
  29567. */
  29568. getColorWrite(): boolean;
  29569. /**
  29570. * Sets alpha constants used by some alpha blending modes
  29571. * @param r defines the red component
  29572. * @param g defines the green component
  29573. * @param b defines the blue component
  29574. * @param a defines the alpha component
  29575. */
  29576. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29577. /**
  29578. * Sets the current alpha mode
  29579. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29580. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29581. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29582. */
  29583. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29584. /**
  29585. * Gets the current alpha mode
  29586. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29587. * @returns the current alpha mode
  29588. */
  29589. getAlphaMode(): number;
  29590. /**
  29591. * Clears the list of texture accessible through engine.
  29592. * This can help preventing texture load conflict due to name collision.
  29593. */
  29594. clearInternalTexturesCache(): void;
  29595. /**
  29596. * Force the entire cache to be cleared
  29597. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29598. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29599. */
  29600. wipeCaches(bruteForce?: boolean): void;
  29601. /**
  29602. * Set the compressed texture format to use, based on the formats you have, and the formats
  29603. * supported by the hardware / browser.
  29604. *
  29605. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29606. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29607. * to API arguments needed to compressed textures. This puts the burden on the container
  29608. * generator to house the arcane code for determining these for current & future formats.
  29609. *
  29610. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29611. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29612. *
  29613. * Note: The result of this call is not taken into account when a texture is base64.
  29614. *
  29615. * @param formatsAvailable defines the list of those format families you have created
  29616. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29617. *
  29618. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29619. * @returns The extension selected.
  29620. */
  29621. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29622. /** @hidden */
  29623. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29624. min: number;
  29625. mag: number;
  29626. };
  29627. /** @hidden */
  29628. _createTexture(): WebGLTexture;
  29629. /**
  29630. * Usually called from Texture.ts.
  29631. * Passed information to create a WebGLTexture
  29632. * @param urlArg defines a value which contains one of the following:
  29633. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29634. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29635. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29636. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29637. * @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)
  29638. * @param scene needed for loading to the correct scene
  29639. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29640. * @param onLoad optional callback to be called upon successful completion
  29641. * @param onError optional callback to be called upon failure
  29642. * @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
  29643. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29644. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29645. * @param forcedExtension defines the extension to use to pick the right loader
  29646. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29647. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29648. */
  29649. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29650. /**
  29651. * @hidden
  29652. * Rescales a texture
  29653. * @param source input texutre
  29654. * @param destination destination texture
  29655. * @param scene scene to use to render the resize
  29656. * @param internalFormat format to use when resizing
  29657. * @param onComplete callback to be called when resize has completed
  29658. */
  29659. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29660. private _unpackFlipYCached;
  29661. /**
  29662. * In case you are sharing the context with other applications, it might
  29663. * be interested to not cache the unpack flip y state to ensure a consistent
  29664. * value would be set.
  29665. */
  29666. enableUnpackFlipYCached: boolean;
  29667. /** @hidden */
  29668. _unpackFlipY(value: boolean): void;
  29669. /** @hidden */
  29670. _getUnpackAlignement(): number;
  29671. /**
  29672. * Creates a dynamic texture
  29673. * @param width defines the width of the texture
  29674. * @param height defines the height of the texture
  29675. * @param generateMipMaps defines if the engine should generate the mip levels
  29676. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29677. * @returns the dynamic texture inside an InternalTexture
  29678. */
  29679. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29680. /**
  29681. * Update the sampling mode of a given texture
  29682. * @param samplingMode defines the required sampling mode
  29683. * @param texture defines the texture to update
  29684. */
  29685. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29686. /**
  29687. * Update the content of a dynamic texture
  29688. * @param texture defines the texture to update
  29689. * @param canvas defines the canvas containing the source
  29690. * @param invertY defines if data must be stored with Y axis inverted
  29691. * @param premulAlpha defines if alpha is stored as premultiplied
  29692. * @param format defines the format of the data
  29693. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29694. */
  29695. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29696. /**
  29697. * Update a video texture
  29698. * @param texture defines the texture to update
  29699. * @param video defines the video element to use
  29700. * @param invertY defines if data must be stored with Y axis inverted
  29701. */
  29702. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29703. /**
  29704. * Updates a depth texture Comparison Mode and Function.
  29705. * If the comparison Function is equal to 0, the mode will be set to none.
  29706. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29707. * @param texture The texture to set the comparison function for
  29708. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29709. */
  29710. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29711. /** @hidden */
  29712. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29713. width: number;
  29714. height: number;
  29715. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29716. /**
  29717. * Creates a depth stencil texture.
  29718. * This is only available in WebGL 2 or with the depth texture extension available.
  29719. * @param size The size of face edge in the texture.
  29720. * @param options The options defining the texture.
  29721. * @returns The texture
  29722. */
  29723. createDepthStencilTexture(size: number | {
  29724. width: number;
  29725. height: number;
  29726. }, options: DepthTextureCreationOptions): InternalTexture;
  29727. /**
  29728. * Creates a depth stencil texture.
  29729. * This is only available in WebGL 2 or with the depth texture extension available.
  29730. * @param size The size of face edge in the texture.
  29731. * @param options The options defining the texture.
  29732. * @returns The texture
  29733. */
  29734. private _createDepthStencilTexture;
  29735. /**
  29736. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29737. * @param renderTarget The render target to set the frame buffer for
  29738. */
  29739. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29740. /**
  29741. * Creates a new render target texture
  29742. * @param size defines the size of the texture
  29743. * @param options defines the options used to create the texture
  29744. * @returns a new render target texture stored in an InternalTexture
  29745. */
  29746. createRenderTargetTexture(size: number | {
  29747. width: number;
  29748. height: number;
  29749. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29750. /** @hidden */
  29751. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29752. /**
  29753. * Updates the sample count of a render target texture
  29754. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29755. * @param texture defines the texture to update
  29756. * @param samples defines the sample count to set
  29757. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29758. */
  29759. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29760. /** @hidden */
  29761. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29762. /** @hidden */
  29763. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29764. /** @hidden */
  29765. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29766. /** @hidden */
  29767. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29768. /**
  29769. * @hidden
  29770. */
  29771. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29772. private _prepareWebGLTextureContinuation;
  29773. private _prepareWebGLTexture;
  29774. /** @hidden */
  29775. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29776. /** @hidden */
  29777. _releaseFramebufferObjects(texture: InternalTexture): void;
  29778. /** @hidden */
  29779. _releaseTexture(texture: InternalTexture): void;
  29780. private setProgram;
  29781. private _boundUniforms;
  29782. /**
  29783. * Binds an effect to the webGL context
  29784. * @param effect defines the effect to bind
  29785. */
  29786. bindSamplers(effect: Effect): void;
  29787. private _activateCurrentTexture;
  29788. /** @hidden */
  29789. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29790. /** @hidden */
  29791. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29792. /**
  29793. * Sets a texture to the webGL context from a postprocess
  29794. * @param channel defines the channel to use
  29795. * @param postProcess defines the source postprocess
  29796. */
  29797. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29798. /**
  29799. * Binds the output of the passed in post process to the texture channel specified
  29800. * @param channel The channel the texture should be bound to
  29801. * @param postProcess The post process which's output should be bound
  29802. */
  29803. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29804. /**
  29805. * Unbind all textures from the webGL context
  29806. */
  29807. unbindAllTextures(): void;
  29808. /**
  29809. * Sets a texture to the according uniform.
  29810. * @param channel The texture channel
  29811. * @param uniform The uniform to set
  29812. * @param texture The texture to apply
  29813. */
  29814. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29815. /**
  29816. * Sets a depth stencil texture from a render target to the according uniform.
  29817. * @param channel The texture channel
  29818. * @param uniform The uniform to set
  29819. * @param texture The render target texture containing the depth stencil texture to apply
  29820. */
  29821. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29822. private _bindSamplerUniformToChannel;
  29823. private _getTextureWrapMode;
  29824. private _setTexture;
  29825. /**
  29826. * Sets an array of texture to the webGL context
  29827. * @param channel defines the channel where the texture array must be set
  29828. * @param uniform defines the associated uniform location
  29829. * @param textures defines the array of textures to bind
  29830. */
  29831. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29832. /** @hidden */
  29833. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29834. private _setTextureParameterFloat;
  29835. private _setTextureParameterInteger;
  29836. /**
  29837. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29838. * @param x defines the x coordinate of the rectangle where pixels must be read
  29839. * @param y defines the y coordinate of the rectangle where pixels must be read
  29840. * @param width defines the width of the rectangle where pixels must be read
  29841. * @param height defines the height of the rectangle where pixels must be read
  29842. * @returns a Uint8Array containing RGBA colors
  29843. */
  29844. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29845. /**
  29846. * Add an externaly attached data from its key.
  29847. * This method call will fail and return false, if such key already exists.
  29848. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29849. * @param key the unique key that identifies the data
  29850. * @param data the data object to associate to the key for this Engine instance
  29851. * @return true if no such key were already present and the data was added successfully, false otherwise
  29852. */
  29853. addExternalData<T>(key: string, data: T): boolean;
  29854. /**
  29855. * Get an externaly attached data from its key
  29856. * @param key the unique key that identifies the data
  29857. * @return the associated data, if present (can be null), or undefined if not present
  29858. */
  29859. getExternalData<T>(key: string): T;
  29860. /**
  29861. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29862. * @param key the unique key that identifies the data
  29863. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29864. * @return the associated data, can be null if the factory returned null.
  29865. */
  29866. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29867. /**
  29868. * Remove an externaly attached data from the Engine instance
  29869. * @param key the unique key that identifies the data
  29870. * @return true if the data was successfully removed, false if it doesn't exist
  29871. */
  29872. removeExternalData(key: string): boolean;
  29873. /**
  29874. * Unbind all vertex attributes from the webGL context
  29875. */
  29876. unbindAllAttributes(): void;
  29877. /**
  29878. * 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
  29879. */
  29880. releaseEffects(): void;
  29881. /**
  29882. * Dispose and release all associated resources
  29883. */
  29884. dispose(): void;
  29885. /**
  29886. * Display the loading screen
  29887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29888. */
  29889. displayLoadingUI(): void;
  29890. /**
  29891. * Hide the loading screen
  29892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29893. */
  29894. hideLoadingUI(): void;
  29895. /**
  29896. * Gets the current loading screen object
  29897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29898. */
  29899. /**
  29900. * Sets the current loading screen object
  29901. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29902. */
  29903. loadingScreen: ILoadingScreen;
  29904. /**
  29905. * Sets the current loading screen text
  29906. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29907. */
  29908. loadingUIText: string;
  29909. /**
  29910. * Sets the current loading screen background color
  29911. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29912. */
  29913. loadingUIBackgroundColor: string;
  29914. /**
  29915. * Attach a new callback raised when context lost event is fired
  29916. * @param callback defines the callback to call
  29917. */
  29918. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29919. /**
  29920. * Attach a new callback raised when context restored event is fired
  29921. * @param callback defines the callback to call
  29922. */
  29923. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29924. /**
  29925. * Gets the source code of the vertex shader associated with a specific webGL program
  29926. * @param program defines the program to use
  29927. * @returns a string containing the source code of the vertex shader associated with the program
  29928. */
  29929. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29930. /**
  29931. * Gets the source code of the fragment shader associated with a specific webGL program
  29932. * @param program defines the program to use
  29933. * @returns a string containing the source code of the fragment shader associated with the program
  29934. */
  29935. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29936. /**
  29937. * Get the current error code of the webGL context
  29938. * @returns the error code
  29939. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29940. */
  29941. getError(): number;
  29942. /**
  29943. * Gets the current framerate
  29944. * @returns a number representing the framerate
  29945. */
  29946. getFps(): number;
  29947. /**
  29948. * Gets the time spent between current and previous frame
  29949. * @returns a number representing the delta time in ms
  29950. */
  29951. getDeltaTime(): number;
  29952. private _measureFps;
  29953. /** @hidden */
  29954. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29955. private _canRenderToFloatFramebuffer;
  29956. private _canRenderToHalfFloatFramebuffer;
  29957. private _canRenderToFramebuffer;
  29958. /** @hidden */
  29959. _getWebGLTextureType(type: number): number;
  29960. /** @hidden */
  29961. _getInternalFormat(format: number): number;
  29962. /** @hidden */
  29963. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29964. /** @hidden */
  29965. _getRGBAMultiSampleBufferFormat(type: number): number;
  29966. /** @hidden */
  29967. _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;
  29968. /** @hidden */
  29969. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29970. /**
  29971. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29972. * @returns true if the engine can be created
  29973. * @ignorenaming
  29974. */
  29975. static isSupported(): boolean;
  29976. }
  29977. }
  29978. declare module "babylonjs/Materials/effect" {
  29979. import { Observable } from "babylonjs/Misc/observable";
  29980. import { Nullable } from "babylonjs/types";
  29981. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29982. import { IDisposable } from "babylonjs/scene";
  29983. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29984. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29985. import { Engine } from "babylonjs/Engines/engine";
  29986. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29987. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29988. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29989. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29991. /**
  29992. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29993. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29994. */
  29995. export class EffectFallbacks {
  29996. private _defines;
  29997. private _currentRank;
  29998. private _maxRank;
  29999. private _mesh;
  30000. /**
  30001. * Removes the fallback from the bound mesh.
  30002. */
  30003. unBindMesh(): void;
  30004. /**
  30005. * Adds a fallback on the specified property.
  30006. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30007. * @param define The name of the define in the shader
  30008. */
  30009. addFallback(rank: number, define: string): void;
  30010. /**
  30011. * Sets the mesh to use CPU skinning when needing to fallback.
  30012. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30013. * @param mesh The mesh to use the fallbacks.
  30014. */
  30015. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30016. /**
  30017. * Checks to see if more fallbacks are still availible.
  30018. */
  30019. readonly isMoreFallbacks: boolean;
  30020. /**
  30021. * Removes the defines that should be removed when falling back.
  30022. * @param currentDefines defines the current define statements for the shader.
  30023. * @param effect defines the current effect we try to compile
  30024. * @returns The resulting defines with defines of the current rank removed.
  30025. */
  30026. reduce(currentDefines: string, effect: Effect): string;
  30027. }
  30028. /**
  30029. * Options to be used when creating an effect.
  30030. */
  30031. export class EffectCreationOptions {
  30032. /**
  30033. * Atrributes that will be used in the shader.
  30034. */
  30035. attributes: string[];
  30036. /**
  30037. * Uniform varible names that will be set in the shader.
  30038. */
  30039. uniformsNames: string[];
  30040. /**
  30041. * Uniform buffer varible names that will be set in the shader.
  30042. */
  30043. uniformBuffersNames: string[];
  30044. /**
  30045. * Sampler texture variable names that will be set in the shader.
  30046. */
  30047. samplers: string[];
  30048. /**
  30049. * Define statements that will be set in the shader.
  30050. */
  30051. defines: any;
  30052. /**
  30053. * Possible fallbacks for this effect to improve performance when needed.
  30054. */
  30055. fallbacks: Nullable<EffectFallbacks>;
  30056. /**
  30057. * Callback that will be called when the shader is compiled.
  30058. */
  30059. onCompiled: Nullable<(effect: Effect) => void>;
  30060. /**
  30061. * Callback that will be called if an error occurs during shader compilation.
  30062. */
  30063. onError: Nullable<(effect: Effect, errors: string) => void>;
  30064. /**
  30065. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30066. */
  30067. indexParameters: any;
  30068. /**
  30069. * Max number of lights that can be used in the shader.
  30070. */
  30071. maxSimultaneousLights: number;
  30072. /**
  30073. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30074. */
  30075. transformFeedbackVaryings: Nullable<string[]>;
  30076. }
  30077. /**
  30078. * Effect containing vertex and fragment shader that can be executed on an object.
  30079. */
  30080. export class Effect implements IDisposable {
  30081. /**
  30082. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30083. */
  30084. static ShadersRepository: string;
  30085. /**
  30086. * Name of the effect.
  30087. */
  30088. name: any;
  30089. /**
  30090. * String container all the define statements that should be set on the shader.
  30091. */
  30092. defines: string;
  30093. /**
  30094. * Callback that will be called when the shader is compiled.
  30095. */
  30096. onCompiled: Nullable<(effect: Effect) => void>;
  30097. /**
  30098. * Callback that will be called if an error occurs during shader compilation.
  30099. */
  30100. onError: Nullable<(effect: Effect, errors: string) => void>;
  30101. /**
  30102. * Callback that will be called when effect is bound.
  30103. */
  30104. onBind: Nullable<(effect: Effect) => void>;
  30105. /**
  30106. * Unique ID of the effect.
  30107. */
  30108. uniqueId: number;
  30109. /**
  30110. * Observable that will be called when the shader is compiled.
  30111. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30112. */
  30113. onCompileObservable: Observable<Effect>;
  30114. /**
  30115. * Observable that will be called if an error occurs during shader compilation.
  30116. */
  30117. onErrorObservable: Observable<Effect>;
  30118. /** @hidden */
  30119. _onBindObservable: Nullable<Observable<Effect>>;
  30120. /**
  30121. * Observable that will be called when effect is bound.
  30122. */
  30123. readonly onBindObservable: Observable<Effect>;
  30124. /** @hidden */
  30125. _bonesComputationForcedToCPU: boolean;
  30126. private static _uniqueIdSeed;
  30127. private _engine;
  30128. private _uniformBuffersNames;
  30129. private _uniformsNames;
  30130. private _samplerList;
  30131. private _samplers;
  30132. private _isReady;
  30133. private _compilationError;
  30134. private _attributesNames;
  30135. private _attributes;
  30136. private _uniforms;
  30137. /**
  30138. * Key for the effect.
  30139. * @hidden
  30140. */
  30141. _key: string;
  30142. private _indexParameters;
  30143. private _fallbacks;
  30144. private _vertexSourceCode;
  30145. private _fragmentSourceCode;
  30146. private _vertexSourceCodeOverride;
  30147. private _fragmentSourceCodeOverride;
  30148. private _transformFeedbackVaryings;
  30149. /**
  30150. * Compiled shader to webGL program.
  30151. * @hidden
  30152. */
  30153. _pipelineContext: Nullable<IPipelineContext>;
  30154. private _valueCache;
  30155. private static _baseCache;
  30156. /**
  30157. * Instantiates an effect.
  30158. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30159. * @param baseName Name of the effect.
  30160. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30161. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30162. * @param samplers List of sampler variables that will be passed to the shader.
  30163. * @param engine Engine to be used to render the effect
  30164. * @param defines Define statements to be added to the shader.
  30165. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30166. * @param onCompiled Callback that will be called when the shader is compiled.
  30167. * @param onError Callback that will be called if an error occurs during shader compilation.
  30168. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30169. */
  30170. 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);
  30171. private _useFinalCode;
  30172. /**
  30173. * Unique key for this effect
  30174. */
  30175. readonly key: string;
  30176. /**
  30177. * If the effect has been compiled and prepared.
  30178. * @returns if the effect is compiled and prepared.
  30179. */
  30180. isReady(): boolean;
  30181. /**
  30182. * The engine the effect was initialized with.
  30183. * @returns the engine.
  30184. */
  30185. getEngine(): Engine;
  30186. /**
  30187. * The pipeline context for this effect
  30188. * @returns the associated pipeline context
  30189. */
  30190. getPipelineContext(): Nullable<IPipelineContext>;
  30191. /**
  30192. * The set of names of attribute variables for the shader.
  30193. * @returns An array of attribute names.
  30194. */
  30195. getAttributesNames(): string[];
  30196. /**
  30197. * Returns the attribute at the given index.
  30198. * @param index The index of the attribute.
  30199. * @returns The location of the attribute.
  30200. */
  30201. getAttributeLocation(index: number): number;
  30202. /**
  30203. * Returns the attribute based on the name of the variable.
  30204. * @param name of the attribute to look up.
  30205. * @returns the attribute location.
  30206. */
  30207. getAttributeLocationByName(name: string): number;
  30208. /**
  30209. * The number of attributes.
  30210. * @returns the numnber of attributes.
  30211. */
  30212. getAttributesCount(): number;
  30213. /**
  30214. * Gets the index of a uniform variable.
  30215. * @param uniformName of the uniform to look up.
  30216. * @returns the index.
  30217. */
  30218. getUniformIndex(uniformName: string): number;
  30219. /**
  30220. * Returns the attribute based on the name of the variable.
  30221. * @param uniformName of the uniform to look up.
  30222. * @returns the location of the uniform.
  30223. */
  30224. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30225. /**
  30226. * Returns an array of sampler variable names
  30227. * @returns The array of sampler variable neames.
  30228. */
  30229. getSamplers(): string[];
  30230. /**
  30231. * The error from the last compilation.
  30232. * @returns the error string.
  30233. */
  30234. getCompilationError(): string;
  30235. /**
  30236. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30237. * @param func The callback to be used.
  30238. */
  30239. executeWhenCompiled(func: (effect: Effect) => void): void;
  30240. private _checkIsReady;
  30241. /** @hidden */
  30242. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30243. /** @hidden */
  30244. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30245. /** @hidden */
  30246. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30247. /**
  30248. * Recompiles the webGL program
  30249. * @param vertexSourceCode The source code for the vertex shader.
  30250. * @param fragmentSourceCode The source code for the fragment shader.
  30251. * @param onCompiled Callback called when completed.
  30252. * @param onError Callback called on error.
  30253. * @hidden
  30254. */
  30255. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30256. /**
  30257. * Prepares the effect
  30258. * @hidden
  30259. */
  30260. _prepareEffect(): void;
  30261. /**
  30262. * Checks if the effect is supported. (Must be called after compilation)
  30263. */
  30264. readonly isSupported: boolean;
  30265. /**
  30266. * Binds a texture to the engine to be used as output of the shader.
  30267. * @param channel Name of the output variable.
  30268. * @param texture Texture to bind.
  30269. * @hidden
  30270. */
  30271. _bindTexture(channel: string, texture: InternalTexture): void;
  30272. /**
  30273. * Sets a texture on the engine to be used in the shader.
  30274. * @param channel Name of the sampler variable.
  30275. * @param texture Texture to set.
  30276. */
  30277. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30278. /**
  30279. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30280. * @param channel Name of the sampler variable.
  30281. * @param texture Texture to set.
  30282. */
  30283. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30284. /**
  30285. * Sets an array of textures on the engine to be used in the shader.
  30286. * @param channel Name of the variable.
  30287. * @param textures Textures to set.
  30288. */
  30289. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30290. /**
  30291. * 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)
  30292. * @param channel Name of the sampler variable.
  30293. * @param postProcess Post process to get the input texture from.
  30294. */
  30295. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30296. /**
  30297. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30298. * 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)
  30299. * @param channel Name of the sampler variable.
  30300. * @param postProcess Post process to get the output texture from.
  30301. */
  30302. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30303. /** @hidden */
  30304. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30305. /** @hidden */
  30306. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30307. /** @hidden */
  30308. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30309. /** @hidden */
  30310. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30311. /**
  30312. * Binds a buffer to a uniform.
  30313. * @param buffer Buffer to bind.
  30314. * @param name Name of the uniform variable to bind to.
  30315. */
  30316. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30317. /**
  30318. * Binds block to a uniform.
  30319. * @param blockName Name of the block to bind.
  30320. * @param index Index to bind.
  30321. */
  30322. bindUniformBlock(blockName: string, index: number): void;
  30323. /**
  30324. * Sets an interger value on a uniform variable.
  30325. * @param uniformName Name of the variable.
  30326. * @param value Value to be set.
  30327. * @returns this effect.
  30328. */
  30329. setInt(uniformName: string, value: number): Effect;
  30330. /**
  30331. * Sets an int array on a uniform variable.
  30332. * @param uniformName Name of the variable.
  30333. * @param array array to be set.
  30334. * @returns this effect.
  30335. */
  30336. setIntArray(uniformName: string, array: Int32Array): Effect;
  30337. /**
  30338. * 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)
  30339. * @param uniformName Name of the variable.
  30340. * @param array array to be set.
  30341. * @returns this effect.
  30342. */
  30343. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30344. /**
  30345. * 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)
  30346. * @param uniformName Name of the variable.
  30347. * @param array array to be set.
  30348. * @returns this effect.
  30349. */
  30350. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30351. /**
  30352. * 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)
  30353. * @param uniformName Name of the variable.
  30354. * @param array array to be set.
  30355. * @returns this effect.
  30356. */
  30357. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30358. /**
  30359. * Sets an float array on a uniform variable.
  30360. * @param uniformName Name of the variable.
  30361. * @param array array to be set.
  30362. * @returns this effect.
  30363. */
  30364. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30365. /**
  30366. * 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)
  30367. * @param uniformName Name of the variable.
  30368. * @param array array to be set.
  30369. * @returns this effect.
  30370. */
  30371. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30372. /**
  30373. * 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)
  30374. * @param uniformName Name of the variable.
  30375. * @param array array to be set.
  30376. * @returns this effect.
  30377. */
  30378. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30379. /**
  30380. * 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)
  30381. * @param uniformName Name of the variable.
  30382. * @param array array to be set.
  30383. * @returns this effect.
  30384. */
  30385. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30386. /**
  30387. * Sets an array on a uniform variable.
  30388. * @param uniformName Name of the variable.
  30389. * @param array array to be set.
  30390. * @returns this effect.
  30391. */
  30392. setArray(uniformName: string, array: number[]): Effect;
  30393. /**
  30394. * 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)
  30395. * @param uniformName Name of the variable.
  30396. * @param array array to be set.
  30397. * @returns this effect.
  30398. */
  30399. setArray2(uniformName: string, array: number[]): Effect;
  30400. /**
  30401. * 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)
  30402. * @param uniformName Name of the variable.
  30403. * @param array array to be set.
  30404. * @returns this effect.
  30405. */
  30406. setArray3(uniformName: string, array: number[]): Effect;
  30407. /**
  30408. * 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)
  30409. * @param uniformName Name of the variable.
  30410. * @param array array to be set.
  30411. * @returns this effect.
  30412. */
  30413. setArray4(uniformName: string, array: number[]): Effect;
  30414. /**
  30415. * Sets matrices on a uniform variable.
  30416. * @param uniformName Name of the variable.
  30417. * @param matrices matrices to be set.
  30418. * @returns this effect.
  30419. */
  30420. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30421. /**
  30422. * Sets matrix on a uniform variable.
  30423. * @param uniformName Name of the variable.
  30424. * @param matrix matrix to be set.
  30425. * @returns this effect.
  30426. */
  30427. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30428. /**
  30429. * 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)
  30430. * @param uniformName Name of the variable.
  30431. * @param matrix matrix to be set.
  30432. * @returns this effect.
  30433. */
  30434. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30435. /**
  30436. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30437. * @param uniformName Name of the variable.
  30438. * @param matrix matrix to be set.
  30439. * @returns this effect.
  30440. */
  30441. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30442. /**
  30443. * Sets a float on a uniform variable.
  30444. * @param uniformName Name of the variable.
  30445. * @param value value to be set.
  30446. * @returns this effect.
  30447. */
  30448. setFloat(uniformName: string, value: number): Effect;
  30449. /**
  30450. * Sets a boolean on a uniform variable.
  30451. * @param uniformName Name of the variable.
  30452. * @param bool value to be set.
  30453. * @returns this effect.
  30454. */
  30455. setBool(uniformName: string, bool: boolean): Effect;
  30456. /**
  30457. * Sets a Vector2 on a uniform variable.
  30458. * @param uniformName Name of the variable.
  30459. * @param vector2 vector2 to be set.
  30460. * @returns this effect.
  30461. */
  30462. setVector2(uniformName: string, vector2: Vector2): Effect;
  30463. /**
  30464. * Sets a float2 on a uniform variable.
  30465. * @param uniformName Name of the variable.
  30466. * @param x First float in float2.
  30467. * @param y Second float in float2.
  30468. * @returns this effect.
  30469. */
  30470. setFloat2(uniformName: string, x: number, y: number): Effect;
  30471. /**
  30472. * Sets a Vector3 on a uniform variable.
  30473. * @param uniformName Name of the variable.
  30474. * @param vector3 Value to be set.
  30475. * @returns this effect.
  30476. */
  30477. setVector3(uniformName: string, vector3: Vector3): Effect;
  30478. /**
  30479. * Sets a float3 on a uniform variable.
  30480. * @param uniformName Name of the variable.
  30481. * @param x First float in float3.
  30482. * @param y Second float in float3.
  30483. * @param z Third float in float3.
  30484. * @returns this effect.
  30485. */
  30486. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30487. /**
  30488. * Sets a Vector4 on a uniform variable.
  30489. * @param uniformName Name of the variable.
  30490. * @param vector4 Value to be set.
  30491. * @returns this effect.
  30492. */
  30493. setVector4(uniformName: string, vector4: Vector4): Effect;
  30494. /**
  30495. * Sets a float4 on a uniform variable.
  30496. * @param uniformName Name of the variable.
  30497. * @param x First float in float4.
  30498. * @param y Second float in float4.
  30499. * @param z Third float in float4.
  30500. * @param w Fourth float in float4.
  30501. * @returns this effect.
  30502. */
  30503. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30504. /**
  30505. * Sets a Color3 on a uniform variable.
  30506. * @param uniformName Name of the variable.
  30507. * @param color3 Value to be set.
  30508. * @returns this effect.
  30509. */
  30510. setColor3(uniformName: string, color3: Color3): Effect;
  30511. /**
  30512. * Sets a Color4 on a uniform variable.
  30513. * @param uniformName Name of the variable.
  30514. * @param color3 Value to be set.
  30515. * @param alpha Alpha value to be set.
  30516. * @returns this effect.
  30517. */
  30518. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30519. /**
  30520. * Sets a Color4 on a uniform variable
  30521. * @param uniformName defines the name of the variable
  30522. * @param color4 defines the value to be set
  30523. * @returns this effect.
  30524. */
  30525. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30526. /** Release all associated resources */
  30527. dispose(): void;
  30528. /**
  30529. * This function will add a new shader to the shader store
  30530. * @param name the name of the shader
  30531. * @param pixelShader optional pixel shader content
  30532. * @param vertexShader optional vertex shader content
  30533. */
  30534. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30535. /**
  30536. * Store of each shader (The can be looked up using effect.key)
  30537. */
  30538. static ShadersStore: {
  30539. [key: string]: string;
  30540. };
  30541. /**
  30542. * Store of each included file for a shader (The can be looked up using effect.key)
  30543. */
  30544. static IncludesShadersStore: {
  30545. [key: string]: string;
  30546. };
  30547. /**
  30548. * Resets the cache of effects.
  30549. */
  30550. static ResetCache(): void;
  30551. }
  30552. }
  30553. declare module "babylonjs/Materials/colorCurves" {
  30554. import { Effect } from "babylonjs/Materials/effect";
  30555. /**
  30556. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30557. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30558. * 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;
  30559. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30560. */
  30561. export class ColorCurves {
  30562. private _dirty;
  30563. private _tempColor;
  30564. private _globalCurve;
  30565. private _highlightsCurve;
  30566. private _midtonesCurve;
  30567. private _shadowsCurve;
  30568. private _positiveCurve;
  30569. private _negativeCurve;
  30570. private _globalHue;
  30571. private _globalDensity;
  30572. private _globalSaturation;
  30573. private _globalExposure;
  30574. /**
  30575. * Gets the global Hue value.
  30576. * 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).
  30577. */
  30578. /**
  30579. * Sets the global Hue value.
  30580. * 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).
  30581. */
  30582. globalHue: number;
  30583. /**
  30584. * Gets the global Density value.
  30585. * 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.
  30586. * Values less than zero provide a filter of opposite hue.
  30587. */
  30588. /**
  30589. * Sets the global Density value.
  30590. * 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.
  30591. * Values less than zero provide a filter of opposite hue.
  30592. */
  30593. globalDensity: number;
  30594. /**
  30595. * Gets the global Saturation value.
  30596. * 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.
  30597. */
  30598. /**
  30599. * Sets the global Saturation value.
  30600. * 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.
  30601. */
  30602. globalSaturation: number;
  30603. /**
  30604. * Gets the global Exposure value.
  30605. * 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.
  30606. */
  30607. /**
  30608. * Sets the global Exposure value.
  30609. * 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.
  30610. */
  30611. globalExposure: number;
  30612. private _highlightsHue;
  30613. private _highlightsDensity;
  30614. private _highlightsSaturation;
  30615. private _highlightsExposure;
  30616. /**
  30617. * Gets the highlights Hue value.
  30618. * 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).
  30619. */
  30620. /**
  30621. * Sets the highlights Hue value.
  30622. * 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).
  30623. */
  30624. highlightsHue: number;
  30625. /**
  30626. * Gets the highlights Density value.
  30627. * 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.
  30628. * Values less than zero provide a filter of opposite hue.
  30629. */
  30630. /**
  30631. * Sets the highlights Density value.
  30632. * 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.
  30633. * Values less than zero provide a filter of opposite hue.
  30634. */
  30635. highlightsDensity: number;
  30636. /**
  30637. * Gets the highlights Saturation value.
  30638. * 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.
  30639. */
  30640. /**
  30641. * Sets the highlights Saturation value.
  30642. * 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.
  30643. */
  30644. highlightsSaturation: number;
  30645. /**
  30646. * Gets the highlights Exposure value.
  30647. * 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.
  30648. */
  30649. /**
  30650. * Sets the highlights Exposure value.
  30651. * 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.
  30652. */
  30653. highlightsExposure: number;
  30654. private _midtonesHue;
  30655. private _midtonesDensity;
  30656. private _midtonesSaturation;
  30657. private _midtonesExposure;
  30658. /**
  30659. * Gets the midtones Hue value.
  30660. * 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).
  30661. */
  30662. /**
  30663. * Sets the midtones Hue value.
  30664. * 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).
  30665. */
  30666. midtonesHue: number;
  30667. /**
  30668. * Gets the midtones Density value.
  30669. * 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.
  30670. * Values less than zero provide a filter of opposite hue.
  30671. */
  30672. /**
  30673. * Sets the midtones Density value.
  30674. * 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.
  30675. * Values less than zero provide a filter of opposite hue.
  30676. */
  30677. midtonesDensity: number;
  30678. /**
  30679. * Gets the midtones Saturation value.
  30680. * 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.
  30681. */
  30682. /**
  30683. * Sets the midtones Saturation value.
  30684. * 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.
  30685. */
  30686. midtonesSaturation: number;
  30687. /**
  30688. * Gets the midtones Exposure value.
  30689. * 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.
  30690. */
  30691. /**
  30692. * Sets the midtones Exposure value.
  30693. * 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.
  30694. */
  30695. midtonesExposure: number;
  30696. private _shadowsHue;
  30697. private _shadowsDensity;
  30698. private _shadowsSaturation;
  30699. private _shadowsExposure;
  30700. /**
  30701. * Gets the shadows Hue value.
  30702. * 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).
  30703. */
  30704. /**
  30705. * Sets the shadows Hue value.
  30706. * 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).
  30707. */
  30708. shadowsHue: number;
  30709. /**
  30710. * Gets the shadows Density value.
  30711. * 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.
  30712. * Values less than zero provide a filter of opposite hue.
  30713. */
  30714. /**
  30715. * Sets the shadows Density value.
  30716. * 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.
  30717. * Values less than zero provide a filter of opposite hue.
  30718. */
  30719. shadowsDensity: number;
  30720. /**
  30721. * Gets the shadows Saturation value.
  30722. * 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.
  30723. */
  30724. /**
  30725. * Sets the shadows Saturation value.
  30726. * 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.
  30727. */
  30728. shadowsSaturation: number;
  30729. /**
  30730. * Gets the shadows Exposure value.
  30731. * 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.
  30732. */
  30733. /**
  30734. * Sets the shadows Exposure value.
  30735. * 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.
  30736. */
  30737. shadowsExposure: number;
  30738. /**
  30739. * Returns the class name
  30740. * @returns The class name
  30741. */
  30742. getClassName(): string;
  30743. /**
  30744. * Binds the color curves to the shader.
  30745. * @param colorCurves The color curve to bind
  30746. * @param effect The effect to bind to
  30747. * @param positiveUniform The positive uniform shader parameter
  30748. * @param neutralUniform The neutral uniform shader parameter
  30749. * @param negativeUniform The negative uniform shader parameter
  30750. */
  30751. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30752. /**
  30753. * Prepare the list of uniforms associated with the ColorCurves effects.
  30754. * @param uniformsList The list of uniforms used in the effect
  30755. */
  30756. static PrepareUniforms(uniformsList: string[]): void;
  30757. /**
  30758. * Returns color grading data based on a hue, density, saturation and exposure value.
  30759. * @param filterHue The hue of the color filter.
  30760. * @param filterDensity The density of the color filter.
  30761. * @param saturation The saturation.
  30762. * @param exposure The exposure.
  30763. * @param result The result data container.
  30764. */
  30765. private getColorGradingDataToRef;
  30766. /**
  30767. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30768. * @param value The input slider value in range [-100,100].
  30769. * @returns Adjusted value.
  30770. */
  30771. private static applyColorGradingSliderNonlinear;
  30772. /**
  30773. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30774. * @param hue The hue (H) input.
  30775. * @param saturation The saturation (S) input.
  30776. * @param brightness The brightness (B) input.
  30777. * @result An RGBA color represented as Vector4.
  30778. */
  30779. private static fromHSBToRef;
  30780. /**
  30781. * Returns a value clamped between min and max
  30782. * @param value The value to clamp
  30783. * @param min The minimum of value
  30784. * @param max The maximum of value
  30785. * @returns The clamped value.
  30786. */
  30787. private static clamp;
  30788. /**
  30789. * Clones the current color curve instance.
  30790. * @return The cloned curves
  30791. */
  30792. clone(): ColorCurves;
  30793. /**
  30794. * Serializes the current color curve instance to a json representation.
  30795. * @return a JSON representation
  30796. */
  30797. serialize(): any;
  30798. /**
  30799. * Parses the color curve from a json representation.
  30800. * @param source the JSON source to parse
  30801. * @return The parsed curves
  30802. */
  30803. static Parse(source: any): ColorCurves;
  30804. }
  30805. }
  30806. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30807. import { Observable } from "babylonjs/Misc/observable";
  30808. import { Nullable } from "babylonjs/types";
  30809. import { Color4 } from "babylonjs/Maths/math";
  30810. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30811. import { Effect } from "babylonjs/Materials/effect";
  30812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30813. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30814. /**
  30815. * Interface to follow in your material defines to integrate easily the
  30816. * Image proccessing functions.
  30817. * @hidden
  30818. */
  30819. export interface IImageProcessingConfigurationDefines {
  30820. IMAGEPROCESSING: boolean;
  30821. VIGNETTE: boolean;
  30822. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30823. VIGNETTEBLENDMODEOPAQUE: boolean;
  30824. TONEMAPPING: boolean;
  30825. TONEMAPPING_ACES: boolean;
  30826. CONTRAST: boolean;
  30827. EXPOSURE: boolean;
  30828. COLORCURVES: boolean;
  30829. COLORGRADING: boolean;
  30830. COLORGRADING3D: boolean;
  30831. SAMPLER3DGREENDEPTH: boolean;
  30832. SAMPLER3DBGRMAP: boolean;
  30833. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30834. }
  30835. /**
  30836. * @hidden
  30837. */
  30838. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30839. IMAGEPROCESSING: boolean;
  30840. VIGNETTE: boolean;
  30841. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30842. VIGNETTEBLENDMODEOPAQUE: boolean;
  30843. TONEMAPPING: boolean;
  30844. TONEMAPPING_ACES: boolean;
  30845. CONTRAST: boolean;
  30846. COLORCURVES: boolean;
  30847. COLORGRADING: boolean;
  30848. COLORGRADING3D: boolean;
  30849. SAMPLER3DGREENDEPTH: boolean;
  30850. SAMPLER3DBGRMAP: boolean;
  30851. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30852. EXPOSURE: boolean;
  30853. constructor();
  30854. }
  30855. /**
  30856. * This groups together the common properties used for image processing either in direct forward pass
  30857. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30858. * or not.
  30859. */
  30860. export class ImageProcessingConfiguration {
  30861. /**
  30862. * Default tone mapping applied in BabylonJS.
  30863. */
  30864. static readonly TONEMAPPING_STANDARD: number;
  30865. /**
  30866. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30867. * to other engines rendering to increase portability.
  30868. */
  30869. static readonly TONEMAPPING_ACES: number;
  30870. /**
  30871. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30872. */
  30873. colorCurves: Nullable<ColorCurves>;
  30874. private _colorCurvesEnabled;
  30875. /**
  30876. * Gets wether the color curves effect is enabled.
  30877. */
  30878. /**
  30879. * Sets wether the color curves effect is enabled.
  30880. */
  30881. colorCurvesEnabled: boolean;
  30882. private _colorGradingTexture;
  30883. /**
  30884. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30885. */
  30886. /**
  30887. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30888. */
  30889. colorGradingTexture: Nullable<BaseTexture>;
  30890. private _colorGradingEnabled;
  30891. /**
  30892. * Gets wether the color grading effect is enabled.
  30893. */
  30894. /**
  30895. * Sets wether the color grading effect is enabled.
  30896. */
  30897. colorGradingEnabled: boolean;
  30898. private _colorGradingWithGreenDepth;
  30899. /**
  30900. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30901. */
  30902. /**
  30903. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30904. */
  30905. colorGradingWithGreenDepth: boolean;
  30906. private _colorGradingBGR;
  30907. /**
  30908. * Gets wether the color grading texture contains BGR values.
  30909. */
  30910. /**
  30911. * Sets wether the color grading texture contains BGR values.
  30912. */
  30913. colorGradingBGR: boolean;
  30914. /** @hidden */
  30915. _exposure: number;
  30916. /**
  30917. * Gets the Exposure used in the effect.
  30918. */
  30919. /**
  30920. * Sets the Exposure used in the effect.
  30921. */
  30922. exposure: number;
  30923. private _toneMappingEnabled;
  30924. /**
  30925. * Gets wether the tone mapping effect is enabled.
  30926. */
  30927. /**
  30928. * Sets wether the tone mapping effect is enabled.
  30929. */
  30930. toneMappingEnabled: boolean;
  30931. private _toneMappingType;
  30932. /**
  30933. * Gets the type of tone mapping effect.
  30934. */
  30935. /**
  30936. * Sets the type of tone mapping effect used in BabylonJS.
  30937. */
  30938. toneMappingType: number;
  30939. protected _contrast: number;
  30940. /**
  30941. * Gets the contrast used in the effect.
  30942. */
  30943. /**
  30944. * Sets the contrast used in the effect.
  30945. */
  30946. contrast: number;
  30947. /**
  30948. * Vignette stretch size.
  30949. */
  30950. vignetteStretch: number;
  30951. /**
  30952. * Vignette centre X Offset.
  30953. */
  30954. vignetteCentreX: number;
  30955. /**
  30956. * Vignette centre Y Offset.
  30957. */
  30958. vignetteCentreY: number;
  30959. /**
  30960. * Vignette weight or intensity of the vignette effect.
  30961. */
  30962. vignetteWeight: number;
  30963. /**
  30964. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30965. * if vignetteEnabled is set to true.
  30966. */
  30967. vignetteColor: Color4;
  30968. /**
  30969. * Camera field of view used by the Vignette effect.
  30970. */
  30971. vignetteCameraFov: number;
  30972. private _vignetteBlendMode;
  30973. /**
  30974. * Gets the vignette blend mode allowing different kind of effect.
  30975. */
  30976. /**
  30977. * Sets the vignette blend mode allowing different kind of effect.
  30978. */
  30979. vignetteBlendMode: number;
  30980. private _vignetteEnabled;
  30981. /**
  30982. * Gets wether the vignette effect is enabled.
  30983. */
  30984. /**
  30985. * Sets wether the vignette effect is enabled.
  30986. */
  30987. vignetteEnabled: boolean;
  30988. private _applyByPostProcess;
  30989. /**
  30990. * Gets wether the image processing is applied through a post process or not.
  30991. */
  30992. /**
  30993. * Sets wether the image processing is applied through a post process or not.
  30994. */
  30995. applyByPostProcess: boolean;
  30996. private _isEnabled;
  30997. /**
  30998. * Gets wether the image processing is enabled or not.
  30999. */
  31000. /**
  31001. * Sets wether the image processing is enabled or not.
  31002. */
  31003. isEnabled: boolean;
  31004. /**
  31005. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31006. */
  31007. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31008. /**
  31009. * Method called each time the image processing information changes requires to recompile the effect.
  31010. */
  31011. protected _updateParameters(): void;
  31012. /**
  31013. * Gets the current class name.
  31014. * @return "ImageProcessingConfiguration"
  31015. */
  31016. getClassName(): string;
  31017. /**
  31018. * Prepare the list of uniforms associated with the Image Processing effects.
  31019. * @param uniforms The list of uniforms used in the effect
  31020. * @param defines the list of defines currently in use
  31021. */
  31022. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31023. /**
  31024. * Prepare the list of samplers associated with the Image Processing effects.
  31025. * @param samplersList The list of uniforms used in the effect
  31026. * @param defines the list of defines currently in use
  31027. */
  31028. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31029. /**
  31030. * Prepare the list of defines associated to the shader.
  31031. * @param defines the list of defines to complete
  31032. * @param forPostProcess Define if we are currently in post process mode or not
  31033. */
  31034. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31035. /**
  31036. * Returns true if all the image processing information are ready.
  31037. * @returns True if ready, otherwise, false
  31038. */
  31039. isReady(): boolean;
  31040. /**
  31041. * Binds the image processing to the shader.
  31042. * @param effect The effect to bind to
  31043. * @param aspectRatio Define the current aspect ratio of the effect
  31044. */
  31045. bind(effect: Effect, aspectRatio?: number): void;
  31046. /**
  31047. * Clones the current image processing instance.
  31048. * @return The cloned image processing
  31049. */
  31050. clone(): ImageProcessingConfiguration;
  31051. /**
  31052. * Serializes the current image processing instance to a json representation.
  31053. * @return a JSON representation
  31054. */
  31055. serialize(): any;
  31056. /**
  31057. * Parses the image processing from a json representation.
  31058. * @param source the JSON source to parse
  31059. * @return The parsed image processing
  31060. */
  31061. static Parse(source: any): ImageProcessingConfiguration;
  31062. private static _VIGNETTEMODE_MULTIPLY;
  31063. private static _VIGNETTEMODE_OPAQUE;
  31064. /**
  31065. * Used to apply the vignette as a mix with the pixel color.
  31066. */
  31067. static readonly VIGNETTEMODE_MULTIPLY: number;
  31068. /**
  31069. * Used to apply the vignette as a replacement of the pixel color.
  31070. */
  31071. static readonly VIGNETTEMODE_OPAQUE: number;
  31072. }
  31073. }
  31074. declare module "babylonjs/Materials/fresnelParameters" {
  31075. import { Color3 } from "babylonjs/Maths/math";
  31076. /**
  31077. * This represents all the required information to add a fresnel effect on a material:
  31078. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31079. */
  31080. export class FresnelParameters {
  31081. private _isEnabled;
  31082. /**
  31083. * Define if the fresnel effect is enable or not.
  31084. */
  31085. isEnabled: boolean;
  31086. /**
  31087. * Define the color used on edges (grazing angle)
  31088. */
  31089. leftColor: Color3;
  31090. /**
  31091. * Define the color used on center
  31092. */
  31093. rightColor: Color3;
  31094. /**
  31095. * Define bias applied to computed fresnel term
  31096. */
  31097. bias: number;
  31098. /**
  31099. * Defined the power exponent applied to fresnel term
  31100. */
  31101. power: number;
  31102. /**
  31103. * Clones the current fresnel and its valuues
  31104. * @returns a clone fresnel configuration
  31105. */
  31106. clone(): FresnelParameters;
  31107. /**
  31108. * Serializes the current fresnel parameters to a JSON representation.
  31109. * @return the JSON serialization
  31110. */
  31111. serialize(): any;
  31112. /**
  31113. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31114. * @param parsedFresnelParameters Define the JSON representation
  31115. * @returns the parsed parameters
  31116. */
  31117. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31118. }
  31119. }
  31120. declare module "babylonjs/Misc/decorators" {
  31121. import { Nullable } from "babylonjs/types";
  31122. import { Scene } from "babylonjs/scene";
  31123. import { IAnimatable } from "babylonjs/Misc/tools";
  31124. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31125. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31126. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31127. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31128. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31129. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31130. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31131. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31132. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31133. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31134. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31135. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31136. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31137. /**
  31138. * Decorator used to define property that can be serialized as reference to a camera
  31139. * @param sourceName defines the name of the property to decorate
  31140. */
  31141. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31142. /**
  31143. * Class used to help serialization objects
  31144. */
  31145. export class SerializationHelper {
  31146. /** @hidden */
  31147. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31148. /** @hidden */
  31149. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31150. /** @hidden */
  31151. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31152. /** @hidden */
  31153. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31154. /**
  31155. * Appends the serialized animations from the source animations
  31156. * @param source Source containing the animations
  31157. * @param destination Target to store the animations
  31158. */
  31159. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31160. /**
  31161. * Static function used to serialized a specific entity
  31162. * @param entity defines the entity to serialize
  31163. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31164. * @returns a JSON compatible object representing the serialization of the entity
  31165. */
  31166. static Serialize<T>(entity: T, serializationObject?: any): any;
  31167. /**
  31168. * Creates a new entity from a serialization data object
  31169. * @param creationFunction defines a function used to instanciated the new entity
  31170. * @param source defines the source serialization data
  31171. * @param scene defines the hosting scene
  31172. * @param rootUrl defines the root url for resources
  31173. * @returns a new entity
  31174. */
  31175. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31176. /**
  31177. * Clones an object
  31178. * @param creationFunction defines the function used to instanciate the new object
  31179. * @param source defines the source object
  31180. * @returns the cloned object
  31181. */
  31182. static Clone<T>(creationFunction: () => T, source: T): T;
  31183. /**
  31184. * Instanciates a new object based on a source one (some data will be shared between both object)
  31185. * @param creationFunction defines the function used to instanciate the new object
  31186. * @param source defines the source object
  31187. * @returns the new object
  31188. */
  31189. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31190. }
  31191. }
  31192. declare module "babylonjs/Cameras/camera" {
  31193. import { SmartArray } from "babylonjs/Misc/smartArray";
  31194. import { Observable } from "babylonjs/Misc/observable";
  31195. import { Nullable } from "babylonjs/types";
  31196. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31197. import { Scene } from "babylonjs/scene";
  31198. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31199. import { Node } from "babylonjs/node";
  31200. import { Mesh } from "babylonjs/Meshes/mesh";
  31201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31202. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31203. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31204. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31205. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31206. import { Ray } from "babylonjs/Culling/ray";
  31207. /**
  31208. * This is the base class of all the camera used in the application.
  31209. * @see http://doc.babylonjs.com/features/cameras
  31210. */
  31211. export class Camera extends Node {
  31212. /** @hidden */
  31213. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31214. /**
  31215. * This is the default projection mode used by the cameras.
  31216. * It helps recreating a feeling of perspective and better appreciate depth.
  31217. * This is the best way to simulate real life cameras.
  31218. */
  31219. static readonly PERSPECTIVE_CAMERA: number;
  31220. /**
  31221. * This helps creating camera with an orthographic mode.
  31222. * 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.
  31223. */
  31224. static readonly ORTHOGRAPHIC_CAMERA: number;
  31225. /**
  31226. * This is the default FOV mode for perspective cameras.
  31227. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31228. */
  31229. static readonly FOVMODE_VERTICAL_FIXED: number;
  31230. /**
  31231. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31232. */
  31233. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31234. /**
  31235. * This specifies ther is no need for a camera rig.
  31236. * Basically only one eye is rendered corresponding to the camera.
  31237. */
  31238. static readonly RIG_MODE_NONE: number;
  31239. /**
  31240. * Simulates a camera Rig with one blue eye and one red eye.
  31241. * This can be use with 3d blue and red glasses.
  31242. */
  31243. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31244. /**
  31245. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31246. */
  31247. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31248. /**
  31249. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31250. */
  31251. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31252. /**
  31253. * Defines that both eyes of the camera will be rendered over under each other.
  31254. */
  31255. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31256. /**
  31257. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31258. */
  31259. static readonly RIG_MODE_VR: number;
  31260. /**
  31261. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31262. */
  31263. static readonly RIG_MODE_WEBVR: number;
  31264. /**
  31265. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31266. */
  31267. static readonly RIG_MODE_CUSTOM: number;
  31268. /**
  31269. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31270. */
  31271. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31272. /**
  31273. * Define the input manager associated with the camera.
  31274. */
  31275. inputs: CameraInputsManager<Camera>;
  31276. /** @hidden */
  31277. _position: Vector3;
  31278. /**
  31279. * Define the current local position of the camera in the scene
  31280. */
  31281. position: Vector3;
  31282. /**
  31283. * The vector the camera should consider as up.
  31284. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31285. */
  31286. upVector: Vector3;
  31287. /**
  31288. * Define the current limit on the left side for an orthographic camera
  31289. * In scene unit
  31290. */
  31291. orthoLeft: Nullable<number>;
  31292. /**
  31293. * Define the current limit on the right side for an orthographic camera
  31294. * In scene unit
  31295. */
  31296. orthoRight: Nullable<number>;
  31297. /**
  31298. * Define the current limit on the bottom side for an orthographic camera
  31299. * In scene unit
  31300. */
  31301. orthoBottom: Nullable<number>;
  31302. /**
  31303. * Define the current limit on the top side for an orthographic camera
  31304. * In scene unit
  31305. */
  31306. orthoTop: Nullable<number>;
  31307. /**
  31308. * Field Of View is set in Radians. (default is 0.8)
  31309. */
  31310. fov: number;
  31311. /**
  31312. * Define the minimum distance the camera can see from.
  31313. * This is important to note that the depth buffer are not infinite and the closer it starts
  31314. * the more your scene might encounter depth fighting issue.
  31315. */
  31316. minZ: number;
  31317. /**
  31318. * Define the maximum distance the camera can see to.
  31319. * This is important to note that the depth buffer are not infinite and the further it end
  31320. * the more your scene might encounter depth fighting issue.
  31321. */
  31322. maxZ: number;
  31323. /**
  31324. * Define the default inertia of the camera.
  31325. * This helps giving a smooth feeling to the camera movement.
  31326. */
  31327. inertia: number;
  31328. /**
  31329. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31330. */
  31331. mode: number;
  31332. /**
  31333. * Define wether the camera is intermediate.
  31334. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31335. */
  31336. isIntermediate: boolean;
  31337. /**
  31338. * Define the viewport of the camera.
  31339. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31340. */
  31341. viewport: Viewport;
  31342. /**
  31343. * Restricts the camera to viewing objects with the same layerMask.
  31344. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31345. */
  31346. layerMask: number;
  31347. /**
  31348. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31349. */
  31350. fovMode: number;
  31351. /**
  31352. * Rig mode of the camera.
  31353. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31354. * This is normally controlled byt the camera themselves as internal use.
  31355. */
  31356. cameraRigMode: number;
  31357. /**
  31358. * Defines the distance between both "eyes" in case of a RIG
  31359. */
  31360. interaxialDistance: number;
  31361. /**
  31362. * Defines if stereoscopic rendering is done side by side or over under.
  31363. */
  31364. isStereoscopicSideBySide: boolean;
  31365. /**
  31366. * 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
  31367. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31368. * else in the scene.
  31369. */
  31370. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31371. /**
  31372. * When set, the camera will render to this render target instead of the default canvas
  31373. */
  31374. outputRenderTarget: Nullable<RenderTargetTexture>;
  31375. /**
  31376. * Observable triggered when the camera view matrix has changed.
  31377. */
  31378. onViewMatrixChangedObservable: Observable<Camera>;
  31379. /**
  31380. * Observable triggered when the camera Projection matrix has changed.
  31381. */
  31382. onProjectionMatrixChangedObservable: Observable<Camera>;
  31383. /**
  31384. * Observable triggered when the inputs have been processed.
  31385. */
  31386. onAfterCheckInputsObservable: Observable<Camera>;
  31387. /**
  31388. * Observable triggered when reset has been called and applied to the camera.
  31389. */
  31390. onRestoreStateObservable: Observable<Camera>;
  31391. /** @hidden */
  31392. _cameraRigParams: any;
  31393. /** @hidden */
  31394. _rigCameras: Camera[];
  31395. /** @hidden */
  31396. _rigPostProcess: Nullable<PostProcess>;
  31397. protected _webvrViewMatrix: Matrix;
  31398. /** @hidden */
  31399. _skipRendering: boolean;
  31400. /** @hidden */
  31401. _projectionMatrix: Matrix;
  31402. /** @hidden */
  31403. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31404. /** @hidden */
  31405. _activeMeshes: SmartArray<AbstractMesh>;
  31406. protected _globalPosition: Vector3;
  31407. /** @hidden */
  31408. _computedViewMatrix: Matrix;
  31409. private _doNotComputeProjectionMatrix;
  31410. private _transformMatrix;
  31411. private _frustumPlanes;
  31412. private _refreshFrustumPlanes;
  31413. private _storedFov;
  31414. private _stateStored;
  31415. /**
  31416. * Instantiates a new camera object.
  31417. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31418. * @see http://doc.babylonjs.com/features/cameras
  31419. * @param name Defines the name of the camera in the scene
  31420. * @param position Defines the position of the camera
  31421. * @param scene Defines the scene the camera belongs too
  31422. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31423. */
  31424. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31425. /**
  31426. * Store current camera state (fov, position, etc..)
  31427. * @returns the camera
  31428. */
  31429. storeState(): Camera;
  31430. /**
  31431. * Restores the camera state values if it has been stored. You must call storeState() first
  31432. */
  31433. protected _restoreStateValues(): boolean;
  31434. /**
  31435. * Restored camera state. You must call storeState() first.
  31436. * @returns true if restored and false otherwise
  31437. */
  31438. restoreState(): boolean;
  31439. /**
  31440. * Gets the class name of the camera.
  31441. * @returns the class name
  31442. */
  31443. getClassName(): string;
  31444. /** @hidden */
  31445. readonly _isCamera: boolean;
  31446. /**
  31447. * Gets a string representation of the camera useful for debug purpose.
  31448. * @param fullDetails Defines that a more verboe level of logging is required
  31449. * @returns the string representation
  31450. */
  31451. toString(fullDetails?: boolean): string;
  31452. /**
  31453. * Gets the current world space position of the camera.
  31454. */
  31455. readonly globalPosition: Vector3;
  31456. /**
  31457. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31458. * @returns the active meshe list
  31459. */
  31460. getActiveMeshes(): SmartArray<AbstractMesh>;
  31461. /**
  31462. * Check wether a mesh is part of the current active mesh list of the camera
  31463. * @param mesh Defines the mesh to check
  31464. * @returns true if active, false otherwise
  31465. */
  31466. isActiveMesh(mesh: Mesh): boolean;
  31467. /**
  31468. * Is this camera ready to be used/rendered
  31469. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31470. * @return true if the camera is ready
  31471. */
  31472. isReady(completeCheck?: boolean): boolean;
  31473. /** @hidden */
  31474. _initCache(): void;
  31475. /** @hidden */
  31476. _updateCache(ignoreParentClass?: boolean): void;
  31477. /** @hidden */
  31478. _isSynchronized(): boolean;
  31479. /** @hidden */
  31480. _isSynchronizedViewMatrix(): boolean;
  31481. /** @hidden */
  31482. _isSynchronizedProjectionMatrix(): boolean;
  31483. /**
  31484. * Attach the input controls to a specific dom element to get the input from.
  31485. * @param element Defines the element the controls should be listened from
  31486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31487. */
  31488. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31489. /**
  31490. * Detach the current controls from the specified dom element.
  31491. * @param element Defines the element to stop listening the inputs from
  31492. */
  31493. detachControl(element: HTMLElement): void;
  31494. /**
  31495. * Update the camera state according to the different inputs gathered during the frame.
  31496. */
  31497. update(): void;
  31498. /** @hidden */
  31499. _checkInputs(): void;
  31500. /** @hidden */
  31501. readonly rigCameras: Camera[];
  31502. /**
  31503. * Gets the post process used by the rig cameras
  31504. */
  31505. readonly rigPostProcess: Nullable<PostProcess>;
  31506. /**
  31507. * Internal, gets the first post proces.
  31508. * @returns the first post process to be run on this camera.
  31509. */
  31510. _getFirstPostProcess(): Nullable<PostProcess>;
  31511. private _cascadePostProcessesToRigCams;
  31512. /**
  31513. * Attach a post process to the camera.
  31514. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31515. * @param postProcess The post process to attach to the camera
  31516. * @param insertAt The position of the post process in case several of them are in use in the scene
  31517. * @returns the position the post process has been inserted at
  31518. */
  31519. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31520. /**
  31521. * Detach a post process to the camera.
  31522. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31523. * @param postProcess The post process to detach from the camera
  31524. */
  31525. detachPostProcess(postProcess: PostProcess): void;
  31526. /**
  31527. * Gets the current world matrix of the camera
  31528. */
  31529. getWorldMatrix(): Matrix;
  31530. /** @hidden */
  31531. _getViewMatrix(): Matrix;
  31532. /**
  31533. * Gets the current view matrix of the camera.
  31534. * @param force forces the camera to recompute the matrix without looking at the cached state
  31535. * @returns the view matrix
  31536. */
  31537. getViewMatrix(force?: boolean): Matrix;
  31538. /**
  31539. * Freeze the projection matrix.
  31540. * It will prevent the cache check of the camera projection compute and can speed up perf
  31541. * if no parameter of the camera are meant to change
  31542. * @param projection Defines manually a projection if necessary
  31543. */
  31544. freezeProjectionMatrix(projection?: Matrix): void;
  31545. /**
  31546. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31547. */
  31548. unfreezeProjectionMatrix(): void;
  31549. /**
  31550. * Gets the current projection matrix of the camera.
  31551. * @param force forces the camera to recompute the matrix without looking at the cached state
  31552. * @returns the projection matrix
  31553. */
  31554. getProjectionMatrix(force?: boolean): Matrix;
  31555. /**
  31556. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31557. * @returns a Matrix
  31558. */
  31559. getTransformationMatrix(): Matrix;
  31560. private _updateFrustumPlanes;
  31561. /**
  31562. * Checks if a cullable object (mesh...) is in the camera frustum
  31563. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31564. * @param target The object to check
  31565. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31566. * @returns true if the object is in frustum otherwise false
  31567. */
  31568. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31569. /**
  31570. * Checks if a cullable object (mesh...) is in the camera frustum
  31571. * Unlike isInFrustum this cheks the full bounding box
  31572. * @param target The object to check
  31573. * @returns true if the object is in frustum otherwise false
  31574. */
  31575. isCompletelyInFrustum(target: ICullable): boolean;
  31576. /**
  31577. * Gets a ray in the forward direction from the camera.
  31578. * @param length Defines the length of the ray to create
  31579. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31580. * @param origin Defines the start point of the ray which defaults to the camera position
  31581. * @returns the forward ray
  31582. */
  31583. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31584. /**
  31585. * Releases resources associated with this node.
  31586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31588. */
  31589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31590. /** @hidden */
  31591. _isLeftCamera: boolean;
  31592. /**
  31593. * Gets the left camera of a rig setup in case of Rigged Camera
  31594. */
  31595. readonly isLeftCamera: boolean;
  31596. /** @hidden */
  31597. _isRightCamera: boolean;
  31598. /**
  31599. * Gets the right camera of a rig setup in case of Rigged Camera
  31600. */
  31601. readonly isRightCamera: boolean;
  31602. /**
  31603. * Gets the left camera of a rig setup in case of Rigged Camera
  31604. */
  31605. readonly leftCamera: Nullable<FreeCamera>;
  31606. /**
  31607. * Gets the right camera of a rig setup in case of Rigged Camera
  31608. */
  31609. readonly rightCamera: Nullable<FreeCamera>;
  31610. /**
  31611. * Gets the left camera target of a rig setup in case of Rigged Camera
  31612. * @returns the target position
  31613. */
  31614. getLeftTarget(): Nullable<Vector3>;
  31615. /**
  31616. * Gets the right camera target of a rig setup in case of Rigged Camera
  31617. * @returns the target position
  31618. */
  31619. getRightTarget(): Nullable<Vector3>;
  31620. /**
  31621. * @hidden
  31622. */
  31623. setCameraRigMode(mode: number, rigParams: any): void;
  31624. /** @hidden */
  31625. static _setStereoscopicRigMode(camera: Camera): void;
  31626. /** @hidden */
  31627. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31628. /** @hidden */
  31629. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31630. /** @hidden */
  31631. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31632. /** @hidden */
  31633. _getVRProjectionMatrix(): Matrix;
  31634. protected _updateCameraRotationMatrix(): void;
  31635. protected _updateWebVRCameraRotationMatrix(): void;
  31636. /**
  31637. * This function MUST be overwritten by the different WebVR cameras available.
  31638. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31639. * @hidden
  31640. */
  31641. _getWebVRProjectionMatrix(): Matrix;
  31642. /**
  31643. * This function MUST be overwritten by the different WebVR cameras available.
  31644. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31645. * @hidden
  31646. */
  31647. _getWebVRViewMatrix(): Matrix;
  31648. /** @hidden */
  31649. setCameraRigParameter(name: string, value: any): void;
  31650. /**
  31651. * needs to be overridden by children so sub has required properties to be copied
  31652. * @hidden
  31653. */
  31654. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31655. /**
  31656. * May need to be overridden by children
  31657. * @hidden
  31658. */
  31659. _updateRigCameras(): void;
  31660. /** @hidden */
  31661. _setupInputs(): void;
  31662. /**
  31663. * Serialiaze the camera setup to a json represention
  31664. * @returns the JSON representation
  31665. */
  31666. serialize(): any;
  31667. /**
  31668. * Clones the current camera.
  31669. * @param name The cloned camera name
  31670. * @returns the cloned camera
  31671. */
  31672. clone(name: string): Camera;
  31673. /**
  31674. * Gets the direction of the camera relative to a given local axis.
  31675. * @param localAxis Defines the reference axis to provide a relative direction.
  31676. * @return the direction
  31677. */
  31678. getDirection(localAxis: Vector3): Vector3;
  31679. /**
  31680. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31681. * @param localAxis Defines the reference axis to provide a relative direction.
  31682. * @param result Defines the vector to store the result in
  31683. */
  31684. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31685. /**
  31686. * Gets a camera constructor for a given camera type
  31687. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31688. * @param name The name of the camera the result will be able to instantiate
  31689. * @param scene The scene the result will construct the camera in
  31690. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31691. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31692. * @returns a factory method to construc the camera
  31693. */
  31694. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31695. /**
  31696. * Compute the world matrix of the camera.
  31697. * @returns the camera workd matrix
  31698. */
  31699. computeWorldMatrix(): Matrix;
  31700. /**
  31701. * Parse a JSON and creates the camera from the parsed information
  31702. * @param parsedCamera The JSON to parse
  31703. * @param scene The scene to instantiate the camera in
  31704. * @returns the newly constructed camera
  31705. */
  31706. static Parse(parsedCamera: any, scene: Scene): Camera;
  31707. }
  31708. }
  31709. declare module "babylonjs/Misc/tools" {
  31710. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31711. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31712. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31713. import { Observable } from "babylonjs/Misc/observable";
  31714. import { DomManagement } from "babylonjs/Misc/domManagement";
  31715. import { WebRequest } from "babylonjs/Misc/webRequest";
  31716. import { Camera } from "babylonjs/Cameras/camera";
  31717. import { Engine } from "babylonjs/Engines/engine";
  31718. import { Animation } from "babylonjs/Animations/animation";
  31719. /**
  31720. * Interface for any object that can request an animation frame
  31721. */
  31722. export interface ICustomAnimationFrameRequester {
  31723. /**
  31724. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31725. */
  31726. renderFunction?: Function;
  31727. /**
  31728. * Called to request the next frame to render to
  31729. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31730. */
  31731. requestAnimationFrame: Function;
  31732. /**
  31733. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31734. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31735. */
  31736. requestID?: number;
  31737. }
  31738. /**
  31739. * Interface containing an array of animations
  31740. */
  31741. export interface IAnimatable {
  31742. /**
  31743. * Array of animations
  31744. */
  31745. animations: Nullable<Array<Animation>>;
  31746. }
  31747. /** Interface used by value gradients (color, factor, ...) */
  31748. export interface IValueGradient {
  31749. /**
  31750. * Gets or sets the gradient value (between 0 and 1)
  31751. */
  31752. gradient: number;
  31753. }
  31754. /** Class used to store color4 gradient */
  31755. export class ColorGradient implements IValueGradient {
  31756. /**
  31757. * Gets or sets the gradient value (between 0 and 1)
  31758. */
  31759. gradient: number;
  31760. /**
  31761. * Gets or sets first associated color
  31762. */
  31763. color1: Color4;
  31764. /**
  31765. * Gets or sets second associated color
  31766. */
  31767. color2?: Color4;
  31768. /**
  31769. * Will get a color picked randomly between color1 and color2.
  31770. * If color2 is undefined then color1 will be used
  31771. * @param result defines the target Color4 to store the result in
  31772. */
  31773. getColorToRef(result: Color4): void;
  31774. }
  31775. /** Class used to store color 3 gradient */
  31776. export class Color3Gradient implements IValueGradient {
  31777. /**
  31778. * Gets or sets the gradient value (between 0 and 1)
  31779. */
  31780. gradient: number;
  31781. /**
  31782. * Gets or sets the associated color
  31783. */
  31784. color: Color3;
  31785. }
  31786. /** Class used to store factor gradient */
  31787. export class FactorGradient implements IValueGradient {
  31788. /**
  31789. * Gets or sets the gradient value (between 0 and 1)
  31790. */
  31791. gradient: number;
  31792. /**
  31793. * Gets or sets first associated factor
  31794. */
  31795. factor1: number;
  31796. /**
  31797. * Gets or sets second associated factor
  31798. */
  31799. factor2?: number;
  31800. /**
  31801. * Will get a number picked randomly between factor1 and factor2.
  31802. * If factor2 is undefined then factor1 will be used
  31803. * @returns the picked number
  31804. */
  31805. getFactor(): number;
  31806. }
  31807. /**
  31808. * @ignore
  31809. * Application error to support additional information when loading a file
  31810. */
  31811. export class LoadFileError extends Error {
  31812. /** defines the optional web request */
  31813. request?: WebRequest | undefined;
  31814. private static _setPrototypeOf;
  31815. /**
  31816. * Creates a new LoadFileError
  31817. * @param message defines the message of the error
  31818. * @param request defines the optional web request
  31819. */
  31820. constructor(message: string,
  31821. /** defines the optional web request */
  31822. request?: WebRequest | undefined);
  31823. }
  31824. /**
  31825. * Class used to define a retry strategy when error happens while loading assets
  31826. */
  31827. export class RetryStrategy {
  31828. /**
  31829. * Function used to defines an exponential back off strategy
  31830. * @param maxRetries defines the maximum number of retries (3 by default)
  31831. * @param baseInterval defines the interval between retries
  31832. * @returns the strategy function to use
  31833. */
  31834. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31835. }
  31836. /**
  31837. * File request interface
  31838. */
  31839. export interface IFileRequest {
  31840. /**
  31841. * Raised when the request is complete (success or error).
  31842. */
  31843. onCompleteObservable: Observable<IFileRequest>;
  31844. /**
  31845. * Aborts the request for a file.
  31846. */
  31847. abort: () => void;
  31848. }
  31849. /**
  31850. * Class containing a set of static utilities functions
  31851. */
  31852. export class Tools {
  31853. /**
  31854. * Gets or sets the base URL to use to load assets
  31855. */
  31856. static BaseUrl: string;
  31857. /**
  31858. * Enable/Disable Custom HTTP Request Headers globally.
  31859. * default = false
  31860. * @see CustomRequestHeaders
  31861. */
  31862. static UseCustomRequestHeaders: boolean;
  31863. /**
  31864. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31865. * i.e. when loading files, where the server/service expects an Authorization header
  31866. */
  31867. static CustomRequestHeaders: {
  31868. [key: string]: string;
  31869. };
  31870. /**
  31871. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31872. */
  31873. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31874. /**
  31875. * Default behaviour for cors in the application.
  31876. * It can be a string if the expected behavior is identical in the entire app.
  31877. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31878. */
  31879. static CorsBehavior: string | ((url: string | string[]) => string);
  31880. /**
  31881. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31882. * @ignorenaming
  31883. */
  31884. static UseFallbackTexture: boolean;
  31885. /**
  31886. * Use this object to register external classes like custom textures or material
  31887. * to allow the laoders to instantiate them
  31888. */
  31889. static RegisteredExternalClasses: {
  31890. [key: string]: Object;
  31891. };
  31892. /**
  31893. * Texture content used if a texture cannot loaded
  31894. * @ignorenaming
  31895. */
  31896. static fallbackTexture: string;
  31897. /**
  31898. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31899. * @param u defines the coordinate on X axis
  31900. * @param v defines the coordinate on Y axis
  31901. * @param width defines the width of the source data
  31902. * @param height defines the height of the source data
  31903. * @param pixels defines the source byte array
  31904. * @param color defines the output color
  31905. */
  31906. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31907. /**
  31908. * Interpolates between a and b via alpha
  31909. * @param a The lower value (returned when alpha = 0)
  31910. * @param b The upper value (returned when alpha = 1)
  31911. * @param alpha The interpolation-factor
  31912. * @return The mixed value
  31913. */
  31914. static Mix(a: number, b: number, alpha: number): number;
  31915. /**
  31916. * Tries to instantiate a new object from a given class name
  31917. * @param className defines the class name to instantiate
  31918. * @returns the new object or null if the system was not able to do the instantiation
  31919. */
  31920. static Instantiate(className: string): any;
  31921. /**
  31922. * Provides a slice function that will work even on IE
  31923. * @param data defines the array to slice
  31924. * @param start defines the start of the data (optional)
  31925. * @param end defines the end of the data (optional)
  31926. * @returns the new sliced array
  31927. */
  31928. static Slice<T>(data: T, start?: number, end?: number): T;
  31929. /**
  31930. * Polyfill for setImmediate
  31931. * @param action defines the action to execute after the current execution block
  31932. */
  31933. static SetImmediate(action: () => void): void;
  31934. /**
  31935. * Function indicating if a number is an exponent of 2
  31936. * @param value defines the value to test
  31937. * @returns true if the value is an exponent of 2
  31938. */
  31939. static IsExponentOfTwo(value: number): boolean;
  31940. private static _tmpFloatArray;
  31941. /**
  31942. * Returns the nearest 32-bit single precision float representation of a Number
  31943. * @param value A Number. If the parameter is of a different type, it will get converted
  31944. * to a number or to NaN if it cannot be converted
  31945. * @returns number
  31946. */
  31947. static FloatRound(value: number): number;
  31948. /**
  31949. * Find the next highest power of two.
  31950. * @param x Number to start search from.
  31951. * @return Next highest power of two.
  31952. */
  31953. static CeilingPOT(x: number): number;
  31954. /**
  31955. * Find the next lowest power of two.
  31956. * @param x Number to start search from.
  31957. * @return Next lowest power of two.
  31958. */
  31959. static FloorPOT(x: number): number;
  31960. /**
  31961. * Find the nearest power of two.
  31962. * @param x Number to start search from.
  31963. * @return Next nearest power of two.
  31964. */
  31965. static NearestPOT(x: number): number;
  31966. /**
  31967. * Get the closest exponent of two
  31968. * @param value defines the value to approximate
  31969. * @param max defines the maximum value to return
  31970. * @param mode defines how to define the closest value
  31971. * @returns closest exponent of two of the given value
  31972. */
  31973. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31974. /**
  31975. * Extracts the filename from a path
  31976. * @param path defines the path to use
  31977. * @returns the filename
  31978. */
  31979. static GetFilename(path: string): string;
  31980. /**
  31981. * Extracts the "folder" part of a path (everything before the filename).
  31982. * @param uri The URI to extract the info from
  31983. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31984. * @returns The "folder" part of the path
  31985. */
  31986. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31987. /**
  31988. * Extracts text content from a DOM element hierarchy
  31989. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31990. */
  31991. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31992. /**
  31993. * Convert an angle in radians to degrees
  31994. * @param angle defines the angle to convert
  31995. * @returns the angle in degrees
  31996. */
  31997. static ToDegrees(angle: number): number;
  31998. /**
  31999. * Convert an angle in degrees to radians
  32000. * @param angle defines the angle to convert
  32001. * @returns the angle in radians
  32002. */
  32003. static ToRadians(angle: number): number;
  32004. /**
  32005. * Encode a buffer to a base64 string
  32006. * @param buffer defines the buffer to encode
  32007. * @returns the encoded string
  32008. */
  32009. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32010. /**
  32011. * Extracts minimum and maximum values from a list of indexed positions
  32012. * @param positions defines the positions to use
  32013. * @param indices defines the indices to the positions
  32014. * @param indexStart defines the start index
  32015. * @param indexCount defines the end index
  32016. * @param bias defines bias value to add to the result
  32017. * @return minimum and maximum values
  32018. */
  32019. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32020. minimum: Vector3;
  32021. maximum: Vector3;
  32022. };
  32023. /**
  32024. * Extracts minimum and maximum values from a list of positions
  32025. * @param positions defines the positions to use
  32026. * @param start defines the start index in the positions array
  32027. * @param count defines the number of positions to handle
  32028. * @param bias defines bias value to add to the result
  32029. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32030. * @return minimum and maximum values
  32031. */
  32032. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32033. minimum: Vector3;
  32034. maximum: Vector3;
  32035. };
  32036. /**
  32037. * Returns an array if obj is not an array
  32038. * @param obj defines the object to evaluate as an array
  32039. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32040. * @returns either obj directly if obj is an array or a new array containing obj
  32041. */
  32042. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32043. /**
  32044. * Gets the pointer prefix to use
  32045. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32046. */
  32047. static GetPointerPrefix(): string;
  32048. /**
  32049. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32050. * @param func - the function to be called
  32051. * @param requester - the object that will request the next frame. Falls back to window.
  32052. * @returns frame number
  32053. */
  32054. static QueueNewFrame(func: () => void, requester?: any): number;
  32055. /**
  32056. * Ask the browser to promote the current element to fullscreen rendering mode
  32057. * @param element defines the DOM element to promote
  32058. */
  32059. static RequestFullscreen(element: HTMLElement): void;
  32060. /**
  32061. * Asks the browser to exit fullscreen mode
  32062. */
  32063. static ExitFullscreen(): void;
  32064. /**
  32065. * Ask the browser to promote the current element to pointerlock mode
  32066. * @param element defines the DOM element to promote
  32067. */
  32068. static RequestPointerlock(element: HTMLElement): void;
  32069. /**
  32070. * Asks the browser to exit pointerlock mode
  32071. */
  32072. static ExitPointerlock(): void;
  32073. /**
  32074. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32075. * @param url define the url we are trying
  32076. * @param element define the dom element where to configure the cors policy
  32077. */
  32078. static SetCorsBehavior(url: string | string[], element: {
  32079. crossOrigin: string | null;
  32080. }): void;
  32081. /**
  32082. * Removes unwanted characters from an url
  32083. * @param url defines the url to clean
  32084. * @returns the cleaned url
  32085. */
  32086. static CleanUrl(url: string): string;
  32087. /**
  32088. * Gets or sets a function used to pre-process url before using them to load assets
  32089. */
  32090. static PreprocessUrl: (url: string) => string;
  32091. /**
  32092. * Loads an image as an HTMLImageElement.
  32093. * @param input url string, ArrayBuffer, or Blob to load
  32094. * @param onLoad callback called when the image successfully loads
  32095. * @param onError callback called when the image fails to load
  32096. * @param offlineProvider offline provider for caching
  32097. * @returns the HTMLImageElement of the loaded image
  32098. */
  32099. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32100. /**
  32101. * Loads a file
  32102. * @param url url string, ArrayBuffer, or Blob to load
  32103. * @param onSuccess callback called when the file successfully loads
  32104. * @param onProgress callback called while file is loading (if the server supports this mode)
  32105. * @param offlineProvider defines the offline provider for caching
  32106. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32107. * @param onError callback called when the file fails to load
  32108. * @returns a file request object
  32109. */
  32110. 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;
  32111. /**
  32112. * Load a script (identified by an url). When the url returns, the
  32113. * content of this file is added into a new script element, attached to the DOM (body element)
  32114. * @param scriptUrl defines the url of the script to laod
  32115. * @param onSuccess defines the callback called when the script is loaded
  32116. * @param onError defines the callback to call if an error occurs
  32117. * @param scriptId defines the id of the script element
  32118. */
  32119. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32120. /**
  32121. * Load an asynchronous script (identified by an url). When the url returns, the
  32122. * content of this file is added into a new script element, attached to the DOM (body element)
  32123. * @param scriptUrl defines the url of the script to laod
  32124. * @param scriptId defines the id of the script element
  32125. * @returns a promise request object
  32126. */
  32127. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32128. /**
  32129. * Loads a file from a blob
  32130. * @param fileToLoad defines the blob to use
  32131. * @param callback defines the callback to call when data is loaded
  32132. * @param progressCallback defines the callback to call during loading process
  32133. * @returns a file request object
  32134. */
  32135. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32136. /**
  32137. * Loads a file
  32138. * @param fileToLoad defines the file to load
  32139. * @param callback defines the callback to call when data is loaded
  32140. * @param progressCallBack defines the callback to call during loading process
  32141. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32142. * @returns a file request object
  32143. */
  32144. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32145. /**
  32146. * Creates a data url from a given string content
  32147. * @param content defines the content to convert
  32148. * @returns the new data url link
  32149. */
  32150. static FileAsURL(content: string): string;
  32151. /**
  32152. * Format the given number to a specific decimal format
  32153. * @param value defines the number to format
  32154. * @param decimals defines the number of decimals to use
  32155. * @returns the formatted string
  32156. */
  32157. static Format(value: number, decimals?: number): string;
  32158. /**
  32159. * Checks if a given vector is inside a specific range
  32160. * @param v defines the vector to test
  32161. * @param min defines the minimum range
  32162. * @param max defines the maximum range
  32163. */
  32164. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32165. /**
  32166. * Tries to copy an object by duplicating every property
  32167. * @param source defines the source object
  32168. * @param destination defines the target object
  32169. * @param doNotCopyList defines a list of properties to avoid
  32170. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32171. */
  32172. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32173. /**
  32174. * Gets a boolean indicating if the given object has no own property
  32175. * @param obj defines the object to test
  32176. * @returns true if object has no own property
  32177. */
  32178. static IsEmpty(obj: any): boolean;
  32179. /**
  32180. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32181. * @param str Source string
  32182. * @param suffix Suffix to search for in the source string
  32183. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32184. */
  32185. static EndsWith(str: string, suffix: string): boolean;
  32186. /**
  32187. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32188. * @param str Source string
  32189. * @param suffix Suffix to search for in the source string
  32190. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32191. */
  32192. static StartsWith(str: string, suffix: string): boolean;
  32193. /**
  32194. * Function used to register events at window level
  32195. * @param events defines the events to register
  32196. */
  32197. static RegisterTopRootEvents(events: {
  32198. name: string;
  32199. handler: Nullable<(e: FocusEvent) => any>;
  32200. }[]): void;
  32201. /**
  32202. * Function used to unregister events from window level
  32203. * @param events defines the events to unregister
  32204. */
  32205. static UnregisterTopRootEvents(events: {
  32206. name: string;
  32207. handler: Nullable<(e: FocusEvent) => any>;
  32208. }[]): void;
  32209. /**
  32210. * @ignore
  32211. */
  32212. static _ScreenshotCanvas: HTMLCanvasElement;
  32213. /**
  32214. * Dumps the current bound framebuffer
  32215. * @param width defines the rendering width
  32216. * @param height defines the rendering height
  32217. * @param engine defines the hosting engine
  32218. * @param successCallback defines the callback triggered once the data are available
  32219. * @param mimeType defines the mime type of the result
  32220. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32221. */
  32222. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32223. /**
  32224. * Converts the canvas data to blob.
  32225. * This acts as a polyfill for browsers not supporting the to blob function.
  32226. * @param canvas Defines the canvas to extract the data from
  32227. * @param successCallback Defines the callback triggered once the data are available
  32228. * @param mimeType Defines the mime type of the result
  32229. */
  32230. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32231. /**
  32232. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32233. * @param successCallback defines the callback triggered once the data are available
  32234. * @param mimeType defines the mime type of the result
  32235. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32236. */
  32237. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32238. /**
  32239. * Downloads a blob in the browser
  32240. * @param blob defines the blob to download
  32241. * @param fileName defines the name of the downloaded file
  32242. */
  32243. static Download(blob: Blob, fileName: string): void;
  32244. /**
  32245. * Captures a screenshot of the current rendering
  32246. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32247. * @param engine defines the rendering engine
  32248. * @param camera defines the source camera
  32249. * @param size This parameter can be set to a single number or to an object with the
  32250. * following (optional) properties: precision, width, height. If a single number is passed,
  32251. * it will be used for both width and height. If an object is passed, the screenshot size
  32252. * will be derived from the parameters. The precision property is a multiplier allowing
  32253. * rendering at a higher or lower resolution
  32254. * @param successCallback defines the callback receives a single parameter which contains the
  32255. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32256. * src parameter of an <img> to display it
  32257. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32258. * Check your browser for supported MIME types
  32259. */
  32260. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32261. /**
  32262. * Generates an image screenshot from the specified camera.
  32263. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32264. * @param engine The engine to use for rendering
  32265. * @param camera The camera to use for rendering
  32266. * @param size This parameter can be set to a single number or to an object with the
  32267. * following (optional) properties: precision, width, height. If a single number is passed,
  32268. * it will be used for both width and height. If an object is passed, the screenshot size
  32269. * will be derived from the parameters. The precision property is a multiplier allowing
  32270. * rendering at a higher or lower resolution
  32271. * @param successCallback The callback receives a single parameter which contains the
  32272. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32273. * src parameter of an <img> to display it
  32274. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32275. * Check your browser for supported MIME types
  32276. * @param samples Texture samples (default: 1)
  32277. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32278. * @param fileName A name for for the downloaded file.
  32279. */
  32280. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32281. /**
  32282. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32283. * Be aware Math.random() could cause collisions, but:
  32284. * "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"
  32285. * @returns a pseudo random id
  32286. */
  32287. static RandomId(): string;
  32288. /**
  32289. * Test if the given uri is a base64 string
  32290. * @param uri The uri to test
  32291. * @return True if the uri is a base64 string or false otherwise
  32292. */
  32293. static IsBase64(uri: string): boolean;
  32294. /**
  32295. * Decode the given base64 uri.
  32296. * @param uri The uri to decode
  32297. * @return The decoded base64 data.
  32298. */
  32299. static DecodeBase64(uri: string): ArrayBuffer;
  32300. /**
  32301. * Gets the absolute url.
  32302. * @param url the input url
  32303. * @return the absolute url
  32304. */
  32305. static GetAbsoluteUrl(url: string): string;
  32306. /**
  32307. * No log
  32308. */
  32309. static readonly NoneLogLevel: number;
  32310. /**
  32311. * Only message logs
  32312. */
  32313. static readonly MessageLogLevel: number;
  32314. /**
  32315. * Only warning logs
  32316. */
  32317. static readonly WarningLogLevel: number;
  32318. /**
  32319. * Only error logs
  32320. */
  32321. static readonly ErrorLogLevel: number;
  32322. /**
  32323. * All logs
  32324. */
  32325. static readonly AllLogLevel: number;
  32326. /**
  32327. * Gets a value indicating the number of loading errors
  32328. * @ignorenaming
  32329. */
  32330. static readonly errorsCount: number;
  32331. /**
  32332. * Callback called when a new log is added
  32333. */
  32334. static OnNewCacheEntry: (entry: string) => void;
  32335. /**
  32336. * Log a message to the console
  32337. * @param message defines the message to log
  32338. */
  32339. static Log(message: string): void;
  32340. /**
  32341. * Write a warning message to the console
  32342. * @param message defines the message to log
  32343. */
  32344. static Warn(message: string): void;
  32345. /**
  32346. * Write an error message to the console
  32347. * @param message defines the message to log
  32348. */
  32349. static Error(message: string): void;
  32350. /**
  32351. * Gets current log cache (list of logs)
  32352. */
  32353. static readonly LogCache: string;
  32354. /**
  32355. * Clears the log cache
  32356. */
  32357. static ClearLogCache(): void;
  32358. /**
  32359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32360. */
  32361. static LogLevels: number;
  32362. /**
  32363. * Checks if the loaded document was accessed via `file:`-Protocol.
  32364. * @returns boolean
  32365. */
  32366. static IsFileURL(): boolean;
  32367. /**
  32368. * Checks if the window object exists
  32369. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32370. */
  32371. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32372. /**
  32373. * No performance log
  32374. */
  32375. static readonly PerformanceNoneLogLevel: number;
  32376. /**
  32377. * Use user marks to log performance
  32378. */
  32379. static readonly PerformanceUserMarkLogLevel: number;
  32380. /**
  32381. * Log performance to the console
  32382. */
  32383. static readonly PerformanceConsoleLogLevel: number;
  32384. private static _performance;
  32385. /**
  32386. * Sets the current performance log level
  32387. */
  32388. static PerformanceLogLevel: number;
  32389. private static _StartPerformanceCounterDisabled;
  32390. private static _EndPerformanceCounterDisabled;
  32391. private static _StartUserMark;
  32392. private static _EndUserMark;
  32393. private static _StartPerformanceConsole;
  32394. private static _EndPerformanceConsole;
  32395. /**
  32396. * Starts a performance counter
  32397. */
  32398. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32399. /**
  32400. * Ends a specific performance coutner
  32401. */
  32402. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32403. /**
  32404. * Gets either window.performance.now() if supported or Date.now() else
  32405. */
  32406. static readonly Now: number;
  32407. /**
  32408. * This method will return the name of the class used to create the instance of the given object.
  32409. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32410. * @param object the object to get the class name from
  32411. * @param isType defines if the object is actually a type
  32412. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32413. */
  32414. static GetClassName(object: any, isType?: boolean): string;
  32415. /**
  32416. * Gets the first element of an array satisfying a given predicate
  32417. * @param array defines the array to browse
  32418. * @param predicate defines the predicate to use
  32419. * @returns null if not found or the element
  32420. */
  32421. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32422. /**
  32423. * This method will return the name of the full name of the class, including its owning module (if any).
  32424. * 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).
  32425. * @param object the object to get the class name from
  32426. * @param isType defines if the object is actually a type
  32427. * @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.
  32428. * @ignorenaming
  32429. */
  32430. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32431. /**
  32432. * Returns a promise that resolves after the given amount of time.
  32433. * @param delay Number of milliseconds to delay
  32434. * @returns Promise that resolves after the given amount of time
  32435. */
  32436. static DelayAsync(delay: number): Promise<void>;
  32437. /**
  32438. * Gets the current gradient from an array of IValueGradient
  32439. * @param ratio defines the current ratio to get
  32440. * @param gradients defines the array of IValueGradient
  32441. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32442. */
  32443. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32444. }
  32445. /**
  32446. * This class is used to track a performance counter which is number based.
  32447. * The user has access to many properties which give statistics of different nature.
  32448. *
  32449. * The implementer can track two kinds of Performance Counter: time and count.
  32450. * 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.
  32451. * 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.
  32452. */
  32453. export class PerfCounter {
  32454. /**
  32455. * Gets or sets a global boolean to turn on and off all the counters
  32456. */
  32457. static Enabled: boolean;
  32458. /**
  32459. * Returns the smallest value ever
  32460. */
  32461. readonly min: number;
  32462. /**
  32463. * Returns the biggest value ever
  32464. */
  32465. readonly max: number;
  32466. /**
  32467. * Returns the average value since the performance counter is running
  32468. */
  32469. readonly average: number;
  32470. /**
  32471. * Returns the average value of the last second the counter was monitored
  32472. */
  32473. readonly lastSecAverage: number;
  32474. /**
  32475. * Returns the current value
  32476. */
  32477. readonly current: number;
  32478. /**
  32479. * Gets the accumulated total
  32480. */
  32481. readonly total: number;
  32482. /**
  32483. * Gets the total value count
  32484. */
  32485. readonly count: number;
  32486. /**
  32487. * Creates a new counter
  32488. */
  32489. constructor();
  32490. /**
  32491. * Call this method to start monitoring a new frame.
  32492. * 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.
  32493. */
  32494. fetchNewFrame(): void;
  32495. /**
  32496. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32497. * @param newCount the count value to add to the monitored count
  32498. * @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.
  32499. */
  32500. addCount(newCount: number, fetchResult: boolean): void;
  32501. /**
  32502. * Start monitoring this performance counter
  32503. */
  32504. beginMonitoring(): void;
  32505. /**
  32506. * Compute the time lapsed since the previous beginMonitoring() call.
  32507. * @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
  32508. */
  32509. endMonitoring(newFrame?: boolean): void;
  32510. private _fetchResult;
  32511. private _startMonitoringTime;
  32512. private _min;
  32513. private _max;
  32514. private _average;
  32515. private _current;
  32516. private _totalValueCount;
  32517. private _totalAccumulated;
  32518. private _lastSecAverage;
  32519. private _lastSecAccumulated;
  32520. private _lastSecTime;
  32521. private _lastSecValueCount;
  32522. }
  32523. /**
  32524. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32525. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32526. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32527. * @param name The name of the class, case should be preserved
  32528. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32529. */
  32530. export function className(name: string, module?: string): (target: Object) => void;
  32531. /**
  32532. * An implementation of a loop for asynchronous functions.
  32533. */
  32534. export class AsyncLoop {
  32535. /**
  32536. * Defines the number of iterations for the loop
  32537. */
  32538. iterations: number;
  32539. /**
  32540. * Defines the current index of the loop.
  32541. */
  32542. index: number;
  32543. private _done;
  32544. private _fn;
  32545. private _successCallback;
  32546. /**
  32547. * Constructor.
  32548. * @param iterations the number of iterations.
  32549. * @param func the function to run each iteration
  32550. * @param successCallback the callback that will be called upon succesful execution
  32551. * @param offset starting offset.
  32552. */
  32553. constructor(
  32554. /**
  32555. * Defines the number of iterations for the loop
  32556. */
  32557. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32558. /**
  32559. * Execute the next iteration. Must be called after the last iteration was finished.
  32560. */
  32561. executeNext(): void;
  32562. /**
  32563. * Break the loop and run the success callback.
  32564. */
  32565. breakLoop(): void;
  32566. /**
  32567. * Create and run an async loop.
  32568. * @param iterations the number of iterations.
  32569. * @param fn the function to run each iteration
  32570. * @param successCallback the callback that will be called upon succesful execution
  32571. * @param offset starting offset.
  32572. * @returns the created async loop object
  32573. */
  32574. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32575. /**
  32576. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32577. * @param iterations total number of iterations
  32578. * @param syncedIterations number of synchronous iterations in each async iteration.
  32579. * @param fn the function to call each iteration.
  32580. * @param callback a success call back that will be called when iterating stops.
  32581. * @param breakFunction a break condition (optional)
  32582. * @param timeout timeout settings for the setTimeout function. default - 0.
  32583. * @returns the created async loop object
  32584. */
  32585. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32586. }
  32587. }
  32588. declare module "babylonjs/Collisions/collisionCoordinator" {
  32589. import { Nullable } from "babylonjs/types";
  32590. import { Scene } from "babylonjs/scene";
  32591. import { Vector3 } from "babylonjs/Maths/math";
  32592. import { Collider } from "babylonjs/Collisions/collider";
  32593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32594. /** @hidden */
  32595. export interface ICollisionCoordinator {
  32596. createCollider(): Collider;
  32597. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32598. init(scene: Scene): void;
  32599. }
  32600. /** @hidden */
  32601. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32602. private _scene;
  32603. private _scaledPosition;
  32604. private _scaledVelocity;
  32605. private _finalPosition;
  32606. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32607. createCollider(): Collider;
  32608. init(scene: Scene): void;
  32609. private _collideWithWorld;
  32610. }
  32611. }
  32612. declare module "babylonjs/Inputs/scene.inputManager" {
  32613. import { Nullable } from "babylonjs/types";
  32614. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32615. import { Vector2 } from "babylonjs/Maths/math";
  32616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32617. import { Scene } from "babylonjs/scene";
  32618. /**
  32619. * Class used to manage all inputs for the scene.
  32620. */
  32621. export class InputManager {
  32622. /** The distance in pixel that you have to move to prevent some events */
  32623. static DragMovementThreshold: number;
  32624. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32625. static LongPressDelay: number;
  32626. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32627. static DoubleClickDelay: number;
  32628. /** If you need to check double click without raising a single click at first click, enable this flag */
  32629. static ExclusiveDoubleClickMode: boolean;
  32630. private _wheelEventName;
  32631. private _onPointerMove;
  32632. private _onPointerDown;
  32633. private _onPointerUp;
  32634. private _initClickEvent;
  32635. private _initActionManager;
  32636. private _delayedSimpleClick;
  32637. private _delayedSimpleClickTimeout;
  32638. private _previousDelayedSimpleClickTimeout;
  32639. private _meshPickProceed;
  32640. private _previousButtonPressed;
  32641. private _currentPickResult;
  32642. private _previousPickResult;
  32643. private _totalPointersPressed;
  32644. private _doubleClickOccured;
  32645. private _pointerOverMesh;
  32646. private _pickedDownMesh;
  32647. private _pickedUpMesh;
  32648. private _pointerX;
  32649. private _pointerY;
  32650. private _unTranslatedPointerX;
  32651. private _unTranslatedPointerY;
  32652. private _startingPointerPosition;
  32653. private _previousStartingPointerPosition;
  32654. private _startingPointerTime;
  32655. private _previousStartingPointerTime;
  32656. private _pointerCaptures;
  32657. private _onKeyDown;
  32658. private _onKeyUp;
  32659. private _onCanvasFocusObserver;
  32660. private _onCanvasBlurObserver;
  32661. private _scene;
  32662. /**
  32663. * Creates a new InputManager
  32664. * @param scene defines the hosting scene
  32665. */
  32666. constructor(scene: Scene);
  32667. /**
  32668. * Gets the mesh that is currently under the pointer
  32669. */
  32670. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32671. /**
  32672. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32673. */
  32674. readonly unTranslatedPointer: Vector2;
  32675. /**
  32676. * Gets or sets the current on-screen X position of the pointer
  32677. */
  32678. pointerX: number;
  32679. /**
  32680. * Gets or sets the current on-screen Y position of the pointer
  32681. */
  32682. pointerY: number;
  32683. private _updatePointerPosition;
  32684. private _processPointerMove;
  32685. private _setRayOnPointerInfo;
  32686. private _checkPrePointerObservable;
  32687. /**
  32688. * Use this method to simulate a pointer move on a mesh
  32689. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32690. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32691. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32692. */
  32693. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32694. /**
  32695. * Use this method to simulate a pointer down on a mesh
  32696. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32697. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32698. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32699. */
  32700. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32701. private _processPointerDown;
  32702. /** @hidden */
  32703. _isPointerSwiping(): boolean;
  32704. /**
  32705. * Use this method to simulate a pointer up on a mesh
  32706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32709. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32710. */
  32711. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32712. private _processPointerUp;
  32713. /**
  32714. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32715. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32716. * @returns true if the pointer was captured
  32717. */
  32718. isPointerCaptured(pointerId?: number): boolean;
  32719. /**
  32720. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32721. * @param attachUp defines if you want to attach events to pointerup
  32722. * @param attachDown defines if you want to attach events to pointerdown
  32723. * @param attachMove defines if you want to attach events to pointermove
  32724. */
  32725. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32726. /**
  32727. * Detaches all event handlers
  32728. */
  32729. detachControl(): void;
  32730. /**
  32731. * Force the value of meshUnderPointer
  32732. * @param mesh defines the mesh to use
  32733. */
  32734. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32735. /**
  32736. * Gets the mesh under the pointer
  32737. * @returns a Mesh or null if no mesh is under the pointer
  32738. */
  32739. getPointerOverMesh(): Nullable<AbstractMesh>;
  32740. }
  32741. }
  32742. declare module "babylonjs/Animations/animationGroup" {
  32743. import { Animatable } from "babylonjs/Animations/animatable";
  32744. import { Animation } from "babylonjs/Animations/animation";
  32745. import { Scene, IDisposable } from "babylonjs/scene";
  32746. import { Observable } from "babylonjs/Misc/observable";
  32747. import { Nullable } from "babylonjs/types";
  32748. import "babylonjs/Animations/animatable";
  32749. /**
  32750. * This class defines the direct association between an animation and a target
  32751. */
  32752. export class TargetedAnimation {
  32753. /**
  32754. * Animation to perform
  32755. */
  32756. animation: Animation;
  32757. /**
  32758. * Target to animate
  32759. */
  32760. target: any;
  32761. /**
  32762. * Serialize the object
  32763. * @returns the JSON object representing the current entity
  32764. */
  32765. serialize(): any;
  32766. }
  32767. /**
  32768. * Use this class to create coordinated animations on multiple targets
  32769. */
  32770. export class AnimationGroup implements IDisposable {
  32771. /** The name of the animation group */
  32772. name: string;
  32773. private _scene;
  32774. private _targetedAnimations;
  32775. private _animatables;
  32776. private _from;
  32777. private _to;
  32778. private _isStarted;
  32779. private _isPaused;
  32780. private _speedRatio;
  32781. private _loopAnimation;
  32782. /**
  32783. * Gets or sets the unique id of the node
  32784. */
  32785. uniqueId: number;
  32786. /**
  32787. * This observable will notify when one animation have ended
  32788. */
  32789. onAnimationEndObservable: Observable<TargetedAnimation>;
  32790. /**
  32791. * Observer raised when one animation loops
  32792. */
  32793. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32794. /**
  32795. * This observable will notify when all animations have ended.
  32796. */
  32797. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32798. /**
  32799. * This observable will notify when all animations have paused.
  32800. */
  32801. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32802. /**
  32803. * This observable will notify when all animations are playing.
  32804. */
  32805. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32806. /**
  32807. * Gets the first frame
  32808. */
  32809. readonly from: number;
  32810. /**
  32811. * Gets the last frame
  32812. */
  32813. readonly to: number;
  32814. /**
  32815. * Define if the animations are started
  32816. */
  32817. readonly isStarted: boolean;
  32818. /**
  32819. * Gets a value indicating that the current group is playing
  32820. */
  32821. readonly isPlaying: boolean;
  32822. /**
  32823. * Gets or sets the speed ratio to use for all animations
  32824. */
  32825. /**
  32826. * Gets or sets the speed ratio to use for all animations
  32827. */
  32828. speedRatio: number;
  32829. /**
  32830. * Gets or sets if all animations should loop or not
  32831. */
  32832. loopAnimation: boolean;
  32833. /**
  32834. * Gets the targeted animations for this animation group
  32835. */
  32836. readonly targetedAnimations: Array<TargetedAnimation>;
  32837. /**
  32838. * returning the list of animatables controlled by this animation group.
  32839. */
  32840. readonly animatables: Array<Animatable>;
  32841. /**
  32842. * Instantiates a new Animation Group.
  32843. * This helps managing several animations at once.
  32844. * @see http://doc.babylonjs.com/how_to/group
  32845. * @param name Defines the name of the group
  32846. * @param scene Defines the scene the group belongs to
  32847. */
  32848. constructor(
  32849. /** The name of the animation group */
  32850. name: string, scene?: Nullable<Scene>);
  32851. /**
  32852. * Add an animation (with its target) in the group
  32853. * @param animation defines the animation we want to add
  32854. * @param target defines the target of the animation
  32855. * @returns the TargetedAnimation object
  32856. */
  32857. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32858. /**
  32859. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32860. * It can add constant keys at begin or end
  32861. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32862. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32863. * @returns the animation group
  32864. */
  32865. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32866. /**
  32867. * Start all animations on given targets
  32868. * @param loop defines if animations must loop
  32869. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32870. * @param from defines the from key (optional)
  32871. * @param to defines the to key (optional)
  32872. * @returns the current animation group
  32873. */
  32874. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32875. /**
  32876. * Pause all animations
  32877. * @returns the animation group
  32878. */
  32879. pause(): AnimationGroup;
  32880. /**
  32881. * Play all animations to initial state
  32882. * This function will start() the animations if they were not started or will restart() them if they were paused
  32883. * @param loop defines if animations must loop
  32884. * @returns the animation group
  32885. */
  32886. play(loop?: boolean): AnimationGroup;
  32887. /**
  32888. * Reset all animations to initial state
  32889. * @returns the animation group
  32890. */
  32891. reset(): AnimationGroup;
  32892. /**
  32893. * Restart animations from key 0
  32894. * @returns the animation group
  32895. */
  32896. restart(): AnimationGroup;
  32897. /**
  32898. * Stop all animations
  32899. * @returns the animation group
  32900. */
  32901. stop(): AnimationGroup;
  32902. /**
  32903. * Set animation weight for all animatables
  32904. * @param weight defines the weight to use
  32905. * @return the animationGroup
  32906. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32907. */
  32908. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32909. /**
  32910. * Synchronize and normalize all animatables with a source animatable
  32911. * @param root defines the root animatable to synchronize with
  32912. * @return the animationGroup
  32913. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32914. */
  32915. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32916. /**
  32917. * Goes to a specific frame in this animation group
  32918. * @param frame the frame number to go to
  32919. * @return the animationGroup
  32920. */
  32921. goToFrame(frame: number): AnimationGroup;
  32922. /**
  32923. * Dispose all associated resources
  32924. */
  32925. dispose(): void;
  32926. private _checkAnimationGroupEnded;
  32927. /**
  32928. * Clone the current animation group and returns a copy
  32929. * @param newName defines the name of the new group
  32930. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32931. * @returns the new aniamtion group
  32932. */
  32933. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32934. /**
  32935. * Serializes the animationGroup to an object
  32936. * @returns Serialized object
  32937. */
  32938. serialize(): any;
  32939. /**
  32940. * Returns a new AnimationGroup object parsed from the source provided.
  32941. * @param parsedAnimationGroup defines the source
  32942. * @param scene defines the scene that will receive the animationGroup
  32943. * @returns a new AnimationGroup
  32944. */
  32945. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32946. /**
  32947. * Returns the string "AnimationGroup"
  32948. * @returns "AnimationGroup"
  32949. */
  32950. getClassName(): string;
  32951. /**
  32952. * Creates a detailled string about the object
  32953. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32954. * @returns a string representing the object
  32955. */
  32956. toString(fullDetails?: boolean): string;
  32957. }
  32958. }
  32959. declare module "babylonjs/scene" {
  32960. import { Nullable } from "babylonjs/types";
  32961. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32962. import { Observable } from "babylonjs/Misc/observable";
  32963. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32964. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32965. import { Geometry } from "babylonjs/Meshes/geometry";
  32966. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32969. import { Mesh } from "babylonjs/Meshes/mesh";
  32970. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32971. import { Bone } from "babylonjs/Bones/bone";
  32972. import { Skeleton } from "babylonjs/Bones/skeleton";
  32973. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32974. import { Camera } from "babylonjs/Cameras/camera";
  32975. import { AbstractScene } from "babylonjs/abstractScene";
  32976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32977. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32978. import { Material } from "babylonjs/Materials/material";
  32979. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32980. import { Effect } from "babylonjs/Materials/effect";
  32981. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32982. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32983. import { Light } from "babylonjs/Lights/light";
  32984. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32985. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32986. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32987. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32988. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32989. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32990. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32991. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32992. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32993. import { Engine } from "babylonjs/Engines/engine";
  32994. import { Node } from "babylonjs/node";
  32995. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32996. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32997. import { WebRequest } from "babylonjs/Misc/webRequest";
  32998. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32999. import { Ray } from "babylonjs/Culling/ray";
  33000. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33001. import { Animation } from "babylonjs/Animations/animation";
  33002. import { Animatable } from "babylonjs/Animations/animatable";
  33003. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33004. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33005. import { Collider } from "babylonjs/Collisions/collider";
  33006. /**
  33007. * Define an interface for all classes that will hold resources
  33008. */
  33009. export interface IDisposable {
  33010. /**
  33011. * Releases all held resources
  33012. */
  33013. dispose(): void;
  33014. }
  33015. /** Interface defining initialization parameters for Scene class */
  33016. export interface SceneOptions {
  33017. /**
  33018. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33019. * It will improve performance when the number of geometries becomes important.
  33020. */
  33021. useGeometryUniqueIdsMap?: boolean;
  33022. /**
  33023. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33024. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33025. */
  33026. useMaterialMeshMap?: boolean;
  33027. /**
  33028. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33029. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33030. */
  33031. useClonedMeshhMap?: boolean;
  33032. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33033. virtual?: boolean;
  33034. }
  33035. /**
  33036. * Represents a scene to be rendered by the engine.
  33037. * @see http://doc.babylonjs.com/features/scene
  33038. */
  33039. export class Scene extends AbstractScene implements IAnimatable {
  33040. private static _uniqueIdCounter;
  33041. /** The fog is deactivated */
  33042. static readonly FOGMODE_NONE: number;
  33043. /** The fog density is following an exponential function */
  33044. static readonly FOGMODE_EXP: number;
  33045. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33046. static readonly FOGMODE_EXP2: number;
  33047. /** The fog density is following a linear function. */
  33048. static readonly FOGMODE_LINEAR: number;
  33049. /**
  33050. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33051. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33052. */
  33053. static MinDeltaTime: number;
  33054. /**
  33055. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33056. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33057. */
  33058. static MaxDeltaTime: number;
  33059. /**
  33060. * Factory used to create the default material.
  33061. * @param name The name of the material to create
  33062. * @param scene The scene to create the material for
  33063. * @returns The default material
  33064. */
  33065. static DefaultMaterialFactory(scene: Scene): Material;
  33066. /**
  33067. * Factory used to create the a collision coordinator.
  33068. * @returns The collision coordinator
  33069. */
  33070. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33071. /** @hidden */
  33072. _inputManager: InputManager;
  33073. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33074. cameraToUseForPointers: Nullable<Camera>;
  33075. /** @hidden */
  33076. readonly _isScene: boolean;
  33077. /**
  33078. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33079. */
  33080. autoClear: boolean;
  33081. /**
  33082. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33083. */
  33084. autoClearDepthAndStencil: boolean;
  33085. /**
  33086. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33087. */
  33088. clearColor: Color4;
  33089. /**
  33090. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33091. */
  33092. ambientColor: Color3;
  33093. /**
  33094. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33095. * It should only be one of the following (if not the default embedded one):
  33096. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33097. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33098. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33099. * The material properties need to be setup according to the type of texture in use.
  33100. */
  33101. environmentBRDFTexture: BaseTexture;
  33102. /** @hidden */
  33103. protected _environmentTexture: Nullable<BaseTexture>;
  33104. /**
  33105. * Texture used in all pbr material as the reflection texture.
  33106. * As in the majority of the scene they are the same (exception for multi room and so on),
  33107. * this is easier to reference from here than from all the materials.
  33108. */
  33109. /**
  33110. * Texture used in all pbr material as the reflection texture.
  33111. * As in the majority of the scene they are the same (exception for multi room and so on),
  33112. * this is easier to set here than in all the materials.
  33113. */
  33114. environmentTexture: Nullable<BaseTexture>;
  33115. /** @hidden */
  33116. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33117. /**
  33118. * Default image processing configuration used either in the rendering
  33119. * Forward main pass or through the imageProcessingPostProcess if present.
  33120. * As in the majority of the scene they are the same (exception for multi camera),
  33121. * this is easier to reference from here than from all the materials and post process.
  33122. *
  33123. * No setter as we it is a shared configuration, you can set the values instead.
  33124. */
  33125. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33126. private _forceWireframe;
  33127. /**
  33128. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33129. */
  33130. forceWireframe: boolean;
  33131. private _forcePointsCloud;
  33132. /**
  33133. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33134. */
  33135. forcePointsCloud: boolean;
  33136. /**
  33137. * Gets or sets the active clipplane 1
  33138. */
  33139. clipPlane: Nullable<Plane>;
  33140. /**
  33141. * Gets or sets the active clipplane 2
  33142. */
  33143. clipPlane2: Nullable<Plane>;
  33144. /**
  33145. * Gets or sets the active clipplane 3
  33146. */
  33147. clipPlane3: Nullable<Plane>;
  33148. /**
  33149. * Gets or sets the active clipplane 4
  33150. */
  33151. clipPlane4: Nullable<Plane>;
  33152. /**
  33153. * Gets or sets a boolean indicating if animations are enabled
  33154. */
  33155. animationsEnabled: boolean;
  33156. private _animationPropertiesOverride;
  33157. /**
  33158. * Gets or sets the animation properties override
  33159. */
  33160. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33161. /**
  33162. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33163. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33164. */
  33165. useConstantAnimationDeltaTime: boolean;
  33166. /**
  33167. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33168. * Please note that it requires to run a ray cast through the scene on every frame
  33169. */
  33170. constantlyUpdateMeshUnderPointer: boolean;
  33171. /**
  33172. * Defines the HTML cursor to use when hovering over interactive elements
  33173. */
  33174. hoverCursor: string;
  33175. /**
  33176. * Defines the HTML default cursor to use (empty by default)
  33177. */
  33178. defaultCursor: string;
  33179. /**
  33180. * This is used to call preventDefault() on pointer down
  33181. * in order to block unwanted artifacts like system double clicks
  33182. */
  33183. preventDefaultOnPointerDown: boolean;
  33184. /**
  33185. * This is used to call preventDefault() on pointer up
  33186. * in order to block unwanted artifacts like system double clicks
  33187. */
  33188. preventDefaultOnPointerUp: boolean;
  33189. /**
  33190. * Gets or sets user defined metadata
  33191. */
  33192. metadata: any;
  33193. /**
  33194. * For internal use only. Please do not use.
  33195. */
  33196. reservedDataStore: any;
  33197. /**
  33198. * Gets the name of the plugin used to load this scene (null by default)
  33199. */
  33200. loadingPluginName: string;
  33201. /**
  33202. * Use this array to add regular expressions used to disable offline support for specific urls
  33203. */
  33204. disableOfflineSupportExceptionRules: RegExp[];
  33205. /**
  33206. * An event triggered when the scene is disposed.
  33207. */
  33208. onDisposeObservable: Observable<Scene>;
  33209. private _onDisposeObserver;
  33210. /** Sets a function to be executed when this scene is disposed. */
  33211. onDispose: () => void;
  33212. /**
  33213. * An event triggered before rendering the scene (right after animations and physics)
  33214. */
  33215. onBeforeRenderObservable: Observable<Scene>;
  33216. private _onBeforeRenderObserver;
  33217. /** Sets a function to be executed before rendering this scene */
  33218. beforeRender: Nullable<() => void>;
  33219. /**
  33220. * An event triggered after rendering the scene
  33221. */
  33222. onAfterRenderObservable: Observable<Scene>;
  33223. /**
  33224. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33225. */
  33226. onAfterRenderCameraObservable: Observable<Camera>;
  33227. private _onAfterRenderObserver;
  33228. /** Sets a function to be executed after rendering this scene */
  33229. afterRender: Nullable<() => void>;
  33230. /**
  33231. * An event triggered before animating the scene
  33232. */
  33233. onBeforeAnimationsObservable: Observable<Scene>;
  33234. /**
  33235. * An event triggered after animations processing
  33236. */
  33237. onAfterAnimationsObservable: Observable<Scene>;
  33238. /**
  33239. * An event triggered before draw calls are ready to be sent
  33240. */
  33241. onBeforeDrawPhaseObservable: Observable<Scene>;
  33242. /**
  33243. * An event triggered after draw calls have been sent
  33244. */
  33245. onAfterDrawPhaseObservable: Observable<Scene>;
  33246. /**
  33247. * An event triggered when the scene is ready
  33248. */
  33249. onReadyObservable: Observable<Scene>;
  33250. /**
  33251. * An event triggered before rendering a camera
  33252. */
  33253. onBeforeCameraRenderObservable: Observable<Camera>;
  33254. private _onBeforeCameraRenderObserver;
  33255. /** Sets a function to be executed before rendering a camera*/
  33256. beforeCameraRender: () => void;
  33257. /**
  33258. * An event triggered after rendering a camera
  33259. */
  33260. onAfterCameraRenderObservable: Observable<Camera>;
  33261. private _onAfterCameraRenderObserver;
  33262. /** Sets a function to be executed after rendering a camera*/
  33263. afterCameraRender: () => void;
  33264. /**
  33265. * An event triggered when active meshes evaluation is about to start
  33266. */
  33267. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33268. /**
  33269. * An event triggered when active meshes evaluation is done
  33270. */
  33271. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33272. /**
  33273. * An event triggered when particles rendering is about to start
  33274. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33275. */
  33276. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33277. /**
  33278. * An event triggered when particles rendering is done
  33279. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33280. */
  33281. onAfterParticlesRenderingObservable: Observable<Scene>;
  33282. /**
  33283. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33284. */
  33285. onDataLoadedObservable: Observable<Scene>;
  33286. /**
  33287. * An event triggered when a camera is created
  33288. */
  33289. onNewCameraAddedObservable: Observable<Camera>;
  33290. /**
  33291. * An event triggered when a camera is removed
  33292. */
  33293. onCameraRemovedObservable: Observable<Camera>;
  33294. /**
  33295. * An event triggered when a light is created
  33296. */
  33297. onNewLightAddedObservable: Observable<Light>;
  33298. /**
  33299. * An event triggered when a light is removed
  33300. */
  33301. onLightRemovedObservable: Observable<Light>;
  33302. /**
  33303. * An event triggered when a geometry is created
  33304. */
  33305. onNewGeometryAddedObservable: Observable<Geometry>;
  33306. /**
  33307. * An event triggered when a geometry is removed
  33308. */
  33309. onGeometryRemovedObservable: Observable<Geometry>;
  33310. /**
  33311. * An event triggered when a transform node is created
  33312. */
  33313. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33314. /**
  33315. * An event triggered when a transform node is removed
  33316. */
  33317. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33318. /**
  33319. * An event triggered when a mesh is created
  33320. */
  33321. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33322. /**
  33323. * An event triggered when a mesh is removed
  33324. */
  33325. onMeshRemovedObservable: Observable<AbstractMesh>;
  33326. /**
  33327. * An event triggered when a skeleton is created
  33328. */
  33329. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33330. /**
  33331. * An event triggered when a skeleton is removed
  33332. */
  33333. onSkeletonRemovedObservable: Observable<Skeleton>;
  33334. /**
  33335. * An event triggered when a material is created
  33336. */
  33337. onNewMaterialAddedObservable: Observable<Material>;
  33338. /**
  33339. * An event triggered when a material is removed
  33340. */
  33341. onMaterialRemovedObservable: Observable<Material>;
  33342. /**
  33343. * An event triggered when a texture is created
  33344. */
  33345. onNewTextureAddedObservable: Observable<BaseTexture>;
  33346. /**
  33347. * An event triggered when a texture is removed
  33348. */
  33349. onTextureRemovedObservable: Observable<BaseTexture>;
  33350. /**
  33351. * An event triggered when render targets are about to be rendered
  33352. * Can happen multiple times per frame.
  33353. */
  33354. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33355. /**
  33356. * An event triggered when render targets were rendered.
  33357. * Can happen multiple times per frame.
  33358. */
  33359. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33360. /**
  33361. * An event triggered before calculating deterministic simulation step
  33362. */
  33363. onBeforeStepObservable: Observable<Scene>;
  33364. /**
  33365. * An event triggered after calculating deterministic simulation step
  33366. */
  33367. onAfterStepObservable: Observable<Scene>;
  33368. /**
  33369. * An event triggered when the activeCamera property is updated
  33370. */
  33371. onActiveCameraChanged: Observable<Scene>;
  33372. /**
  33373. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33374. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33375. * 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)
  33376. */
  33377. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33378. /**
  33379. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33380. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33381. * 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)
  33382. */
  33383. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33384. /**
  33385. * This Observable will when a mesh has been imported into the scene.
  33386. */
  33387. onMeshImportedObservable: Observable<AbstractMesh>;
  33388. /**
  33389. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33390. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33391. */
  33392. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33393. /** @hidden */
  33394. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33395. /**
  33396. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33397. */
  33398. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33399. /**
  33400. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33401. */
  33402. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33403. /**
  33404. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33405. */
  33406. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33407. /** Callback called when a pointer move is detected */
  33408. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33409. /** Callback called when a pointer down is detected */
  33410. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33411. /** Callback called when a pointer up is detected */
  33412. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33413. /** Callback called when a pointer pick is detected */
  33414. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33415. /**
  33416. * 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).
  33417. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33418. */
  33419. onPrePointerObservable: Observable<PointerInfoPre>;
  33420. /**
  33421. * Observable event triggered each time an input event is received from the rendering canvas
  33422. */
  33423. onPointerObservable: Observable<PointerInfo>;
  33424. /**
  33425. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33426. */
  33427. readonly unTranslatedPointer: Vector2;
  33428. /**
  33429. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33430. */
  33431. static DragMovementThreshold: number;
  33432. /**
  33433. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33434. */
  33435. static LongPressDelay: number;
  33436. /**
  33437. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33438. */
  33439. static DoubleClickDelay: number;
  33440. /** If you need to check double click without raising a single click at first click, enable this flag */
  33441. static ExclusiveDoubleClickMode: boolean;
  33442. /** @hidden */
  33443. _mirroredCameraPosition: Nullable<Vector3>;
  33444. /**
  33445. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33446. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33447. */
  33448. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33449. /**
  33450. * Observable event triggered each time an keyboard event is received from the hosting window
  33451. */
  33452. onKeyboardObservable: Observable<KeyboardInfo>;
  33453. private _useRightHandedSystem;
  33454. /**
  33455. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33456. */
  33457. useRightHandedSystem: boolean;
  33458. private _timeAccumulator;
  33459. private _currentStepId;
  33460. private _currentInternalStep;
  33461. /**
  33462. * Sets the step Id used by deterministic lock step
  33463. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33464. * @param newStepId defines the step Id
  33465. */
  33466. setStepId(newStepId: number): void;
  33467. /**
  33468. * Gets the step Id used by deterministic lock step
  33469. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33470. * @returns the step Id
  33471. */
  33472. getStepId(): number;
  33473. /**
  33474. * Gets the internal step used by deterministic lock step
  33475. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33476. * @returns the internal step
  33477. */
  33478. getInternalStep(): number;
  33479. private _fogEnabled;
  33480. /**
  33481. * Gets or sets a boolean indicating if fog is enabled on this scene
  33482. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33483. * (Default is true)
  33484. */
  33485. fogEnabled: boolean;
  33486. private _fogMode;
  33487. /**
  33488. * Gets or sets the fog mode to use
  33489. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33490. * | mode | value |
  33491. * | --- | --- |
  33492. * | FOGMODE_NONE | 0 |
  33493. * | FOGMODE_EXP | 1 |
  33494. * | FOGMODE_EXP2 | 2 |
  33495. * | FOGMODE_LINEAR | 3 |
  33496. */
  33497. fogMode: number;
  33498. /**
  33499. * Gets or sets the fog color to use
  33500. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33501. * (Default is Color3(0.2, 0.2, 0.3))
  33502. */
  33503. fogColor: Color3;
  33504. /**
  33505. * Gets or sets the fog density to use
  33506. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33507. * (Default is 0.1)
  33508. */
  33509. fogDensity: number;
  33510. /**
  33511. * Gets or sets the fog start distance to use
  33512. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33513. * (Default is 0)
  33514. */
  33515. fogStart: number;
  33516. /**
  33517. * Gets or sets the fog end distance to use
  33518. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33519. * (Default is 1000)
  33520. */
  33521. fogEnd: number;
  33522. private _shadowsEnabled;
  33523. /**
  33524. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33525. */
  33526. shadowsEnabled: boolean;
  33527. private _lightsEnabled;
  33528. /**
  33529. * Gets or sets a boolean indicating if lights are enabled on this scene
  33530. */
  33531. lightsEnabled: boolean;
  33532. /** All of the active cameras added to this scene. */
  33533. activeCameras: Camera[];
  33534. /** @hidden */
  33535. _activeCamera: Nullable<Camera>;
  33536. /** Gets or sets the current active camera */
  33537. activeCamera: Nullable<Camera>;
  33538. private _defaultMaterial;
  33539. /** The default material used on meshes when no material is affected */
  33540. /** The default material used on meshes when no material is affected */
  33541. defaultMaterial: Material;
  33542. private _texturesEnabled;
  33543. /**
  33544. * Gets or sets a boolean indicating if textures are enabled on this scene
  33545. */
  33546. texturesEnabled: boolean;
  33547. /**
  33548. * Gets or sets a boolean indicating if particles are enabled on this scene
  33549. */
  33550. particlesEnabled: boolean;
  33551. /**
  33552. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33553. */
  33554. spritesEnabled: boolean;
  33555. private _skeletonsEnabled;
  33556. /**
  33557. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33558. */
  33559. skeletonsEnabled: boolean;
  33560. /**
  33561. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33562. */
  33563. lensFlaresEnabled: boolean;
  33564. /**
  33565. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33566. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33567. */
  33568. collisionsEnabled: boolean;
  33569. private _collisionCoordinator;
  33570. /** @hidden */
  33571. readonly collisionCoordinator: ICollisionCoordinator;
  33572. /**
  33573. * Defines the gravity applied to this scene (used only for collisions)
  33574. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33575. */
  33576. gravity: Vector3;
  33577. /**
  33578. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33579. */
  33580. postProcessesEnabled: boolean;
  33581. /**
  33582. * The list of postprocesses added to the scene
  33583. */
  33584. postProcesses: PostProcess[];
  33585. /**
  33586. * Gets the current postprocess manager
  33587. */
  33588. postProcessManager: PostProcessManager;
  33589. /**
  33590. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33591. */
  33592. renderTargetsEnabled: boolean;
  33593. /**
  33594. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33595. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33596. */
  33597. dumpNextRenderTargets: boolean;
  33598. /**
  33599. * The list of user defined render targets added to the scene
  33600. */
  33601. customRenderTargets: RenderTargetTexture[];
  33602. /**
  33603. * Defines if texture loading must be delayed
  33604. * If true, textures will only be loaded when they need to be rendered
  33605. */
  33606. useDelayedTextureLoading: boolean;
  33607. /**
  33608. * Gets the list of meshes imported to the scene through SceneLoader
  33609. */
  33610. importedMeshesFiles: String[];
  33611. /**
  33612. * Gets or sets a boolean indicating if probes are enabled on this scene
  33613. */
  33614. probesEnabled: boolean;
  33615. /**
  33616. * Gets or sets the current offline provider to use to store scene data
  33617. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33618. */
  33619. offlineProvider: IOfflineProvider;
  33620. /**
  33621. * Gets or sets the action manager associated with the scene
  33622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33623. */
  33624. actionManager: AbstractActionManager;
  33625. private _meshesForIntersections;
  33626. /**
  33627. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33628. */
  33629. proceduralTexturesEnabled: boolean;
  33630. private _engine;
  33631. private _totalVertices;
  33632. /** @hidden */
  33633. _activeIndices: PerfCounter;
  33634. /** @hidden */
  33635. _activeParticles: PerfCounter;
  33636. /** @hidden */
  33637. _activeBones: PerfCounter;
  33638. private _animationRatio;
  33639. /** @hidden */
  33640. _animationTimeLast: number;
  33641. /** @hidden */
  33642. _animationTime: number;
  33643. /**
  33644. * Gets or sets a general scale for animation speed
  33645. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33646. */
  33647. animationTimeScale: number;
  33648. /** @hidden */
  33649. _cachedMaterial: Nullable<Material>;
  33650. /** @hidden */
  33651. _cachedEffect: Nullable<Effect>;
  33652. /** @hidden */
  33653. _cachedVisibility: Nullable<number>;
  33654. private _renderId;
  33655. private _frameId;
  33656. private _executeWhenReadyTimeoutId;
  33657. private _intermediateRendering;
  33658. private _viewUpdateFlag;
  33659. private _projectionUpdateFlag;
  33660. /** @hidden */
  33661. _toBeDisposed: Nullable<IDisposable>[];
  33662. private _activeRequests;
  33663. /** @hidden */
  33664. _pendingData: any[];
  33665. private _isDisposed;
  33666. /**
  33667. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33668. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33669. */
  33670. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33671. private _activeMeshes;
  33672. private _processedMaterials;
  33673. private _renderTargets;
  33674. /** @hidden */
  33675. _activeParticleSystems: SmartArray<IParticleSystem>;
  33676. private _activeSkeletons;
  33677. private _softwareSkinnedMeshes;
  33678. private _renderingManager;
  33679. /** @hidden */
  33680. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33681. private _transformMatrix;
  33682. private _sceneUbo;
  33683. /** @hidden */
  33684. _viewMatrix: Matrix;
  33685. private _projectionMatrix;
  33686. /** @hidden */
  33687. _forcedViewPosition: Nullable<Vector3>;
  33688. /** @hidden */
  33689. _frustumPlanes: Plane[];
  33690. /**
  33691. * Gets the list of frustum planes (built from the active camera)
  33692. */
  33693. readonly frustumPlanes: Plane[];
  33694. /**
  33695. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33696. * This is useful if there are more lights that the maximum simulteanous authorized
  33697. */
  33698. requireLightSorting: boolean;
  33699. /** @hidden */
  33700. readonly useMaterialMeshMap: boolean;
  33701. /** @hidden */
  33702. readonly useClonedMeshhMap: boolean;
  33703. private _externalData;
  33704. private _uid;
  33705. /**
  33706. * @hidden
  33707. * Backing store of defined scene components.
  33708. */
  33709. _components: ISceneComponent[];
  33710. /**
  33711. * @hidden
  33712. * Backing store of defined scene components.
  33713. */
  33714. _serializableComponents: ISceneSerializableComponent[];
  33715. /**
  33716. * List of components to register on the next registration step.
  33717. */
  33718. private _transientComponents;
  33719. /**
  33720. * Registers the transient components if needed.
  33721. */
  33722. private _registerTransientComponents;
  33723. /**
  33724. * @hidden
  33725. * Add a component to the scene.
  33726. * Note that the ccomponent could be registered on th next frame if this is called after
  33727. * the register component stage.
  33728. * @param component Defines the component to add to the scene
  33729. */
  33730. _addComponent(component: ISceneComponent): void;
  33731. /**
  33732. * @hidden
  33733. * Gets a component from the scene.
  33734. * @param name defines the name of the component to retrieve
  33735. * @returns the component or null if not present
  33736. */
  33737. _getComponent(name: string): Nullable<ISceneComponent>;
  33738. /**
  33739. * @hidden
  33740. * Defines the actions happening before camera updates.
  33741. */
  33742. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33743. /**
  33744. * @hidden
  33745. * Defines the actions happening before clear the canvas.
  33746. */
  33747. _beforeClearStage: Stage<SimpleStageAction>;
  33748. /**
  33749. * @hidden
  33750. * Defines the actions when collecting render targets for the frame.
  33751. */
  33752. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33753. /**
  33754. * @hidden
  33755. * Defines the actions happening for one camera in the frame.
  33756. */
  33757. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33758. /**
  33759. * @hidden
  33760. * Defines the actions happening during the per mesh ready checks.
  33761. */
  33762. _isReadyForMeshStage: Stage<MeshStageAction>;
  33763. /**
  33764. * @hidden
  33765. * Defines the actions happening before evaluate active mesh checks.
  33766. */
  33767. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33768. /**
  33769. * @hidden
  33770. * Defines the actions happening during the evaluate sub mesh checks.
  33771. */
  33772. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33773. /**
  33774. * @hidden
  33775. * Defines the actions happening during the active mesh stage.
  33776. */
  33777. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33778. /**
  33779. * @hidden
  33780. * Defines the actions happening during the per camera render target step.
  33781. */
  33782. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33783. /**
  33784. * @hidden
  33785. * Defines the actions happening just before the active camera is drawing.
  33786. */
  33787. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33788. /**
  33789. * @hidden
  33790. * Defines the actions happening just before a render target is drawing.
  33791. */
  33792. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33793. /**
  33794. * @hidden
  33795. * Defines the actions happening just before a rendering group is drawing.
  33796. */
  33797. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33798. /**
  33799. * @hidden
  33800. * Defines the actions happening just before a mesh is drawing.
  33801. */
  33802. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33803. /**
  33804. * @hidden
  33805. * Defines the actions happening just after a mesh has been drawn.
  33806. */
  33807. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33808. /**
  33809. * @hidden
  33810. * Defines the actions happening just after a rendering group has been drawn.
  33811. */
  33812. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33813. /**
  33814. * @hidden
  33815. * Defines the actions happening just after the active camera has been drawn.
  33816. */
  33817. _afterCameraDrawStage: Stage<CameraStageAction>;
  33818. /**
  33819. * @hidden
  33820. * Defines the actions happening just after a render target has been drawn.
  33821. */
  33822. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33823. /**
  33824. * @hidden
  33825. * Defines the actions happening just after rendering all cameras and computing intersections.
  33826. */
  33827. _afterRenderStage: Stage<SimpleStageAction>;
  33828. /**
  33829. * @hidden
  33830. * Defines the actions happening when a pointer move event happens.
  33831. */
  33832. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33833. /**
  33834. * @hidden
  33835. * Defines the actions happening when a pointer down event happens.
  33836. */
  33837. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33838. /**
  33839. * @hidden
  33840. * Defines the actions happening when a pointer up event happens.
  33841. */
  33842. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33843. /**
  33844. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33845. */
  33846. private geometriesByUniqueId;
  33847. /**
  33848. * Creates a new Scene
  33849. * @param engine defines the engine to use to render this scene
  33850. * @param options defines the scene options
  33851. */
  33852. constructor(engine: Engine, options?: SceneOptions);
  33853. /**
  33854. * Gets a string idenfifying the name of the class
  33855. * @returns "Scene" string
  33856. */
  33857. getClassName(): string;
  33858. private _defaultMeshCandidates;
  33859. /**
  33860. * @hidden
  33861. */
  33862. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33863. private _defaultSubMeshCandidates;
  33864. /**
  33865. * @hidden
  33866. */
  33867. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33868. /**
  33869. * Sets the default candidate providers for the scene.
  33870. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33871. * and getCollidingSubMeshCandidates to their default function
  33872. */
  33873. setDefaultCandidateProviders(): void;
  33874. /**
  33875. * Gets the mesh that is currently under the pointer
  33876. */
  33877. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33878. /**
  33879. * Gets or sets the current on-screen X position of the pointer
  33880. */
  33881. pointerX: number;
  33882. /**
  33883. * Gets or sets the current on-screen Y position of the pointer
  33884. */
  33885. pointerY: number;
  33886. /**
  33887. * Gets the cached material (ie. the latest rendered one)
  33888. * @returns the cached material
  33889. */
  33890. getCachedMaterial(): Nullable<Material>;
  33891. /**
  33892. * Gets the cached effect (ie. the latest rendered one)
  33893. * @returns the cached effect
  33894. */
  33895. getCachedEffect(): Nullable<Effect>;
  33896. /**
  33897. * Gets the cached visibility state (ie. the latest rendered one)
  33898. * @returns the cached visibility state
  33899. */
  33900. getCachedVisibility(): Nullable<number>;
  33901. /**
  33902. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33903. * @param material defines the current material
  33904. * @param effect defines the current effect
  33905. * @param visibility defines the current visibility state
  33906. * @returns true if one parameter is not cached
  33907. */
  33908. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33909. /**
  33910. * Gets the engine associated with the scene
  33911. * @returns an Engine
  33912. */
  33913. getEngine(): Engine;
  33914. /**
  33915. * Gets the total number of vertices rendered per frame
  33916. * @returns the total number of vertices rendered per frame
  33917. */
  33918. getTotalVertices(): number;
  33919. /**
  33920. * Gets the performance counter for total vertices
  33921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33922. */
  33923. readonly totalVerticesPerfCounter: PerfCounter;
  33924. /**
  33925. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33926. * @returns the total number of active indices rendered per frame
  33927. */
  33928. getActiveIndices(): number;
  33929. /**
  33930. * Gets the performance counter for active indices
  33931. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33932. */
  33933. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33934. /**
  33935. * Gets the total number of active particles rendered per frame
  33936. * @returns the total number of active particles rendered per frame
  33937. */
  33938. getActiveParticles(): number;
  33939. /**
  33940. * Gets the performance counter for active particles
  33941. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33942. */
  33943. readonly activeParticlesPerfCounter: PerfCounter;
  33944. /**
  33945. * Gets the total number of active bones rendered per frame
  33946. * @returns the total number of active bones rendered per frame
  33947. */
  33948. getActiveBones(): number;
  33949. /**
  33950. * Gets the performance counter for active bones
  33951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33952. */
  33953. readonly activeBonesPerfCounter: PerfCounter;
  33954. /**
  33955. * Gets the array of active meshes
  33956. * @returns an array of AbstractMesh
  33957. */
  33958. getActiveMeshes(): SmartArray<AbstractMesh>;
  33959. /**
  33960. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33961. * @returns a number
  33962. */
  33963. getAnimationRatio(): number;
  33964. /**
  33965. * Gets an unique Id for the current render phase
  33966. * @returns a number
  33967. */
  33968. getRenderId(): number;
  33969. /**
  33970. * Gets an unique Id for the current frame
  33971. * @returns a number
  33972. */
  33973. getFrameId(): number;
  33974. /** Call this function if you want to manually increment the render Id*/
  33975. incrementRenderId(): void;
  33976. private _createUbo;
  33977. /**
  33978. * Use this method to simulate a pointer move on a mesh
  33979. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33980. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33981. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33982. * @returns the current scene
  33983. */
  33984. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33985. /**
  33986. * Use this method to simulate a pointer down on a mesh
  33987. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33988. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33989. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33990. * @returns the current scene
  33991. */
  33992. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33993. /**
  33994. * Use this method to simulate a pointer up on a mesh
  33995. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33996. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33997. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33998. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33999. * @returns the current scene
  34000. */
  34001. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34002. /**
  34003. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34004. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34005. * @returns true if the pointer was captured
  34006. */
  34007. isPointerCaptured(pointerId?: number): boolean;
  34008. /**
  34009. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34010. * @param attachUp defines if you want to attach events to pointerup
  34011. * @param attachDown defines if you want to attach events to pointerdown
  34012. * @param attachMove defines if you want to attach events to pointermove
  34013. */
  34014. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34015. /** Detaches all event handlers*/
  34016. detachControl(): void;
  34017. /**
  34018. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34019. * Delay loaded resources are not taking in account
  34020. * @return true if all required resources are ready
  34021. */
  34022. isReady(): boolean;
  34023. /** Resets all cached information relative to material (including effect and visibility) */
  34024. resetCachedMaterial(): void;
  34025. /**
  34026. * Registers a function to be called before every frame render
  34027. * @param func defines the function to register
  34028. */
  34029. registerBeforeRender(func: () => void): void;
  34030. /**
  34031. * Unregisters a function called before every frame render
  34032. * @param func defines the function to unregister
  34033. */
  34034. unregisterBeforeRender(func: () => void): void;
  34035. /**
  34036. * Registers a function to be called after every frame render
  34037. * @param func defines the function to register
  34038. */
  34039. registerAfterRender(func: () => void): void;
  34040. /**
  34041. * Unregisters a function called after every frame render
  34042. * @param func defines the function to unregister
  34043. */
  34044. unregisterAfterRender(func: () => void): void;
  34045. private _executeOnceBeforeRender;
  34046. /**
  34047. * The provided function will run before render once and will be disposed afterwards.
  34048. * A timeout delay can be provided so that the function will be executed in N ms.
  34049. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34050. * @param func The function to be executed.
  34051. * @param timeout optional delay in ms
  34052. */
  34053. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34054. /** @hidden */
  34055. _addPendingData(data: any): void;
  34056. /** @hidden */
  34057. _removePendingData(data: any): void;
  34058. /**
  34059. * Returns the number of items waiting to be loaded
  34060. * @returns the number of items waiting to be loaded
  34061. */
  34062. getWaitingItemsCount(): number;
  34063. /**
  34064. * Returns a boolean indicating if the scene is still loading data
  34065. */
  34066. readonly isLoading: boolean;
  34067. /**
  34068. * Registers a function to be executed when the scene is ready
  34069. * @param {Function} func - the function to be executed
  34070. */
  34071. executeWhenReady(func: () => void): void;
  34072. /**
  34073. * Returns a promise that resolves when the scene is ready
  34074. * @returns A promise that resolves when the scene is ready
  34075. */
  34076. whenReadyAsync(): Promise<void>;
  34077. /** @hidden */
  34078. _checkIsReady(): void;
  34079. /**
  34080. * Gets all animatable attached to the scene
  34081. */
  34082. readonly animatables: Animatable[];
  34083. /**
  34084. * Resets the last animation time frame.
  34085. * Useful to override when animations start running when loading a scene for the first time.
  34086. */
  34087. resetLastAnimationTimeFrame(): void;
  34088. /**
  34089. * Gets the current view matrix
  34090. * @returns a Matrix
  34091. */
  34092. getViewMatrix(): Matrix;
  34093. /**
  34094. * Gets the current projection matrix
  34095. * @returns a Matrix
  34096. */
  34097. getProjectionMatrix(): Matrix;
  34098. /**
  34099. * Gets the current transform matrix
  34100. * @returns a Matrix made of View * Projection
  34101. */
  34102. getTransformMatrix(): Matrix;
  34103. /**
  34104. * Sets the current transform matrix
  34105. * @param viewL defines the View matrix to use
  34106. * @param projectionL defines the Projection matrix to use
  34107. * @param viewR defines the right View matrix to use (if provided)
  34108. * @param projectionR defines the right Projection matrix to use (if provided)
  34109. */
  34110. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34111. /**
  34112. * Gets the uniform buffer used to store scene data
  34113. * @returns a UniformBuffer
  34114. */
  34115. getSceneUniformBuffer(): UniformBuffer;
  34116. /**
  34117. * Gets an unique (relatively to the current scene) Id
  34118. * @returns an unique number for the scene
  34119. */
  34120. getUniqueId(): number;
  34121. /**
  34122. * Add a mesh to the list of scene's meshes
  34123. * @param newMesh defines the mesh to add
  34124. * @param recursive if all child meshes should also be added to the scene
  34125. */
  34126. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34127. /**
  34128. * Remove a mesh for the list of scene's meshes
  34129. * @param toRemove defines the mesh to remove
  34130. * @param recursive if all child meshes should also be removed from the scene
  34131. * @returns the index where the mesh was in the mesh list
  34132. */
  34133. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34134. /**
  34135. * Add a transform node to the list of scene's transform nodes
  34136. * @param newTransformNode defines the transform node to add
  34137. */
  34138. addTransformNode(newTransformNode: TransformNode): void;
  34139. /**
  34140. * Remove a transform node for the list of scene's transform nodes
  34141. * @param toRemove defines the transform node to remove
  34142. * @returns the index where the transform node was in the transform node list
  34143. */
  34144. removeTransformNode(toRemove: TransformNode): number;
  34145. /**
  34146. * Remove a skeleton for the list of scene's skeletons
  34147. * @param toRemove defines the skeleton to remove
  34148. * @returns the index where the skeleton was in the skeleton list
  34149. */
  34150. removeSkeleton(toRemove: Skeleton): number;
  34151. /**
  34152. * Remove a morph target for the list of scene's morph targets
  34153. * @param toRemove defines the morph target to remove
  34154. * @returns the index where the morph target was in the morph target list
  34155. */
  34156. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34157. /**
  34158. * Remove a light for the list of scene's lights
  34159. * @param toRemove defines the light to remove
  34160. * @returns the index where the light was in the light list
  34161. */
  34162. removeLight(toRemove: Light): number;
  34163. /**
  34164. * Remove a camera for the list of scene's cameras
  34165. * @param toRemove defines the camera to remove
  34166. * @returns the index where the camera was in the camera list
  34167. */
  34168. removeCamera(toRemove: Camera): number;
  34169. /**
  34170. * Remove a particle system for the list of scene's particle systems
  34171. * @param toRemove defines the particle system to remove
  34172. * @returns the index where the particle system was in the particle system list
  34173. */
  34174. removeParticleSystem(toRemove: IParticleSystem): number;
  34175. /**
  34176. * Remove a animation for the list of scene's animations
  34177. * @param toRemove defines the animation to remove
  34178. * @returns the index where the animation was in the animation list
  34179. */
  34180. removeAnimation(toRemove: Animation): number;
  34181. /**
  34182. * Will stop the animation of the given target
  34183. * @param target - the target
  34184. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34185. * @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)
  34186. */
  34187. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34188. /**
  34189. * Removes the given animation group from this scene.
  34190. * @param toRemove The animation group to remove
  34191. * @returns The index of the removed animation group
  34192. */
  34193. removeAnimationGroup(toRemove: AnimationGroup): number;
  34194. /**
  34195. * Removes the given multi-material from this scene.
  34196. * @param toRemove The multi-material to remove
  34197. * @returns The index of the removed multi-material
  34198. */
  34199. removeMultiMaterial(toRemove: MultiMaterial): number;
  34200. /**
  34201. * Removes the given material from this scene.
  34202. * @param toRemove The material to remove
  34203. * @returns The index of the removed material
  34204. */
  34205. removeMaterial(toRemove: Material): number;
  34206. /**
  34207. * Removes the given action manager from this scene.
  34208. * @param toRemove The action manager to remove
  34209. * @returns The index of the removed action manager
  34210. */
  34211. removeActionManager(toRemove: AbstractActionManager): number;
  34212. /**
  34213. * Removes the given texture from this scene.
  34214. * @param toRemove The texture to remove
  34215. * @returns The index of the removed texture
  34216. */
  34217. removeTexture(toRemove: BaseTexture): number;
  34218. /**
  34219. * Adds the given light to this scene
  34220. * @param newLight The light to add
  34221. */
  34222. addLight(newLight: Light): void;
  34223. /**
  34224. * Sorts the list list based on light priorities
  34225. */
  34226. sortLightsByPriority(): void;
  34227. /**
  34228. * Adds the given camera to this scene
  34229. * @param newCamera The camera to add
  34230. */
  34231. addCamera(newCamera: Camera): void;
  34232. /**
  34233. * Adds the given skeleton to this scene
  34234. * @param newSkeleton The skeleton to add
  34235. */
  34236. addSkeleton(newSkeleton: Skeleton): void;
  34237. /**
  34238. * Adds the given particle system to this scene
  34239. * @param newParticleSystem The particle system to add
  34240. */
  34241. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34242. /**
  34243. * Adds the given animation to this scene
  34244. * @param newAnimation The animation to add
  34245. */
  34246. addAnimation(newAnimation: Animation): void;
  34247. /**
  34248. * Adds the given animation group to this scene.
  34249. * @param newAnimationGroup The animation group to add
  34250. */
  34251. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34252. /**
  34253. * Adds the given multi-material to this scene
  34254. * @param newMultiMaterial The multi-material to add
  34255. */
  34256. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34257. /**
  34258. * Adds the given material to this scene
  34259. * @param newMaterial The material to add
  34260. */
  34261. addMaterial(newMaterial: Material): void;
  34262. /**
  34263. * Adds the given morph target to this scene
  34264. * @param newMorphTargetManager The morph target to add
  34265. */
  34266. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34267. /**
  34268. * Adds the given geometry to this scene
  34269. * @param newGeometry The geometry to add
  34270. */
  34271. addGeometry(newGeometry: Geometry): void;
  34272. /**
  34273. * Adds the given action manager to this scene
  34274. * @param newActionManager The action manager to add
  34275. */
  34276. addActionManager(newActionManager: AbstractActionManager): void;
  34277. /**
  34278. * Adds the given texture to this scene.
  34279. * @param newTexture The texture to add
  34280. */
  34281. addTexture(newTexture: BaseTexture): void;
  34282. /**
  34283. * Switch active camera
  34284. * @param newCamera defines the new active camera
  34285. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34286. */
  34287. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34288. /**
  34289. * sets the active camera of the scene using its ID
  34290. * @param id defines the camera's ID
  34291. * @return the new active camera or null if none found.
  34292. */
  34293. setActiveCameraByID(id: string): Nullable<Camera>;
  34294. /**
  34295. * sets the active camera of the scene using its name
  34296. * @param name defines the camera's name
  34297. * @returns the new active camera or null if none found.
  34298. */
  34299. setActiveCameraByName(name: string): Nullable<Camera>;
  34300. /**
  34301. * get an animation group using its name
  34302. * @param name defines the material's name
  34303. * @return the animation group or null if none found.
  34304. */
  34305. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34306. /**
  34307. * Get a material using its unique id
  34308. * @param uniqueId defines the material's unique id
  34309. * @return the material or null if none found.
  34310. */
  34311. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34312. /**
  34313. * get a material using its id
  34314. * @param id defines the material's ID
  34315. * @return the material or null if none found.
  34316. */
  34317. getMaterialByID(id: string): Nullable<Material>;
  34318. /**
  34319. * Gets a material using its name
  34320. * @param name defines the material's name
  34321. * @return the material or null if none found.
  34322. */
  34323. getMaterialByName(name: string): Nullable<Material>;
  34324. /**
  34325. * Gets a camera using its id
  34326. * @param id defines the id to look for
  34327. * @returns the camera or null if not found
  34328. */
  34329. getCameraByID(id: string): Nullable<Camera>;
  34330. /**
  34331. * Gets a camera using its unique id
  34332. * @param uniqueId defines the unique id to look for
  34333. * @returns the camera or null if not found
  34334. */
  34335. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34336. /**
  34337. * Gets a camera using its name
  34338. * @param name defines the camera's name
  34339. * @return the camera or null if none found.
  34340. */
  34341. getCameraByName(name: string): Nullable<Camera>;
  34342. /**
  34343. * Gets a bone using its id
  34344. * @param id defines the bone's id
  34345. * @return the bone or null if not found
  34346. */
  34347. getBoneByID(id: string): Nullable<Bone>;
  34348. /**
  34349. * Gets a bone using its id
  34350. * @param name defines the bone's name
  34351. * @return the bone or null if not found
  34352. */
  34353. getBoneByName(name: string): Nullable<Bone>;
  34354. /**
  34355. * Gets a light node using its name
  34356. * @param name defines the the light's name
  34357. * @return the light or null if none found.
  34358. */
  34359. getLightByName(name: string): Nullable<Light>;
  34360. /**
  34361. * Gets a light node using its id
  34362. * @param id defines the light's id
  34363. * @return the light or null if none found.
  34364. */
  34365. getLightByID(id: string): Nullable<Light>;
  34366. /**
  34367. * Gets a light node using its scene-generated unique ID
  34368. * @param uniqueId defines the light's unique id
  34369. * @return the light or null if none found.
  34370. */
  34371. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34372. /**
  34373. * Gets a particle system by id
  34374. * @param id defines the particle system id
  34375. * @return the corresponding system or null if none found
  34376. */
  34377. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34378. /**
  34379. * Gets a geometry using its ID
  34380. * @param id defines the geometry's id
  34381. * @return the geometry or null if none found.
  34382. */
  34383. getGeometryByID(id: string): Nullable<Geometry>;
  34384. private _getGeometryByUniqueID;
  34385. /**
  34386. * Add a new geometry to this scene
  34387. * @param geometry defines the geometry to be added to the scene.
  34388. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34389. * @return a boolean defining if the geometry was added or not
  34390. */
  34391. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34392. /**
  34393. * Removes an existing geometry
  34394. * @param geometry defines the geometry to be removed from the scene
  34395. * @return a boolean defining if the geometry was removed or not
  34396. */
  34397. removeGeometry(geometry: Geometry): boolean;
  34398. /**
  34399. * Gets the list of geometries attached to the scene
  34400. * @returns an array of Geometry
  34401. */
  34402. getGeometries(): Geometry[];
  34403. /**
  34404. * Gets the first added mesh found of a given ID
  34405. * @param id defines the id to search for
  34406. * @return the mesh found or null if not found at all
  34407. */
  34408. getMeshByID(id: string): Nullable<AbstractMesh>;
  34409. /**
  34410. * Gets a list of meshes using their id
  34411. * @param id defines the id to search for
  34412. * @returns a list of meshes
  34413. */
  34414. getMeshesByID(id: string): Array<AbstractMesh>;
  34415. /**
  34416. * Gets the first added transform node found of a given ID
  34417. * @param id defines the id to search for
  34418. * @return the found transform node or null if not found at all.
  34419. */
  34420. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34421. /**
  34422. * Gets a transform node with its auto-generated unique id
  34423. * @param uniqueId efines the unique id to search for
  34424. * @return the found transform node or null if not found at all.
  34425. */
  34426. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34427. /**
  34428. * Gets a list of transform nodes using their id
  34429. * @param id defines the id to search for
  34430. * @returns a list of transform nodes
  34431. */
  34432. getTransformNodesByID(id: string): Array<TransformNode>;
  34433. /**
  34434. * Gets a mesh with its auto-generated unique id
  34435. * @param uniqueId defines the unique id to search for
  34436. * @return the found mesh or null if not found at all.
  34437. */
  34438. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34439. /**
  34440. * Gets a the last added mesh using a given id
  34441. * @param id defines the id to search for
  34442. * @return the found mesh or null if not found at all.
  34443. */
  34444. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34445. /**
  34446. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34447. * @param id defines the id to search for
  34448. * @return the found node or null if not found at all
  34449. */
  34450. getLastEntryByID(id: string): Nullable<Node>;
  34451. /**
  34452. * Gets a node (Mesh, Camera, Light) using a given id
  34453. * @param id defines the id to search for
  34454. * @return the found node or null if not found at all
  34455. */
  34456. getNodeByID(id: string): Nullable<Node>;
  34457. /**
  34458. * Gets a node (Mesh, Camera, Light) using a given name
  34459. * @param name defines the name to search for
  34460. * @return the found node or null if not found at all.
  34461. */
  34462. getNodeByName(name: string): Nullable<Node>;
  34463. /**
  34464. * Gets a mesh using a given name
  34465. * @param name defines the name to search for
  34466. * @return the found mesh or null if not found at all.
  34467. */
  34468. getMeshByName(name: string): Nullable<AbstractMesh>;
  34469. /**
  34470. * Gets a transform node using a given name
  34471. * @param name defines the name to search for
  34472. * @return the found transform node or null if not found at all.
  34473. */
  34474. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34475. /**
  34476. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34477. * @param id defines the id to search for
  34478. * @return the found skeleton or null if not found at all.
  34479. */
  34480. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34481. /**
  34482. * Gets a skeleton using a given auto generated unique id
  34483. * @param uniqueId defines the unique id to search for
  34484. * @return the found skeleton or null if not found at all.
  34485. */
  34486. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34487. /**
  34488. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34489. * @param id defines the id to search for
  34490. * @return the found skeleton or null if not found at all.
  34491. */
  34492. getSkeletonById(id: string): Nullable<Skeleton>;
  34493. /**
  34494. * Gets a skeleton using a given name
  34495. * @param name defines the name to search for
  34496. * @return the found skeleton or null if not found at all.
  34497. */
  34498. getSkeletonByName(name: string): Nullable<Skeleton>;
  34499. /**
  34500. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34501. * @param id defines the id to search for
  34502. * @return the found morph target manager or null if not found at all.
  34503. */
  34504. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34505. /**
  34506. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34507. * @param id defines the id to search for
  34508. * @return the found morph target or null if not found at all.
  34509. */
  34510. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34511. /**
  34512. * Gets a boolean indicating if the given mesh is active
  34513. * @param mesh defines the mesh to look for
  34514. * @returns true if the mesh is in the active list
  34515. */
  34516. isActiveMesh(mesh: AbstractMesh): boolean;
  34517. /**
  34518. * Return a unique id as a string which can serve as an identifier for the scene
  34519. */
  34520. readonly uid: string;
  34521. /**
  34522. * Add an externaly attached data from its key.
  34523. * This method call will fail and return false, if such key already exists.
  34524. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34525. * @param key the unique key that identifies the data
  34526. * @param data the data object to associate to the key for this Engine instance
  34527. * @return true if no such key were already present and the data was added successfully, false otherwise
  34528. */
  34529. addExternalData<T>(key: string, data: T): boolean;
  34530. /**
  34531. * Get an externaly attached data from its key
  34532. * @param key the unique key that identifies the data
  34533. * @return the associated data, if present (can be null), or undefined if not present
  34534. */
  34535. getExternalData<T>(key: string): Nullable<T>;
  34536. /**
  34537. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34538. * @param key the unique key that identifies the data
  34539. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34540. * @return the associated data, can be null if the factory returned null.
  34541. */
  34542. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34543. /**
  34544. * Remove an externaly attached data from the Engine instance
  34545. * @param key the unique key that identifies the data
  34546. * @return true if the data was successfully removed, false if it doesn't exist
  34547. */
  34548. removeExternalData(key: string): boolean;
  34549. private _evaluateSubMesh;
  34550. /**
  34551. * Clear the processed materials smart array preventing retention point in material dispose.
  34552. */
  34553. freeProcessedMaterials(): void;
  34554. private _preventFreeActiveMeshesAndRenderingGroups;
  34555. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34556. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34557. * when disposing several meshes in a row or a hierarchy of meshes.
  34558. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34559. */
  34560. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34561. /**
  34562. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34563. */
  34564. freeActiveMeshes(): void;
  34565. /**
  34566. * Clear the info related to rendering groups preventing retention points during dispose.
  34567. */
  34568. freeRenderingGroups(): void;
  34569. /** @hidden */
  34570. _isInIntermediateRendering(): boolean;
  34571. /**
  34572. * Lambda returning the list of potentially active meshes.
  34573. */
  34574. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34575. /**
  34576. * Lambda returning the list of potentially active sub meshes.
  34577. */
  34578. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34579. /**
  34580. * Lambda returning the list of potentially intersecting sub meshes.
  34581. */
  34582. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34583. /**
  34584. * Lambda returning the list of potentially colliding sub meshes.
  34585. */
  34586. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34587. private _activeMeshesFrozen;
  34588. /**
  34589. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34590. * @returns the current scene
  34591. */
  34592. freezeActiveMeshes(): Scene;
  34593. /**
  34594. * Use this function to restart evaluating active meshes on every frame
  34595. * @returns the current scene
  34596. */
  34597. unfreezeActiveMeshes(): Scene;
  34598. private _evaluateActiveMeshes;
  34599. private _activeMesh;
  34600. /**
  34601. * Update the transform matrix to update from the current active camera
  34602. * @param force defines a boolean used to force the update even if cache is up to date
  34603. */
  34604. updateTransformMatrix(force?: boolean): void;
  34605. private _bindFrameBuffer;
  34606. /** @hidden */
  34607. _allowPostProcessClearColor: boolean;
  34608. /** @hidden */
  34609. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34610. private _processSubCameras;
  34611. private _checkIntersections;
  34612. /** @hidden */
  34613. _advancePhysicsEngineStep(step: number): void;
  34614. /**
  34615. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34616. */
  34617. getDeterministicFrameTime: () => number;
  34618. /** @hidden */
  34619. _animate(): void;
  34620. /** Execute all animations (for a frame) */
  34621. animate(): void;
  34622. /**
  34623. * Render the scene
  34624. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34625. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34626. */
  34627. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34628. /**
  34629. * Freeze all materials
  34630. * A frozen material will not be updatable but should be faster to render
  34631. */
  34632. freezeMaterials(): void;
  34633. /**
  34634. * Unfreeze all materials
  34635. * A frozen material will not be updatable but should be faster to render
  34636. */
  34637. unfreezeMaterials(): void;
  34638. /**
  34639. * Releases all held ressources
  34640. */
  34641. dispose(): void;
  34642. /**
  34643. * Gets if the scene is already disposed
  34644. */
  34645. readonly isDisposed: boolean;
  34646. /**
  34647. * Call this function to reduce memory footprint of the scene.
  34648. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34649. */
  34650. clearCachedVertexData(): void;
  34651. /**
  34652. * This function will remove the local cached buffer data from texture.
  34653. * It will save memory but will prevent the texture from being rebuilt
  34654. */
  34655. cleanCachedTextureBuffer(): void;
  34656. /**
  34657. * Get the world extend vectors with an optional filter
  34658. *
  34659. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34660. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34661. */
  34662. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34663. min: Vector3;
  34664. max: Vector3;
  34665. };
  34666. /**
  34667. * Creates a ray that can be used to pick in the scene
  34668. * @param x defines the x coordinate of the origin (on-screen)
  34669. * @param y defines the y coordinate of the origin (on-screen)
  34670. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34671. * @param camera defines the camera to use for the picking
  34672. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34673. * @returns a Ray
  34674. */
  34675. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34676. /**
  34677. * Creates a ray that can be used to pick in the scene
  34678. * @param x defines the x coordinate of the origin (on-screen)
  34679. * @param y defines the y coordinate of the origin (on-screen)
  34680. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34681. * @param result defines the ray where to store the picking ray
  34682. * @param camera defines the camera to use for the picking
  34683. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34684. * @returns the current scene
  34685. */
  34686. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34687. /**
  34688. * Creates a ray that can be used to pick in the scene
  34689. * @param x defines the x coordinate of the origin (on-screen)
  34690. * @param y defines the y coordinate of the origin (on-screen)
  34691. * @param camera defines the camera to use for the picking
  34692. * @returns a Ray
  34693. */
  34694. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34695. /**
  34696. * Creates a ray that can be used to pick in the scene
  34697. * @param x defines the x coordinate of the origin (on-screen)
  34698. * @param y defines the y coordinate of the origin (on-screen)
  34699. * @param result defines the ray where to store the picking ray
  34700. * @param camera defines the camera to use for the picking
  34701. * @returns the current scene
  34702. */
  34703. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34704. /** Launch a ray to try to pick a mesh in the scene
  34705. * @param x position on screen
  34706. * @param y position on screen
  34707. * @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
  34708. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34709. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34710. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34711. * @returns a PickingInfo
  34712. */
  34713. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34714. /** Use the given ray to pick a mesh in the scene
  34715. * @param ray The ray to use to pick meshes
  34716. * @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
  34717. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34718. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34719. * @returns a PickingInfo
  34720. */
  34721. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34722. /**
  34723. * Launch a ray to try to pick a mesh in the scene
  34724. * @param x X position on screen
  34725. * @param y Y position on screen
  34726. * @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
  34727. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34728. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34729. * @returns an array of PickingInfo
  34730. */
  34731. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34732. /**
  34733. * Launch a ray to try to pick a mesh in the scene
  34734. * @param ray Ray to use
  34735. * @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
  34736. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34737. * @returns an array of PickingInfo
  34738. */
  34739. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34740. /**
  34741. * Force the value of meshUnderPointer
  34742. * @param mesh defines the mesh to use
  34743. */
  34744. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34745. /**
  34746. * Gets the mesh under the pointer
  34747. * @returns a Mesh or null if no mesh is under the pointer
  34748. */
  34749. getPointerOverMesh(): Nullable<AbstractMesh>;
  34750. /** @hidden */
  34751. _rebuildGeometries(): void;
  34752. /** @hidden */
  34753. _rebuildTextures(): void;
  34754. private _getByTags;
  34755. /**
  34756. * Get a list of meshes by tags
  34757. * @param tagsQuery defines the tags query to use
  34758. * @param forEach defines a predicate used to filter results
  34759. * @returns an array of Mesh
  34760. */
  34761. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34762. /**
  34763. * Get a list of cameras by tags
  34764. * @param tagsQuery defines the tags query to use
  34765. * @param forEach defines a predicate used to filter results
  34766. * @returns an array of Camera
  34767. */
  34768. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34769. /**
  34770. * Get a list of lights by tags
  34771. * @param tagsQuery defines the tags query to use
  34772. * @param forEach defines a predicate used to filter results
  34773. * @returns an array of Light
  34774. */
  34775. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34776. /**
  34777. * Get a list of materials by tags
  34778. * @param tagsQuery defines the tags query to use
  34779. * @param forEach defines a predicate used to filter results
  34780. * @returns an array of Material
  34781. */
  34782. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34783. /**
  34784. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34785. * This allowed control for front to back rendering or reversly depending of the special needs.
  34786. *
  34787. * @param renderingGroupId The rendering group id corresponding to its index
  34788. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34789. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34790. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34791. */
  34792. 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;
  34793. /**
  34794. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34795. *
  34796. * @param renderingGroupId The rendering group id corresponding to its index
  34797. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34798. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34799. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34800. */
  34801. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34802. /**
  34803. * Gets the current auto clear configuration for one rendering group of the rendering
  34804. * manager.
  34805. * @param index the rendering group index to get the information for
  34806. * @returns The auto clear setup for the requested rendering group
  34807. */
  34808. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34809. private _blockMaterialDirtyMechanism;
  34810. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34811. blockMaterialDirtyMechanism: boolean;
  34812. /**
  34813. * Will flag all materials as dirty to trigger new shader compilation
  34814. * @param flag defines the flag used to specify which material part must be marked as dirty
  34815. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34816. */
  34817. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34818. /** @hidden */
  34819. _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;
  34820. /** @hidden */
  34821. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34822. }
  34823. }
  34824. declare module "babylonjs/assetContainer" {
  34825. import { AbstractScene } from "babylonjs/abstractScene";
  34826. import { Scene } from "babylonjs/scene";
  34827. import { Mesh } from "babylonjs/Meshes/mesh";
  34828. /**
  34829. * Set of assets to keep when moving a scene into an asset container.
  34830. */
  34831. export class KeepAssets extends AbstractScene {
  34832. }
  34833. /**
  34834. * Container with a set of assets that can be added or removed from a scene.
  34835. */
  34836. export class AssetContainer extends AbstractScene {
  34837. /**
  34838. * The scene the AssetContainer belongs to.
  34839. */
  34840. scene: Scene;
  34841. /**
  34842. * Instantiates an AssetContainer.
  34843. * @param scene The scene the AssetContainer belongs to.
  34844. */
  34845. constructor(scene: Scene);
  34846. /**
  34847. * Adds all the assets from the container to the scene.
  34848. */
  34849. addAllToScene(): void;
  34850. /**
  34851. * Removes all the assets in the container from the scene
  34852. */
  34853. removeAllFromScene(): void;
  34854. /**
  34855. * Disposes all the assets in the container
  34856. */
  34857. dispose(): void;
  34858. private _moveAssets;
  34859. /**
  34860. * Removes all the assets contained in the scene and adds them to the container.
  34861. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34862. */
  34863. moveAllFromScene(keepAssets?: KeepAssets): void;
  34864. /**
  34865. * 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.
  34866. * @returns the root mesh
  34867. */
  34868. createRootMesh(): Mesh;
  34869. }
  34870. }
  34871. declare module "babylonjs/abstractScene" {
  34872. import { Scene } from "babylonjs/scene";
  34873. import { Nullable } from "babylonjs/types";
  34874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34875. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34876. import { Geometry } from "babylonjs/Meshes/geometry";
  34877. import { Skeleton } from "babylonjs/Bones/skeleton";
  34878. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34879. import { AssetContainer } from "babylonjs/assetContainer";
  34880. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34881. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34882. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34883. import { Material } from "babylonjs/Materials/material";
  34884. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34885. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34886. import { Camera } from "babylonjs/Cameras/camera";
  34887. import { Light } from "babylonjs/Lights/light";
  34888. import { Node } from "babylonjs/node";
  34889. import { Animation } from "babylonjs/Animations/animation";
  34890. /**
  34891. * Defines how the parser contract is defined.
  34892. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34893. */
  34894. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34895. /**
  34896. * Defines how the individual parser contract is defined.
  34897. * These parser can parse an individual asset
  34898. */
  34899. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34900. /**
  34901. * Base class of the scene acting as a container for the different elements composing a scene.
  34902. * This class is dynamically extended by the different components of the scene increasing
  34903. * flexibility and reducing coupling
  34904. */
  34905. export abstract class AbstractScene {
  34906. /**
  34907. * Stores the list of available parsers in the application.
  34908. */
  34909. private static _BabylonFileParsers;
  34910. /**
  34911. * Stores the list of available individual parsers in the application.
  34912. */
  34913. private static _IndividualBabylonFileParsers;
  34914. /**
  34915. * Adds a parser in the list of available ones
  34916. * @param name Defines the name of the parser
  34917. * @param parser Defines the parser to add
  34918. */
  34919. static AddParser(name: string, parser: BabylonFileParser): void;
  34920. /**
  34921. * Gets a general parser from the list of avaialble ones
  34922. * @param name Defines the name of the parser
  34923. * @returns the requested parser or null
  34924. */
  34925. static GetParser(name: string): Nullable<BabylonFileParser>;
  34926. /**
  34927. * Adds n individual parser in the list of available ones
  34928. * @param name Defines the name of the parser
  34929. * @param parser Defines the parser to add
  34930. */
  34931. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34932. /**
  34933. * Gets an individual parser from the list of avaialble ones
  34934. * @param name Defines the name of the parser
  34935. * @returns the requested parser or null
  34936. */
  34937. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34938. /**
  34939. * Parser json data and populate both a scene and its associated container object
  34940. * @param jsonData Defines the data to parse
  34941. * @param scene Defines the scene to parse the data for
  34942. * @param container Defines the container attached to the parsing sequence
  34943. * @param rootUrl Defines the root url of the data
  34944. */
  34945. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34946. /**
  34947. * Gets the list of root nodes (ie. nodes with no parent)
  34948. */
  34949. rootNodes: Node[];
  34950. /** All of the cameras added to this scene
  34951. * @see http://doc.babylonjs.com/babylon101/cameras
  34952. */
  34953. cameras: Camera[];
  34954. /**
  34955. * All of the lights added to this scene
  34956. * @see http://doc.babylonjs.com/babylon101/lights
  34957. */
  34958. lights: Light[];
  34959. /**
  34960. * All of the (abstract) meshes added to this scene
  34961. */
  34962. meshes: AbstractMesh[];
  34963. /**
  34964. * The list of skeletons added to the scene
  34965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34966. */
  34967. skeletons: Skeleton[];
  34968. /**
  34969. * All of the particle systems added to this scene
  34970. * @see http://doc.babylonjs.com/babylon101/particles
  34971. */
  34972. particleSystems: IParticleSystem[];
  34973. /**
  34974. * Gets a list of Animations associated with the scene
  34975. */
  34976. animations: Animation[];
  34977. /**
  34978. * All of the animation groups added to this scene
  34979. * @see http://doc.babylonjs.com/how_to/group
  34980. */
  34981. animationGroups: AnimationGroup[];
  34982. /**
  34983. * All of the multi-materials added to this scene
  34984. * @see http://doc.babylonjs.com/how_to/multi_materials
  34985. */
  34986. multiMaterials: MultiMaterial[];
  34987. /**
  34988. * All of the materials added to this scene
  34989. * In the context of a Scene, it is not supposed to be modified manually.
  34990. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34991. * Note also that the order of the Material wihin the array is not significant and might change.
  34992. * @see http://doc.babylonjs.com/babylon101/materials
  34993. */
  34994. materials: Material[];
  34995. /**
  34996. * The list of morph target managers added to the scene
  34997. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34998. */
  34999. morphTargetManagers: MorphTargetManager[];
  35000. /**
  35001. * The list of geometries used in the scene.
  35002. */
  35003. geometries: Geometry[];
  35004. /**
  35005. * All of the tranform nodes added to this scene
  35006. * In the context of a Scene, it is not supposed to be modified manually.
  35007. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35008. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35009. * @see http://doc.babylonjs.com/how_to/transformnode
  35010. */
  35011. transformNodes: TransformNode[];
  35012. /**
  35013. * ActionManagers available on the scene.
  35014. */
  35015. actionManagers: AbstractActionManager[];
  35016. /**
  35017. * Textures to keep.
  35018. */
  35019. textures: BaseTexture[];
  35020. /**
  35021. * Environment texture for the scene
  35022. */
  35023. environmentTexture: Nullable<BaseTexture>;
  35024. }
  35025. }
  35026. declare module "babylonjs/Audio/sound" {
  35027. import { Observable } from "babylonjs/Misc/observable";
  35028. import { Vector3 } from "babylonjs/Maths/math";
  35029. import { Nullable } from "babylonjs/types";
  35030. import { Scene } from "babylonjs/scene";
  35031. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35032. /**
  35033. * Defines a sound that can be played in the application.
  35034. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35036. */
  35037. export class Sound {
  35038. /**
  35039. * The name of the sound in the scene.
  35040. */
  35041. name: string;
  35042. /**
  35043. * Does the sound autoplay once loaded.
  35044. */
  35045. autoplay: boolean;
  35046. /**
  35047. * Does the sound loop after it finishes playing once.
  35048. */
  35049. loop: boolean;
  35050. /**
  35051. * Does the sound use a custom attenuation curve to simulate the falloff
  35052. * happening when the source gets further away from the camera.
  35053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35054. */
  35055. useCustomAttenuation: boolean;
  35056. /**
  35057. * The sound track id this sound belongs to.
  35058. */
  35059. soundTrackId: number;
  35060. /**
  35061. * Is this sound currently played.
  35062. */
  35063. isPlaying: boolean;
  35064. /**
  35065. * Is this sound currently paused.
  35066. */
  35067. isPaused: boolean;
  35068. /**
  35069. * Does this sound enables spatial sound.
  35070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35071. */
  35072. spatialSound: boolean;
  35073. /**
  35074. * Define the reference distance the sound should be heard perfectly.
  35075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35076. */
  35077. refDistance: number;
  35078. /**
  35079. * Define the roll off factor of spatial sounds.
  35080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35081. */
  35082. rolloffFactor: number;
  35083. /**
  35084. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35086. */
  35087. maxDistance: number;
  35088. /**
  35089. * Define the distance attenuation model the sound will follow.
  35090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35091. */
  35092. distanceModel: string;
  35093. /**
  35094. * @hidden
  35095. * Back Compat
  35096. **/
  35097. onended: () => any;
  35098. /**
  35099. * Observable event when the current playing sound finishes.
  35100. */
  35101. onEndedObservable: Observable<Sound>;
  35102. private _panningModel;
  35103. private _playbackRate;
  35104. private _streaming;
  35105. private _startTime;
  35106. private _startOffset;
  35107. private _position;
  35108. /** @hidden */
  35109. _positionInEmitterSpace: boolean;
  35110. private _localDirection;
  35111. private _volume;
  35112. private _isReadyToPlay;
  35113. private _isDirectional;
  35114. private _readyToPlayCallback;
  35115. private _audioBuffer;
  35116. private _soundSource;
  35117. private _streamingSource;
  35118. private _soundPanner;
  35119. private _soundGain;
  35120. private _inputAudioNode;
  35121. private _outputAudioNode;
  35122. private _coneInnerAngle;
  35123. private _coneOuterAngle;
  35124. private _coneOuterGain;
  35125. private _scene;
  35126. private _connectedTransformNode;
  35127. private _customAttenuationFunction;
  35128. private _registerFunc;
  35129. private _isOutputConnected;
  35130. private _htmlAudioElement;
  35131. private _urlType;
  35132. /** @hidden */
  35133. static _SceneComponentInitialization: (scene: Scene) => void;
  35134. /**
  35135. * Create a sound and attach it to a scene
  35136. * @param name Name of your sound
  35137. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35138. * @param scene defines the scene the sound belongs to
  35139. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35140. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35141. */
  35142. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  35143. /**
  35144. * Release the sound and its associated resources
  35145. */
  35146. dispose(): void;
  35147. /**
  35148. * Gets if the sounds is ready to be played or not.
  35149. * @returns true if ready, otherwise false
  35150. */
  35151. isReady(): boolean;
  35152. private _soundLoaded;
  35153. /**
  35154. * Sets the data of the sound from an audiobuffer
  35155. * @param audioBuffer The audioBuffer containing the data
  35156. */
  35157. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35158. /**
  35159. * Updates the current sounds options such as maxdistance, loop...
  35160. * @param options A JSON object containing values named as the object properties
  35161. */
  35162. updateOptions(options: any): void;
  35163. private _createSpatialParameters;
  35164. private _updateSpatialParameters;
  35165. /**
  35166. * Switch the panning model to HRTF:
  35167. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35169. */
  35170. switchPanningModelToHRTF(): void;
  35171. /**
  35172. * Switch the panning model to Equal Power:
  35173. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35175. */
  35176. switchPanningModelToEqualPower(): void;
  35177. private _switchPanningModel;
  35178. /**
  35179. * Connect this sound to a sound track audio node like gain...
  35180. * @param soundTrackAudioNode the sound track audio node to connect to
  35181. */
  35182. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35183. /**
  35184. * Transform this sound into a directional source
  35185. * @param coneInnerAngle Size of the inner cone in degree
  35186. * @param coneOuterAngle Size of the outer cone in degree
  35187. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35188. */
  35189. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35190. /**
  35191. * Gets or sets the inner angle for the directional cone.
  35192. */
  35193. /**
  35194. * Gets or sets the inner angle for the directional cone.
  35195. */
  35196. directionalConeInnerAngle: number;
  35197. /**
  35198. * Gets or sets the outer angle for the directional cone.
  35199. */
  35200. /**
  35201. * Gets or sets the outer angle for the directional cone.
  35202. */
  35203. directionalConeOuterAngle: number;
  35204. /**
  35205. * Sets the position of the emitter if spatial sound is enabled
  35206. * @param newPosition Defines the new posisiton
  35207. */
  35208. setPosition(newPosition: Vector3): void;
  35209. /**
  35210. * Sets the local direction of the emitter if spatial sound is enabled
  35211. * @param newLocalDirection Defines the new local direction
  35212. */
  35213. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35214. private _updateDirection;
  35215. /** @hidden */
  35216. updateDistanceFromListener(): void;
  35217. /**
  35218. * Sets a new custom attenuation function for the sound.
  35219. * @param callback Defines the function used for the attenuation
  35220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35221. */
  35222. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35223. /**
  35224. * Play the sound
  35225. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35226. * @param offset (optional) Start the sound setting it at a specific time
  35227. */
  35228. play(time?: number, offset?: number): void;
  35229. private _onended;
  35230. /**
  35231. * Stop the sound
  35232. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35233. */
  35234. stop(time?: number): void;
  35235. /**
  35236. * Put the sound in pause
  35237. */
  35238. pause(): void;
  35239. /**
  35240. * Sets a dedicated volume for this sounds
  35241. * @param newVolume Define the new volume of the sound
  35242. * @param time Define in how long the sound should be at this value
  35243. */
  35244. setVolume(newVolume: number, time?: number): void;
  35245. /**
  35246. * Set the sound play back rate
  35247. * @param newPlaybackRate Define the playback rate the sound should be played at
  35248. */
  35249. setPlaybackRate(newPlaybackRate: number): void;
  35250. /**
  35251. * Gets the volume of the sound.
  35252. * @returns the volume of the sound
  35253. */
  35254. getVolume(): number;
  35255. /**
  35256. * Attach the sound to a dedicated mesh
  35257. * @param transformNode The transform node to connect the sound with
  35258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35259. */
  35260. attachToMesh(transformNode: TransformNode): void;
  35261. /**
  35262. * Detach the sound from the previously attached mesh
  35263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35264. */
  35265. detachFromMesh(): void;
  35266. private _onRegisterAfterWorldMatrixUpdate;
  35267. /**
  35268. * Clone the current sound in the scene.
  35269. * @returns the new sound clone
  35270. */
  35271. clone(): Nullable<Sound>;
  35272. /**
  35273. * Gets the current underlying audio buffer containing the data
  35274. * @returns the audio buffer
  35275. */
  35276. getAudioBuffer(): Nullable<AudioBuffer>;
  35277. /**
  35278. * Serializes the Sound in a JSON representation
  35279. * @returns the JSON representation of the sound
  35280. */
  35281. serialize(): any;
  35282. /**
  35283. * Parse a JSON representation of a sound to innstantiate in a given scene
  35284. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35285. * @param scene Define the scene the new parsed sound should be created in
  35286. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35287. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35288. * @returns the newly parsed sound
  35289. */
  35290. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35291. }
  35292. }
  35293. declare module "babylonjs/Actions/directAudioActions" {
  35294. import { Action } from "babylonjs/Actions/action";
  35295. import { Condition } from "babylonjs/Actions/condition";
  35296. import { Sound } from "babylonjs/Audio/sound";
  35297. /**
  35298. * This defines an action helpful to play a defined sound on a triggered action.
  35299. */
  35300. export class PlaySoundAction extends Action {
  35301. private _sound;
  35302. /**
  35303. * Instantiate the action
  35304. * @param triggerOptions defines the trigger options
  35305. * @param sound defines the sound to play
  35306. * @param condition defines the trigger related conditions
  35307. */
  35308. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35309. /** @hidden */
  35310. _prepare(): void;
  35311. /**
  35312. * Execute the action and play the sound.
  35313. */
  35314. execute(): void;
  35315. /**
  35316. * Serializes the actions and its related information.
  35317. * @param parent defines the object to serialize in
  35318. * @returns the serialized object
  35319. */
  35320. serialize(parent: any): any;
  35321. }
  35322. /**
  35323. * This defines an action helpful to stop a defined sound on a triggered action.
  35324. */
  35325. export class StopSoundAction extends Action {
  35326. private _sound;
  35327. /**
  35328. * Instantiate the action
  35329. * @param triggerOptions defines the trigger options
  35330. * @param sound defines the sound to stop
  35331. * @param condition defines the trigger related conditions
  35332. */
  35333. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35334. /** @hidden */
  35335. _prepare(): void;
  35336. /**
  35337. * Execute the action and stop the sound.
  35338. */
  35339. execute(): void;
  35340. /**
  35341. * Serializes the actions and its related information.
  35342. * @param parent defines the object to serialize in
  35343. * @returns the serialized object
  35344. */
  35345. serialize(parent: any): any;
  35346. }
  35347. }
  35348. declare module "babylonjs/Actions/interpolateValueAction" {
  35349. import { Action } from "babylonjs/Actions/action";
  35350. import { Condition } from "babylonjs/Actions/condition";
  35351. import { Observable } from "babylonjs/Misc/observable";
  35352. /**
  35353. * This defines an action responsible to change the value of a property
  35354. * by interpolating between its current value and the newly set one once triggered.
  35355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35356. */
  35357. export class InterpolateValueAction extends Action {
  35358. /**
  35359. * Defines the path of the property where the value should be interpolated
  35360. */
  35361. propertyPath: string;
  35362. /**
  35363. * Defines the target value at the end of the interpolation.
  35364. */
  35365. value: any;
  35366. /**
  35367. * Defines the time it will take for the property to interpolate to the value.
  35368. */
  35369. duration: number;
  35370. /**
  35371. * Defines if the other scene animations should be stopped when the action has been triggered
  35372. */
  35373. stopOtherAnimations?: boolean;
  35374. /**
  35375. * Defines a callback raised once the interpolation animation has been done.
  35376. */
  35377. onInterpolationDone?: () => void;
  35378. /**
  35379. * Observable triggered once the interpolation animation has been done.
  35380. */
  35381. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35382. private _target;
  35383. private _effectiveTarget;
  35384. private _property;
  35385. /**
  35386. * Instantiate the action
  35387. * @param triggerOptions defines the trigger options
  35388. * @param target defines the object containing the value to interpolate
  35389. * @param propertyPath defines the path to the property in the target object
  35390. * @param value defines the target value at the end of the interpolation
  35391. * @param duration deines the time it will take for the property to interpolate to the value.
  35392. * @param condition defines the trigger related conditions
  35393. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35394. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35395. */
  35396. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35397. /** @hidden */
  35398. _prepare(): void;
  35399. /**
  35400. * Execute the action starts the value interpolation.
  35401. */
  35402. execute(): void;
  35403. /**
  35404. * Serializes the actions and its related information.
  35405. * @param parent defines the object to serialize in
  35406. * @returns the serialized object
  35407. */
  35408. serialize(parent: any): any;
  35409. }
  35410. }
  35411. declare module "babylonjs/Actions/index" {
  35412. export * from "babylonjs/Actions/action";
  35413. export * from "babylonjs/Actions/actionEvent";
  35414. export * from "babylonjs/Actions/actionManager";
  35415. export * from "babylonjs/Actions/condition";
  35416. export * from "babylonjs/Actions/directActions";
  35417. export * from "babylonjs/Actions/directAudioActions";
  35418. export * from "babylonjs/Actions/interpolateValueAction";
  35419. }
  35420. declare module "babylonjs/Animations/index" {
  35421. export * from "babylonjs/Animations/animatable";
  35422. export * from "babylonjs/Animations/animation";
  35423. export * from "babylonjs/Animations/animationGroup";
  35424. export * from "babylonjs/Animations/animationPropertiesOverride";
  35425. export * from "babylonjs/Animations/easing";
  35426. export * from "babylonjs/Animations/runtimeAnimation";
  35427. export * from "babylonjs/Animations/animationEvent";
  35428. export * from "babylonjs/Animations/animationGroup";
  35429. export * from "babylonjs/Animations/animationKey";
  35430. export * from "babylonjs/Animations/animationRange";
  35431. }
  35432. declare module "babylonjs/Audio/soundTrack" {
  35433. import { Sound } from "babylonjs/Audio/sound";
  35434. import { Analyser } from "babylonjs/Audio/analyser";
  35435. import { Scene } from "babylonjs/scene";
  35436. /**
  35437. * Options allowed during the creation of a sound track.
  35438. */
  35439. export interface ISoundTrackOptions {
  35440. /**
  35441. * The volume the sound track should take during creation
  35442. */
  35443. volume?: number;
  35444. /**
  35445. * Define if the sound track is the main sound track of the scene
  35446. */
  35447. mainTrack?: boolean;
  35448. }
  35449. /**
  35450. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35451. * It will be also used in a future release to apply effects on a specific track.
  35452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35453. */
  35454. export class SoundTrack {
  35455. /**
  35456. * The unique identifier of the sound track in the scene.
  35457. */
  35458. id: number;
  35459. /**
  35460. * The list of sounds included in the sound track.
  35461. */
  35462. soundCollection: Array<Sound>;
  35463. private _outputAudioNode;
  35464. private _scene;
  35465. private _isMainTrack;
  35466. private _connectedAnalyser;
  35467. private _options;
  35468. private _isInitialized;
  35469. /**
  35470. * Creates a new sound track.
  35471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35472. * @param scene Define the scene the sound track belongs to
  35473. * @param options
  35474. */
  35475. constructor(scene: Scene, options?: ISoundTrackOptions);
  35476. private _initializeSoundTrackAudioGraph;
  35477. /**
  35478. * Release the sound track and its associated resources
  35479. */
  35480. dispose(): void;
  35481. /**
  35482. * Adds a sound to this sound track
  35483. * @param sound define the cound to add
  35484. * @ignoreNaming
  35485. */
  35486. AddSound(sound: Sound): void;
  35487. /**
  35488. * Removes a sound to this sound track
  35489. * @param sound define the cound to remove
  35490. * @ignoreNaming
  35491. */
  35492. RemoveSound(sound: Sound): void;
  35493. /**
  35494. * Set a global volume for the full sound track.
  35495. * @param newVolume Define the new volume of the sound track
  35496. */
  35497. setVolume(newVolume: number): void;
  35498. /**
  35499. * Switch the panning model to HRTF:
  35500. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35502. */
  35503. switchPanningModelToHRTF(): void;
  35504. /**
  35505. * Switch the panning model to Equal Power:
  35506. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35508. */
  35509. switchPanningModelToEqualPower(): void;
  35510. /**
  35511. * Connect the sound track to an audio analyser allowing some amazing
  35512. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35514. * @param analyser The analyser to connect to the engine
  35515. */
  35516. connectToAnalyser(analyser: Analyser): void;
  35517. }
  35518. }
  35519. declare module "babylonjs/Audio/audioSceneComponent" {
  35520. import { Sound } from "babylonjs/Audio/sound";
  35521. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35522. import { Nullable } from "babylonjs/types";
  35523. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35524. import { Scene } from "babylonjs/scene";
  35525. import { AbstractScene } from "babylonjs/abstractScene";
  35526. module "babylonjs/abstractScene" {
  35527. interface AbstractScene {
  35528. /**
  35529. * The list of sounds used in the scene.
  35530. */
  35531. sounds: Nullable<Array<Sound>>;
  35532. }
  35533. }
  35534. module "babylonjs/scene" {
  35535. interface Scene {
  35536. /**
  35537. * @hidden
  35538. * Backing field
  35539. */
  35540. _mainSoundTrack: SoundTrack;
  35541. /**
  35542. * The main sound track played by the scene.
  35543. * It cotains your primary collection of sounds.
  35544. */
  35545. mainSoundTrack: SoundTrack;
  35546. /**
  35547. * The list of sound tracks added to the scene
  35548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35549. */
  35550. soundTracks: Nullable<Array<SoundTrack>>;
  35551. /**
  35552. * Gets a sound using a given name
  35553. * @param name defines the name to search for
  35554. * @return the found sound or null if not found at all.
  35555. */
  35556. getSoundByName(name: string): Nullable<Sound>;
  35557. /**
  35558. * Gets or sets if audio support is enabled
  35559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35560. */
  35561. audioEnabled: boolean;
  35562. /**
  35563. * Gets or sets if audio will be output to headphones
  35564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35565. */
  35566. headphone: boolean;
  35567. }
  35568. }
  35569. /**
  35570. * Defines the sound scene component responsible to manage any sounds
  35571. * in a given scene.
  35572. */
  35573. export class AudioSceneComponent implements ISceneSerializableComponent {
  35574. /**
  35575. * The component name helpfull to identify the component in the list of scene components.
  35576. */
  35577. readonly name: string;
  35578. /**
  35579. * The scene the component belongs to.
  35580. */
  35581. scene: Scene;
  35582. private _audioEnabled;
  35583. /**
  35584. * Gets whether audio is enabled or not.
  35585. * Please use related enable/disable method to switch state.
  35586. */
  35587. readonly audioEnabled: boolean;
  35588. private _headphone;
  35589. /**
  35590. * Gets whether audio is outputing to headphone or not.
  35591. * Please use the according Switch methods to change output.
  35592. */
  35593. readonly headphone: boolean;
  35594. /**
  35595. * Creates a new instance of the component for the given scene
  35596. * @param scene Defines the scene to register the component in
  35597. */
  35598. constructor(scene: Scene);
  35599. /**
  35600. * Registers the component in a given scene
  35601. */
  35602. register(): void;
  35603. /**
  35604. * Rebuilds the elements related to this component in case of
  35605. * context lost for instance.
  35606. */
  35607. rebuild(): void;
  35608. /**
  35609. * Serializes the component data to the specified json object
  35610. * @param serializationObject The object to serialize to
  35611. */
  35612. serialize(serializationObject: any): void;
  35613. /**
  35614. * Adds all the elements from the container to the scene
  35615. * @param container the container holding the elements
  35616. */
  35617. addFromContainer(container: AbstractScene): void;
  35618. /**
  35619. * Removes all the elements in the container from the scene
  35620. * @param container contains the elements to remove
  35621. * @param dispose if the removed element should be disposed (default: false)
  35622. */
  35623. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35624. /**
  35625. * Disposes the component and the associated ressources.
  35626. */
  35627. dispose(): void;
  35628. /**
  35629. * Disables audio in the associated scene.
  35630. */
  35631. disableAudio(): void;
  35632. /**
  35633. * Enables audio in the associated scene.
  35634. */
  35635. enableAudio(): void;
  35636. /**
  35637. * Switch audio to headphone output.
  35638. */
  35639. switchAudioModeForHeadphones(): void;
  35640. /**
  35641. * Switch audio to normal speakers.
  35642. */
  35643. switchAudioModeForNormalSpeakers(): void;
  35644. private _afterRender;
  35645. }
  35646. }
  35647. declare module "babylonjs/Audio/weightedsound" {
  35648. import { Sound } from "babylonjs/Audio/sound";
  35649. /**
  35650. * Wraps one or more Sound objects and selects one with random weight for playback.
  35651. */
  35652. export class WeightedSound {
  35653. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35654. loop: boolean;
  35655. private _coneInnerAngle;
  35656. private _coneOuterAngle;
  35657. private _volume;
  35658. /** A Sound is currently playing. */
  35659. isPlaying: boolean;
  35660. /** A Sound is currently paused. */
  35661. isPaused: boolean;
  35662. private _sounds;
  35663. private _weights;
  35664. private _currentIndex?;
  35665. /**
  35666. * Creates a new WeightedSound from the list of sounds given.
  35667. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35668. * @param sounds Array of Sounds that will be selected from.
  35669. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35670. */
  35671. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35672. /**
  35673. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35674. */
  35675. /**
  35676. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35677. */
  35678. directionalConeInnerAngle: number;
  35679. /**
  35680. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35681. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35682. */
  35683. /**
  35684. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35685. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35686. */
  35687. directionalConeOuterAngle: number;
  35688. /**
  35689. * Playback volume.
  35690. */
  35691. /**
  35692. * Playback volume.
  35693. */
  35694. volume: number;
  35695. private _onended;
  35696. /**
  35697. * Suspend playback
  35698. */
  35699. pause(): void;
  35700. /**
  35701. * Stop playback
  35702. */
  35703. stop(): void;
  35704. /**
  35705. * Start playback.
  35706. * @param startOffset Position the clip head at a specific time in seconds.
  35707. */
  35708. play(startOffset?: number): void;
  35709. }
  35710. }
  35711. declare module "babylonjs/Audio/index" {
  35712. export * from "babylonjs/Audio/analyser";
  35713. export * from "babylonjs/Audio/audioEngine";
  35714. export * from "babylonjs/Audio/audioSceneComponent";
  35715. export * from "babylonjs/Audio/sound";
  35716. export * from "babylonjs/Audio/soundTrack";
  35717. export * from "babylonjs/Audio/weightedsound";
  35718. }
  35719. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35720. import { Behavior } from "babylonjs/Behaviors/behavior";
  35721. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35722. import { BackEase } from "babylonjs/Animations/easing";
  35723. /**
  35724. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35725. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35726. */
  35727. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35728. /**
  35729. * Gets the name of the behavior.
  35730. */
  35731. readonly name: string;
  35732. /**
  35733. * The easing function used by animations
  35734. */
  35735. static EasingFunction: BackEase;
  35736. /**
  35737. * The easing mode used by animations
  35738. */
  35739. static EasingMode: number;
  35740. /**
  35741. * The duration of the animation, in milliseconds
  35742. */
  35743. transitionDuration: number;
  35744. /**
  35745. * Length of the distance animated by the transition when lower radius is reached
  35746. */
  35747. lowerRadiusTransitionRange: number;
  35748. /**
  35749. * Length of the distance animated by the transition when upper radius is reached
  35750. */
  35751. upperRadiusTransitionRange: number;
  35752. private _autoTransitionRange;
  35753. /**
  35754. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35755. */
  35756. /**
  35757. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35758. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35759. */
  35760. autoTransitionRange: boolean;
  35761. private _attachedCamera;
  35762. private _onAfterCheckInputsObserver;
  35763. private _onMeshTargetChangedObserver;
  35764. /**
  35765. * Initializes the behavior.
  35766. */
  35767. init(): void;
  35768. /**
  35769. * Attaches the behavior to its arc rotate camera.
  35770. * @param camera Defines the camera to attach the behavior to
  35771. */
  35772. attach(camera: ArcRotateCamera): void;
  35773. /**
  35774. * Detaches the behavior from its current arc rotate camera.
  35775. */
  35776. detach(): void;
  35777. private _radiusIsAnimating;
  35778. private _radiusBounceTransition;
  35779. private _animatables;
  35780. private _cachedWheelPrecision;
  35781. /**
  35782. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35783. * @param radiusLimit The limit to check against.
  35784. * @return Bool to indicate if at limit.
  35785. */
  35786. private _isRadiusAtLimit;
  35787. /**
  35788. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35789. * @param radiusDelta The delta by which to animate to. Can be negative.
  35790. */
  35791. private _applyBoundRadiusAnimation;
  35792. /**
  35793. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35794. */
  35795. protected _clearAnimationLocks(): void;
  35796. /**
  35797. * Stops and removes all animations that have been applied to the camera
  35798. */
  35799. stopAllAnimations(): void;
  35800. }
  35801. }
  35802. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35803. import { Behavior } from "babylonjs/Behaviors/behavior";
  35804. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35805. import { ExponentialEase } from "babylonjs/Animations/easing";
  35806. import { Nullable } from "babylonjs/types";
  35807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35808. import { Vector3 } from "babylonjs/Maths/math";
  35809. /**
  35810. * 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.
  35811. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35812. */
  35813. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35814. /**
  35815. * Gets the name of the behavior.
  35816. */
  35817. readonly name: string;
  35818. private _mode;
  35819. private _radiusScale;
  35820. private _positionScale;
  35821. private _defaultElevation;
  35822. private _elevationReturnTime;
  35823. private _elevationReturnWaitTime;
  35824. private _zoomStopsAnimation;
  35825. private _framingTime;
  35826. /**
  35827. * The easing function used by animations
  35828. */
  35829. static EasingFunction: ExponentialEase;
  35830. /**
  35831. * The easing mode used by animations
  35832. */
  35833. static EasingMode: number;
  35834. /**
  35835. * Sets the current mode used by the behavior
  35836. */
  35837. /**
  35838. * Gets current mode used by the behavior.
  35839. */
  35840. mode: number;
  35841. /**
  35842. * Sets the scale applied to the radius (1 by default)
  35843. */
  35844. /**
  35845. * Gets the scale applied to the radius
  35846. */
  35847. radiusScale: number;
  35848. /**
  35849. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35850. */
  35851. /**
  35852. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35853. */
  35854. positionScale: number;
  35855. /**
  35856. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35857. * behaviour is triggered, in radians.
  35858. */
  35859. /**
  35860. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35861. * behaviour is triggered, in radians.
  35862. */
  35863. defaultElevation: number;
  35864. /**
  35865. * Sets the time (in milliseconds) taken to return to the default beta position.
  35866. * Negative value indicates camera should not return to default.
  35867. */
  35868. /**
  35869. * Gets the time (in milliseconds) taken to return to the default beta position.
  35870. * Negative value indicates camera should not return to default.
  35871. */
  35872. elevationReturnTime: number;
  35873. /**
  35874. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35875. */
  35876. /**
  35877. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35878. */
  35879. elevationReturnWaitTime: number;
  35880. /**
  35881. * Sets the flag that indicates if user zooming should stop animation.
  35882. */
  35883. /**
  35884. * Gets the flag that indicates if user zooming should stop animation.
  35885. */
  35886. zoomStopsAnimation: boolean;
  35887. /**
  35888. * Sets the transition time when framing the mesh, in milliseconds
  35889. */
  35890. /**
  35891. * Gets the transition time when framing the mesh, in milliseconds
  35892. */
  35893. framingTime: number;
  35894. /**
  35895. * Define if the behavior should automatically change the configured
  35896. * camera limits and sensibilities.
  35897. */
  35898. autoCorrectCameraLimitsAndSensibility: boolean;
  35899. private _onPrePointerObservableObserver;
  35900. private _onAfterCheckInputsObserver;
  35901. private _onMeshTargetChangedObserver;
  35902. private _attachedCamera;
  35903. private _isPointerDown;
  35904. private _lastInteractionTime;
  35905. /**
  35906. * Initializes the behavior.
  35907. */
  35908. init(): void;
  35909. /**
  35910. * Attaches the behavior to its arc rotate camera.
  35911. * @param camera Defines the camera to attach the behavior to
  35912. */
  35913. attach(camera: ArcRotateCamera): void;
  35914. /**
  35915. * Detaches the behavior from its current arc rotate camera.
  35916. */
  35917. detach(): void;
  35918. private _animatables;
  35919. private _betaIsAnimating;
  35920. private _betaTransition;
  35921. private _radiusTransition;
  35922. private _vectorTransition;
  35923. /**
  35924. * Targets the given mesh and updates zoom level accordingly.
  35925. * @param mesh The mesh to target.
  35926. * @param radius Optional. If a cached radius position already exists, overrides default.
  35927. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35928. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35929. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35930. */
  35931. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35932. /**
  35933. * Targets the given mesh with its children and updates zoom level accordingly.
  35934. * @param mesh The mesh to target.
  35935. * @param radius Optional. If a cached radius position already exists, overrides default.
  35936. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35937. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35938. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35939. */
  35940. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35941. /**
  35942. * Targets the given meshes with their children and updates zoom level accordingly.
  35943. * @param meshes The mesh to target.
  35944. * @param radius Optional. If a cached radius position already exists, overrides default.
  35945. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35946. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35947. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35948. */
  35949. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35950. /**
  35951. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35952. * @param minimumWorld Determines the smaller position of the bounding box extend
  35953. * @param maximumWorld Determines the bigger position of the bounding box extend
  35954. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35955. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35956. */
  35957. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35958. /**
  35959. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35960. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35961. * frustum width.
  35962. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35963. * to fully enclose the mesh in the viewing frustum.
  35964. */
  35965. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35966. /**
  35967. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35968. * is automatically returned to its default position (expected to be above ground plane).
  35969. */
  35970. private _maintainCameraAboveGround;
  35971. /**
  35972. * Returns the frustum slope based on the canvas ratio and camera FOV
  35973. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35974. */
  35975. private _getFrustumSlope;
  35976. /**
  35977. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35978. */
  35979. private _clearAnimationLocks;
  35980. /**
  35981. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35982. */
  35983. private _applyUserInteraction;
  35984. /**
  35985. * Stops and removes all animations that have been applied to the camera
  35986. */
  35987. stopAllAnimations(): void;
  35988. /**
  35989. * Gets a value indicating if the user is moving the camera
  35990. */
  35991. readonly isUserIsMoving: boolean;
  35992. /**
  35993. * The camera can move all the way towards the mesh.
  35994. */
  35995. static IgnoreBoundsSizeMode: number;
  35996. /**
  35997. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35998. */
  35999. static FitFrustumSidesMode: number;
  36000. }
  36001. }
  36002. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36003. import { Nullable } from "babylonjs/types";
  36004. import { Camera } from "babylonjs/Cameras/camera";
  36005. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36006. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36007. /**
  36008. * Base class for Camera Pointer Inputs.
  36009. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36010. * for example usage.
  36011. */
  36012. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36013. /**
  36014. * Defines the camera the input is attached to.
  36015. */
  36016. abstract camera: Camera;
  36017. /**
  36018. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36019. */
  36020. protected _altKey: boolean;
  36021. protected _ctrlKey: boolean;
  36022. protected _metaKey: boolean;
  36023. protected _shiftKey: boolean;
  36024. /**
  36025. * Which mouse buttons were pressed at time of last mouse event.
  36026. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36027. */
  36028. protected _buttonsPressed: number;
  36029. /**
  36030. * Defines the buttons associated with the input to handle camera move.
  36031. */
  36032. buttons: number[];
  36033. /**
  36034. * Attach the input controls to a specific dom element to get the input from.
  36035. * @param element Defines the element the controls should be listened from
  36036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36037. */
  36038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36039. /**
  36040. * Detach the current controls from the specified dom element.
  36041. * @param element Defines the element to stop listening the inputs from
  36042. */
  36043. detachControl(element: Nullable<HTMLElement>): void;
  36044. /**
  36045. * Gets the class name of the current input.
  36046. * @returns the class name
  36047. */
  36048. getClassName(): string;
  36049. /**
  36050. * Get the friendly name associated with the input class.
  36051. * @returns the input friendly name
  36052. */
  36053. getSimpleName(): string;
  36054. /**
  36055. * Called on pointer POINTERDOUBLETAP event.
  36056. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36057. */
  36058. protected onDoubleTap(type: string): void;
  36059. /**
  36060. * Called on pointer POINTERMOVE event if only a single touch is active.
  36061. * Override this method to provide functionality.
  36062. */
  36063. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36064. /**
  36065. * Called on pointer POINTERMOVE event if multiple touches are active.
  36066. * Override this method to provide functionality.
  36067. */
  36068. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36069. /**
  36070. * Called on JS contextmenu event.
  36071. * Override this method to provide functionality.
  36072. */
  36073. protected onContextMenu(evt: PointerEvent): void;
  36074. /**
  36075. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36076. * press.
  36077. * Override this method to provide functionality.
  36078. */
  36079. protected onButtonDown(evt: PointerEvent): void;
  36080. /**
  36081. * Called each time a new POINTERUP event occurs. Ie, for each button
  36082. * release.
  36083. * Override this method to provide functionality.
  36084. */
  36085. protected onButtonUp(evt: PointerEvent): void;
  36086. /**
  36087. * Called when window becomes inactive.
  36088. * Override this method to provide functionality.
  36089. */
  36090. protected onLostFocus(): void;
  36091. private _pointerInput;
  36092. private _observer;
  36093. private _onLostFocus;
  36094. private pointA;
  36095. private pointB;
  36096. }
  36097. }
  36098. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36099. import { Nullable } from "babylonjs/types";
  36100. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36101. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36102. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36103. /**
  36104. * Manage the pointers inputs to control an arc rotate camera.
  36105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36106. */
  36107. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36108. /**
  36109. * Defines the camera the input is attached to.
  36110. */
  36111. camera: ArcRotateCamera;
  36112. /**
  36113. * Gets the class name of the current input.
  36114. * @returns the class name
  36115. */
  36116. getClassName(): string;
  36117. /**
  36118. * Defines the buttons associated with the input to handle camera move.
  36119. */
  36120. buttons: number[];
  36121. /**
  36122. * Defines the pointer angular sensibility along the X axis or how fast is
  36123. * the camera rotating.
  36124. */
  36125. angularSensibilityX: number;
  36126. /**
  36127. * Defines the pointer angular sensibility along the Y axis or how fast is
  36128. * the camera rotating.
  36129. */
  36130. angularSensibilityY: number;
  36131. /**
  36132. * Defines the pointer pinch precision or how fast is the camera zooming.
  36133. */
  36134. pinchPrecision: number;
  36135. /**
  36136. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36137. * from 0.
  36138. * It defines the percentage of current camera.radius to use as delta when
  36139. * pinch zoom is used.
  36140. */
  36141. pinchDeltaPercentage: number;
  36142. /**
  36143. * Defines the pointer panning sensibility or how fast is the camera moving.
  36144. */
  36145. panningSensibility: number;
  36146. /**
  36147. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36148. */
  36149. multiTouchPanning: boolean;
  36150. /**
  36151. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36152. * zoom (pinch) through multitouch.
  36153. */
  36154. multiTouchPanAndZoom: boolean;
  36155. /**
  36156. * Revers pinch action direction.
  36157. */
  36158. pinchInwards: boolean;
  36159. private _isPanClick;
  36160. private _twoFingerActivityCount;
  36161. private _isPinching;
  36162. /**
  36163. * Called on pointer POINTERMOVE event if only a single touch is active.
  36164. */
  36165. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36166. /**
  36167. * Called on pointer POINTERDOUBLETAP event.
  36168. */
  36169. protected onDoubleTap(type: string): void;
  36170. /**
  36171. * Called on pointer POINTERMOVE event if multiple touches are active.
  36172. */
  36173. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36174. /**
  36175. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36176. * press.
  36177. */
  36178. protected onButtonDown(evt: PointerEvent): void;
  36179. /**
  36180. * Called each time a new POINTERUP event occurs. Ie, for each button
  36181. * release.
  36182. */
  36183. protected onButtonUp(evt: PointerEvent): void;
  36184. /**
  36185. * Called when window becomes inactive.
  36186. */
  36187. protected onLostFocus(): void;
  36188. }
  36189. }
  36190. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36191. import { Nullable } from "babylonjs/types";
  36192. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36193. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36194. /**
  36195. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36197. */
  36198. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36199. /**
  36200. * Defines the camera the input is attached to.
  36201. */
  36202. camera: ArcRotateCamera;
  36203. /**
  36204. * Defines the list of key codes associated with the up action (increase alpha)
  36205. */
  36206. keysUp: number[];
  36207. /**
  36208. * Defines the list of key codes associated with the down action (decrease alpha)
  36209. */
  36210. keysDown: number[];
  36211. /**
  36212. * Defines the list of key codes associated with the left action (increase beta)
  36213. */
  36214. keysLeft: number[];
  36215. /**
  36216. * Defines the list of key codes associated with the right action (decrease beta)
  36217. */
  36218. keysRight: number[];
  36219. /**
  36220. * Defines the list of key codes associated with the reset action.
  36221. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36222. */
  36223. keysReset: number[];
  36224. /**
  36225. * Defines the panning sensibility of the inputs.
  36226. * (How fast is the camera paning)
  36227. */
  36228. panningSensibility: number;
  36229. /**
  36230. * Defines the zooming sensibility of the inputs.
  36231. * (How fast is the camera zooming)
  36232. */
  36233. zoomingSensibility: number;
  36234. /**
  36235. * Defines wether maintaining the alt key down switch the movement mode from
  36236. * orientation to zoom.
  36237. */
  36238. useAltToZoom: boolean;
  36239. /**
  36240. * Rotation speed of the camera
  36241. */
  36242. angularSpeed: number;
  36243. private _keys;
  36244. private _ctrlPressed;
  36245. private _altPressed;
  36246. private _onCanvasBlurObserver;
  36247. private _onKeyboardObserver;
  36248. private _engine;
  36249. private _scene;
  36250. /**
  36251. * Attach the input controls to a specific dom element to get the input from.
  36252. * @param element Defines the element the controls should be listened from
  36253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36254. */
  36255. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36256. /**
  36257. * Detach the current controls from the specified dom element.
  36258. * @param element Defines the element to stop listening the inputs from
  36259. */
  36260. detachControl(element: Nullable<HTMLElement>): void;
  36261. /**
  36262. * Update the current camera state depending on the inputs that have been used this frame.
  36263. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36264. */
  36265. checkInputs(): void;
  36266. /**
  36267. * Gets the class name of the current intput.
  36268. * @returns the class name
  36269. */
  36270. getClassName(): string;
  36271. /**
  36272. * Get the friendly name associated with the input class.
  36273. * @returns the input friendly name
  36274. */
  36275. getSimpleName(): string;
  36276. }
  36277. }
  36278. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36279. import { Nullable } from "babylonjs/types";
  36280. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36281. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36282. /**
  36283. * Manage the mouse wheel inputs to control an arc rotate camera.
  36284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36285. */
  36286. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36287. /**
  36288. * Defines the camera the input is attached to.
  36289. */
  36290. camera: ArcRotateCamera;
  36291. /**
  36292. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36293. */
  36294. wheelPrecision: number;
  36295. /**
  36296. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36297. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36298. */
  36299. wheelDeltaPercentage: number;
  36300. private _wheel;
  36301. private _observer;
  36302. private computeDeltaFromMouseWheelLegacyEvent;
  36303. /**
  36304. * Attach the input controls to a specific dom element to get the input from.
  36305. * @param element Defines the element the controls should be listened from
  36306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36307. */
  36308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36309. /**
  36310. * Detach the current controls from the specified dom element.
  36311. * @param element Defines the element to stop listening the inputs from
  36312. */
  36313. detachControl(element: Nullable<HTMLElement>): void;
  36314. /**
  36315. * Gets the class name of the current intput.
  36316. * @returns the class name
  36317. */
  36318. getClassName(): string;
  36319. /**
  36320. * Get the friendly name associated with the input class.
  36321. * @returns the input friendly name
  36322. */
  36323. getSimpleName(): string;
  36324. }
  36325. }
  36326. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36327. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36328. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36329. /**
  36330. * Default Inputs manager for the ArcRotateCamera.
  36331. * It groups all the default supported inputs for ease of use.
  36332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36333. */
  36334. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36335. /**
  36336. * Instantiates a new ArcRotateCameraInputsManager.
  36337. * @param camera Defines the camera the inputs belong to
  36338. */
  36339. constructor(camera: ArcRotateCamera);
  36340. /**
  36341. * Add mouse wheel input support to the input manager.
  36342. * @returns the current input manager
  36343. */
  36344. addMouseWheel(): ArcRotateCameraInputsManager;
  36345. /**
  36346. * Add pointers input support to the input manager.
  36347. * @returns the current input manager
  36348. */
  36349. addPointers(): ArcRotateCameraInputsManager;
  36350. /**
  36351. * Add keyboard input support to the input manager.
  36352. * @returns the current input manager
  36353. */
  36354. addKeyboard(): ArcRotateCameraInputsManager;
  36355. }
  36356. }
  36357. declare module "babylonjs/Cameras/arcRotateCamera" {
  36358. import { Observable } from "babylonjs/Misc/observable";
  36359. import { Nullable } from "babylonjs/types";
  36360. import { Scene } from "babylonjs/scene";
  36361. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36363. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36364. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36365. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36366. import { Camera } from "babylonjs/Cameras/camera";
  36367. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36368. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36369. import { Collider } from "babylonjs/Collisions/collider";
  36370. /**
  36371. * This represents an orbital type of camera.
  36372. *
  36373. * 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.
  36374. * 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.
  36375. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36376. */
  36377. export class ArcRotateCamera extends TargetCamera {
  36378. /**
  36379. * Defines the rotation angle of the camera along the longitudinal axis.
  36380. */
  36381. alpha: number;
  36382. /**
  36383. * Defines the rotation angle of the camera along the latitudinal axis.
  36384. */
  36385. beta: number;
  36386. /**
  36387. * Defines the radius of the camera from it s target point.
  36388. */
  36389. radius: number;
  36390. protected _target: Vector3;
  36391. protected _targetHost: Nullable<AbstractMesh>;
  36392. /**
  36393. * Defines the target point of the camera.
  36394. * The camera looks towards it form the radius distance.
  36395. */
  36396. target: Vector3;
  36397. /**
  36398. * Define the current local position of the camera in the scene
  36399. */
  36400. position: Vector3;
  36401. protected _upVector: Vector3;
  36402. protected _upToYMatrix: Matrix;
  36403. protected _YToUpMatrix: Matrix;
  36404. /**
  36405. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36406. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36407. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36408. */
  36409. upVector: Vector3;
  36410. /**
  36411. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36412. */
  36413. setMatUp(): void;
  36414. /**
  36415. * Current inertia value on the longitudinal axis.
  36416. * The bigger this number the longer it will take for the camera to stop.
  36417. */
  36418. inertialAlphaOffset: number;
  36419. /**
  36420. * Current inertia value on the latitudinal axis.
  36421. * The bigger this number the longer it will take for the camera to stop.
  36422. */
  36423. inertialBetaOffset: number;
  36424. /**
  36425. * Current inertia value on the radius axis.
  36426. * The bigger this number the longer it will take for the camera to stop.
  36427. */
  36428. inertialRadiusOffset: number;
  36429. /**
  36430. * Minimum allowed angle on the longitudinal axis.
  36431. * This can help limiting how the Camera is able to move in the scene.
  36432. */
  36433. lowerAlphaLimit: Nullable<number>;
  36434. /**
  36435. * Maximum allowed angle on the longitudinal axis.
  36436. * This can help limiting how the Camera is able to move in the scene.
  36437. */
  36438. upperAlphaLimit: Nullable<number>;
  36439. /**
  36440. * Minimum allowed angle on the latitudinal axis.
  36441. * This can help limiting how the Camera is able to move in the scene.
  36442. */
  36443. lowerBetaLimit: number;
  36444. /**
  36445. * Maximum allowed angle on the latitudinal axis.
  36446. * This can help limiting how the Camera is able to move in the scene.
  36447. */
  36448. upperBetaLimit: number;
  36449. /**
  36450. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36451. * This can help limiting how the Camera is able to move in the scene.
  36452. */
  36453. lowerRadiusLimit: Nullable<number>;
  36454. /**
  36455. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36456. * This can help limiting how the Camera is able to move in the scene.
  36457. */
  36458. upperRadiusLimit: Nullable<number>;
  36459. /**
  36460. * Defines the current inertia value used during panning of the camera along the X axis.
  36461. */
  36462. inertialPanningX: number;
  36463. /**
  36464. * Defines the current inertia value used during panning of the camera along the Y axis.
  36465. */
  36466. inertialPanningY: number;
  36467. /**
  36468. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36469. * Basically if your fingers moves away from more than this distance you will be considered
  36470. * in pinch mode.
  36471. */
  36472. pinchToPanMaxDistance: number;
  36473. /**
  36474. * Defines the maximum distance the camera can pan.
  36475. * This could help keeping the cammera always in your scene.
  36476. */
  36477. panningDistanceLimit: Nullable<number>;
  36478. /**
  36479. * Defines the target of the camera before paning.
  36480. */
  36481. panningOriginTarget: Vector3;
  36482. /**
  36483. * Defines the value of the inertia used during panning.
  36484. * 0 would mean stop inertia and one would mean no decelleration at all.
  36485. */
  36486. panningInertia: number;
  36487. /**
  36488. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36489. */
  36490. angularSensibilityX: number;
  36491. /**
  36492. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36493. */
  36494. angularSensibilityY: number;
  36495. /**
  36496. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36497. */
  36498. pinchPrecision: number;
  36499. /**
  36500. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36501. * It will be used instead of pinchDeltaPrecision if different from 0.
  36502. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36503. */
  36504. pinchDeltaPercentage: number;
  36505. /**
  36506. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36507. */
  36508. panningSensibility: number;
  36509. /**
  36510. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36511. */
  36512. keysUp: number[];
  36513. /**
  36514. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36515. */
  36516. keysDown: number[];
  36517. /**
  36518. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36519. */
  36520. keysLeft: number[];
  36521. /**
  36522. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36523. */
  36524. keysRight: number[];
  36525. /**
  36526. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36527. */
  36528. wheelPrecision: number;
  36529. /**
  36530. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36531. * It will be used instead of pinchDeltaPrecision if different from 0.
  36532. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36533. */
  36534. wheelDeltaPercentage: number;
  36535. /**
  36536. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36537. */
  36538. zoomOnFactor: number;
  36539. /**
  36540. * Defines a screen offset for the camera position.
  36541. */
  36542. targetScreenOffset: Vector2;
  36543. /**
  36544. * Allows the camera to be completely reversed.
  36545. * If false the camera can not arrive upside down.
  36546. */
  36547. allowUpsideDown: boolean;
  36548. /**
  36549. * Define if double tap/click is used to restore the previously saved state of the camera.
  36550. */
  36551. useInputToRestoreState: boolean;
  36552. /** @hidden */
  36553. _viewMatrix: Matrix;
  36554. /** @hidden */
  36555. _useCtrlForPanning: boolean;
  36556. /** @hidden */
  36557. _panningMouseButton: number;
  36558. /**
  36559. * Defines the input associated to the camera.
  36560. */
  36561. inputs: ArcRotateCameraInputsManager;
  36562. /** @hidden */
  36563. _reset: () => void;
  36564. /**
  36565. * Defines the allowed panning axis.
  36566. */
  36567. panningAxis: Vector3;
  36568. protected _localDirection: Vector3;
  36569. protected _transformedDirection: Vector3;
  36570. private _bouncingBehavior;
  36571. /**
  36572. * Gets the bouncing behavior of the camera if it has been enabled.
  36573. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36574. */
  36575. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36576. /**
  36577. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36578. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36579. */
  36580. useBouncingBehavior: boolean;
  36581. private _framingBehavior;
  36582. /**
  36583. * Gets the framing behavior of the camera if it has been enabled.
  36584. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36585. */
  36586. readonly framingBehavior: Nullable<FramingBehavior>;
  36587. /**
  36588. * Defines if the framing behavior of the camera is enabled on the camera.
  36589. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36590. */
  36591. useFramingBehavior: boolean;
  36592. private _autoRotationBehavior;
  36593. /**
  36594. * Gets the auto rotation behavior of the camera if it has been enabled.
  36595. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36596. */
  36597. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36598. /**
  36599. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36600. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36601. */
  36602. useAutoRotationBehavior: boolean;
  36603. /**
  36604. * Observable triggered when the mesh target has been changed on the camera.
  36605. */
  36606. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36607. /**
  36608. * Event raised when the camera is colliding with a mesh.
  36609. */
  36610. onCollide: (collidedMesh: AbstractMesh) => void;
  36611. /**
  36612. * Defines whether the camera should check collision with the objects oh the scene.
  36613. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36614. */
  36615. checkCollisions: boolean;
  36616. /**
  36617. * Defines the collision radius of the camera.
  36618. * This simulates a sphere around the camera.
  36619. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36620. */
  36621. collisionRadius: Vector3;
  36622. protected _collider: Collider;
  36623. protected _previousPosition: Vector3;
  36624. protected _collisionVelocity: Vector3;
  36625. protected _newPosition: Vector3;
  36626. protected _previousAlpha: number;
  36627. protected _previousBeta: number;
  36628. protected _previousRadius: number;
  36629. protected _collisionTriggered: boolean;
  36630. protected _targetBoundingCenter: Nullable<Vector3>;
  36631. private _computationVector;
  36632. /**
  36633. * Instantiates a new ArcRotateCamera in a given scene
  36634. * @param name Defines the name of the camera
  36635. * @param alpha Defines the camera rotation along the logitudinal axis
  36636. * @param beta Defines the camera rotation along the latitudinal axis
  36637. * @param radius Defines the camera distance from its target
  36638. * @param target Defines the camera target
  36639. * @param scene Defines the scene the camera belongs to
  36640. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36641. */
  36642. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36643. /** @hidden */
  36644. _initCache(): void;
  36645. /** @hidden */
  36646. _updateCache(ignoreParentClass?: boolean): void;
  36647. protected _getTargetPosition(): Vector3;
  36648. private _storedAlpha;
  36649. private _storedBeta;
  36650. private _storedRadius;
  36651. private _storedTarget;
  36652. /**
  36653. * Stores the current state of the camera (alpha, beta, radius and target)
  36654. * @returns the camera itself
  36655. */
  36656. storeState(): Camera;
  36657. /**
  36658. * @hidden
  36659. * Restored camera state. You must call storeState() first
  36660. */
  36661. _restoreStateValues(): boolean;
  36662. /** @hidden */
  36663. _isSynchronizedViewMatrix(): boolean;
  36664. /**
  36665. * Attached controls to the current camera.
  36666. * @param element Defines the element the controls should be listened from
  36667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36668. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36669. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36670. */
  36671. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36672. /**
  36673. * Detach the current controls from the camera.
  36674. * The camera will stop reacting to inputs.
  36675. * @param element Defines the element to stop listening the inputs from
  36676. */
  36677. detachControl(element: HTMLElement): void;
  36678. /** @hidden */
  36679. _checkInputs(): void;
  36680. protected _checkLimits(): void;
  36681. /**
  36682. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36683. */
  36684. rebuildAnglesAndRadius(): void;
  36685. /**
  36686. * Use a position to define the current camera related information like aplha, beta and radius
  36687. * @param position Defines the position to set the camera at
  36688. */
  36689. setPosition(position: Vector3): void;
  36690. /**
  36691. * Defines the target the camera should look at.
  36692. * This will automatically adapt alpha beta and radius to fit within the new target.
  36693. * @param target Defines the new target as a Vector or a mesh
  36694. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36695. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36696. */
  36697. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36698. /** @hidden */
  36699. _getViewMatrix(): Matrix;
  36700. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36701. /**
  36702. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36703. * @param meshes Defines the mesh to zoom on
  36704. * @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)
  36705. */
  36706. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36707. /**
  36708. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36709. * The target will be changed but the radius
  36710. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36711. * @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)
  36712. */
  36713. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36714. min: Vector3;
  36715. max: Vector3;
  36716. distance: number;
  36717. }, doNotUpdateMaxZ?: boolean): void;
  36718. /**
  36719. * @override
  36720. * Override Camera.createRigCamera
  36721. */
  36722. createRigCamera(name: string, cameraIndex: number): Camera;
  36723. /**
  36724. * @hidden
  36725. * @override
  36726. * Override Camera._updateRigCameras
  36727. */
  36728. _updateRigCameras(): void;
  36729. /**
  36730. * Destroy the camera and release the current resources hold by it.
  36731. */
  36732. dispose(): void;
  36733. /**
  36734. * Gets the current object class name.
  36735. * @return the class name
  36736. */
  36737. getClassName(): string;
  36738. }
  36739. }
  36740. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36741. import { Behavior } from "babylonjs/Behaviors/behavior";
  36742. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36743. /**
  36744. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36745. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36746. */
  36747. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36748. /**
  36749. * Gets the name of the behavior.
  36750. */
  36751. readonly name: string;
  36752. private _zoomStopsAnimation;
  36753. private _idleRotationSpeed;
  36754. private _idleRotationWaitTime;
  36755. private _idleRotationSpinupTime;
  36756. /**
  36757. * Sets the flag that indicates if user zooming should stop animation.
  36758. */
  36759. /**
  36760. * Gets the flag that indicates if user zooming should stop animation.
  36761. */
  36762. zoomStopsAnimation: boolean;
  36763. /**
  36764. * Sets the default speed at which the camera rotates around the model.
  36765. */
  36766. /**
  36767. * Gets the default speed at which the camera rotates around the model.
  36768. */
  36769. idleRotationSpeed: number;
  36770. /**
  36771. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36772. */
  36773. /**
  36774. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36775. */
  36776. idleRotationWaitTime: number;
  36777. /**
  36778. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36779. */
  36780. /**
  36781. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36782. */
  36783. idleRotationSpinupTime: number;
  36784. /**
  36785. * Gets a value indicating if the camera is currently rotating because of this behavior
  36786. */
  36787. readonly rotationInProgress: boolean;
  36788. private _onPrePointerObservableObserver;
  36789. private _onAfterCheckInputsObserver;
  36790. private _attachedCamera;
  36791. private _isPointerDown;
  36792. private _lastFrameTime;
  36793. private _lastInteractionTime;
  36794. private _cameraRotationSpeed;
  36795. /**
  36796. * Initializes the behavior.
  36797. */
  36798. init(): void;
  36799. /**
  36800. * Attaches the behavior to its arc rotate camera.
  36801. * @param camera Defines the camera to attach the behavior to
  36802. */
  36803. attach(camera: ArcRotateCamera): void;
  36804. /**
  36805. * Detaches the behavior from its current arc rotate camera.
  36806. */
  36807. detach(): void;
  36808. /**
  36809. * Returns true if user is scrolling.
  36810. * @return true if user is scrolling.
  36811. */
  36812. private _userIsZooming;
  36813. private _lastFrameRadius;
  36814. private _shouldAnimationStopForInteraction;
  36815. /**
  36816. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36817. */
  36818. private _applyUserInteraction;
  36819. private _userIsMoving;
  36820. }
  36821. }
  36822. declare module "babylonjs/Behaviors/Cameras/index" {
  36823. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36824. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36825. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36826. }
  36827. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36828. import { Mesh } from "babylonjs/Meshes/mesh";
  36829. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36830. import { Behavior } from "babylonjs/Behaviors/behavior";
  36831. /**
  36832. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36833. */
  36834. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36835. private ui;
  36836. /**
  36837. * The name of the behavior
  36838. */
  36839. name: string;
  36840. /**
  36841. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36842. */
  36843. distanceAwayFromFace: number;
  36844. /**
  36845. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36846. */
  36847. distanceAwayFromBottomOfFace: number;
  36848. private _faceVectors;
  36849. private _target;
  36850. private _scene;
  36851. private _onRenderObserver;
  36852. private _tmpMatrix;
  36853. private _tmpVector;
  36854. /**
  36855. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36856. * @param ui The transform node that should be attched to the mesh
  36857. */
  36858. constructor(ui: TransformNode);
  36859. /**
  36860. * Initializes the behavior
  36861. */
  36862. init(): void;
  36863. private _closestFace;
  36864. private _zeroVector;
  36865. private _lookAtTmpMatrix;
  36866. private _lookAtToRef;
  36867. /**
  36868. * Attaches the AttachToBoxBehavior to the passed in mesh
  36869. * @param target The mesh that the specified node will be attached to
  36870. */
  36871. attach(target: Mesh): void;
  36872. /**
  36873. * Detaches the behavior from the mesh
  36874. */
  36875. detach(): void;
  36876. }
  36877. }
  36878. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36879. import { Behavior } from "babylonjs/Behaviors/behavior";
  36880. import { Mesh } from "babylonjs/Meshes/mesh";
  36881. /**
  36882. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36883. */
  36884. export class FadeInOutBehavior implements Behavior<Mesh> {
  36885. /**
  36886. * Time in milliseconds to delay before fading in (Default: 0)
  36887. */
  36888. delay: number;
  36889. /**
  36890. * Time in milliseconds for the mesh to fade in (Default: 300)
  36891. */
  36892. fadeInTime: number;
  36893. private _millisecondsPerFrame;
  36894. private _hovered;
  36895. private _hoverValue;
  36896. private _ownerNode;
  36897. /**
  36898. * Instatiates the FadeInOutBehavior
  36899. */
  36900. constructor();
  36901. /**
  36902. * The name of the behavior
  36903. */
  36904. readonly name: string;
  36905. /**
  36906. * Initializes the behavior
  36907. */
  36908. init(): void;
  36909. /**
  36910. * Attaches the fade behavior on the passed in mesh
  36911. * @param ownerNode The mesh that will be faded in/out once attached
  36912. */
  36913. attach(ownerNode: Mesh): void;
  36914. /**
  36915. * Detaches the behavior from the mesh
  36916. */
  36917. detach(): void;
  36918. /**
  36919. * Triggers the mesh to begin fading in or out
  36920. * @param value if the object should fade in or out (true to fade in)
  36921. */
  36922. fadeIn(value: boolean): void;
  36923. private _update;
  36924. private _setAllVisibility;
  36925. }
  36926. }
  36927. declare module "babylonjs/Misc/pivotTools" {
  36928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36929. /**
  36930. * Class containing a set of static utilities functions for managing Pivots
  36931. * @hidden
  36932. */
  36933. export class PivotTools {
  36934. private static _PivotCached;
  36935. private static _OldPivotPoint;
  36936. private static _PivotTranslation;
  36937. private static _PivotTmpVector;
  36938. /** @hidden */
  36939. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36940. /** @hidden */
  36941. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36942. }
  36943. }
  36944. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36945. import { Scene } from "babylonjs/scene";
  36946. import { Vector4, Plane } from "babylonjs/Maths/math";
  36947. import { Mesh } from "babylonjs/Meshes/mesh";
  36948. import { Nullable } from "babylonjs/types";
  36949. /**
  36950. * Class containing static functions to help procedurally build meshes
  36951. */
  36952. export class PlaneBuilder {
  36953. /**
  36954. * Creates a plane mesh
  36955. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36956. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36957. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36961. * @param name defines the name of the mesh
  36962. * @param options defines the options used to create the mesh
  36963. * @param scene defines the hosting scene
  36964. * @returns the plane mesh
  36965. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36966. */
  36967. static CreatePlane(name: string, options: {
  36968. size?: number;
  36969. width?: number;
  36970. height?: number;
  36971. sideOrientation?: number;
  36972. frontUVs?: Vector4;
  36973. backUVs?: Vector4;
  36974. updatable?: boolean;
  36975. sourcePlane?: Plane;
  36976. }, scene?: Nullable<Scene>): Mesh;
  36977. }
  36978. }
  36979. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36980. import { Behavior } from "babylonjs/Behaviors/behavior";
  36981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36982. import { Observable } from "babylonjs/Misc/observable";
  36983. import { Vector3 } from "babylonjs/Maths/math";
  36984. import { Ray } from "babylonjs/Culling/ray";
  36985. import "babylonjs/Meshes/Builders/planeBuilder";
  36986. /**
  36987. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36988. */
  36989. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36990. private static _AnyMouseID;
  36991. /**
  36992. * Abstract mesh the behavior is set on
  36993. */
  36994. attachedNode: AbstractMesh;
  36995. private _dragPlane;
  36996. private _scene;
  36997. private _pointerObserver;
  36998. private _beforeRenderObserver;
  36999. private static _planeScene;
  37000. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37001. /**
  37002. * 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)
  37003. */
  37004. maxDragAngle: number;
  37005. /**
  37006. * @hidden
  37007. */
  37008. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37009. /**
  37010. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37011. */
  37012. currentDraggingPointerID: number;
  37013. /**
  37014. * The last position where the pointer hit the drag plane in world space
  37015. */
  37016. lastDragPosition: Vector3;
  37017. /**
  37018. * If the behavior is currently in a dragging state
  37019. */
  37020. dragging: boolean;
  37021. /**
  37022. * 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)
  37023. */
  37024. dragDeltaRatio: number;
  37025. /**
  37026. * If the drag plane orientation should be updated during the dragging (Default: true)
  37027. */
  37028. updateDragPlane: boolean;
  37029. private _debugMode;
  37030. private _moving;
  37031. /**
  37032. * Fires each time the attached mesh is dragged with the pointer
  37033. * * delta between last drag position and current drag position in world space
  37034. * * dragDistance along the drag axis
  37035. * * dragPlaneNormal normal of the current drag plane used during the drag
  37036. * * dragPlanePoint in world space where the drag intersects the drag plane
  37037. */
  37038. onDragObservable: Observable<{
  37039. delta: Vector3;
  37040. dragPlanePoint: Vector3;
  37041. dragPlaneNormal: Vector3;
  37042. dragDistance: number;
  37043. pointerId: number;
  37044. }>;
  37045. /**
  37046. * Fires each time a drag begins (eg. mouse down on mesh)
  37047. */
  37048. onDragStartObservable: Observable<{
  37049. dragPlanePoint: Vector3;
  37050. pointerId: number;
  37051. }>;
  37052. /**
  37053. * Fires each time a drag ends (eg. mouse release after drag)
  37054. */
  37055. onDragEndObservable: Observable<{
  37056. dragPlanePoint: Vector3;
  37057. pointerId: number;
  37058. }>;
  37059. /**
  37060. * If the attached mesh should be moved when dragged
  37061. */
  37062. moveAttached: boolean;
  37063. /**
  37064. * If the drag behavior will react to drag events (Default: true)
  37065. */
  37066. enabled: boolean;
  37067. /**
  37068. * If camera controls should be detached during the drag
  37069. */
  37070. detachCameraControls: boolean;
  37071. /**
  37072. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37073. */
  37074. useObjectOrienationForDragging: boolean;
  37075. private _options;
  37076. /**
  37077. * Creates a pointer drag behavior that can be attached to a mesh
  37078. * @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)
  37079. */
  37080. constructor(options?: {
  37081. dragAxis?: Vector3;
  37082. dragPlaneNormal?: Vector3;
  37083. });
  37084. /**
  37085. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37086. */
  37087. validateDrag: (targetPosition: Vector3) => boolean;
  37088. /**
  37089. * The name of the behavior
  37090. */
  37091. readonly name: string;
  37092. /**
  37093. * Initializes the behavior
  37094. */
  37095. init(): void;
  37096. private _tmpVector;
  37097. private _alternatePickedPoint;
  37098. private _worldDragAxis;
  37099. private _targetPosition;
  37100. private _attachedElement;
  37101. /**
  37102. * Attaches the drag behavior the passed in mesh
  37103. * @param ownerNode The mesh that will be dragged around once attached
  37104. */
  37105. attach(ownerNode: AbstractMesh): void;
  37106. /**
  37107. * Force relase the drag action by code.
  37108. */
  37109. releaseDrag(): void;
  37110. private _startDragRay;
  37111. private _lastPointerRay;
  37112. /**
  37113. * Simulates the start of a pointer drag event on the behavior
  37114. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37115. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37116. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37117. */
  37118. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37119. private _startDrag;
  37120. private _dragDelta;
  37121. private _moveDrag;
  37122. private _pickWithRayOnDragPlane;
  37123. private _pointA;
  37124. private _pointB;
  37125. private _pointC;
  37126. private _lineA;
  37127. private _lineB;
  37128. private _localAxis;
  37129. private _lookAt;
  37130. private _updateDragPlanePosition;
  37131. /**
  37132. * Detaches the behavior from the mesh
  37133. */
  37134. detach(): void;
  37135. }
  37136. }
  37137. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37138. import { Mesh } from "babylonjs/Meshes/mesh";
  37139. import { Behavior } from "babylonjs/Behaviors/behavior";
  37140. /**
  37141. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37142. */
  37143. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37144. private _dragBehaviorA;
  37145. private _dragBehaviorB;
  37146. private _startDistance;
  37147. private _initialScale;
  37148. private _targetScale;
  37149. private _ownerNode;
  37150. private _sceneRenderObserver;
  37151. /**
  37152. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37153. */
  37154. constructor();
  37155. /**
  37156. * The name of the behavior
  37157. */
  37158. readonly name: string;
  37159. /**
  37160. * Initializes the behavior
  37161. */
  37162. init(): void;
  37163. private _getCurrentDistance;
  37164. /**
  37165. * Attaches the scale behavior the passed in mesh
  37166. * @param ownerNode The mesh that will be scaled around once attached
  37167. */
  37168. attach(ownerNode: Mesh): void;
  37169. /**
  37170. * Detaches the behavior from the mesh
  37171. */
  37172. detach(): void;
  37173. }
  37174. }
  37175. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37176. import { Behavior } from "babylonjs/Behaviors/behavior";
  37177. import { Mesh } from "babylonjs/Meshes/mesh";
  37178. import { Observable } from "babylonjs/Misc/observable";
  37179. /**
  37180. * 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
  37181. */
  37182. export class SixDofDragBehavior implements Behavior<Mesh> {
  37183. private static _virtualScene;
  37184. private _ownerNode;
  37185. private _sceneRenderObserver;
  37186. private _scene;
  37187. private _targetPosition;
  37188. private _virtualOriginMesh;
  37189. private _virtualDragMesh;
  37190. private _pointerObserver;
  37191. private _moving;
  37192. private _startingOrientation;
  37193. /**
  37194. * 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)
  37195. */
  37196. private zDragFactor;
  37197. /**
  37198. * If the object should rotate to face the drag origin
  37199. */
  37200. rotateDraggedObject: boolean;
  37201. /**
  37202. * If the behavior is currently in a dragging state
  37203. */
  37204. dragging: boolean;
  37205. /**
  37206. * 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)
  37207. */
  37208. dragDeltaRatio: number;
  37209. /**
  37210. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37211. */
  37212. currentDraggingPointerID: number;
  37213. /**
  37214. * If camera controls should be detached during the drag
  37215. */
  37216. detachCameraControls: boolean;
  37217. /**
  37218. * Fires each time a drag starts
  37219. */
  37220. onDragStartObservable: Observable<{}>;
  37221. /**
  37222. * Fires each time a drag ends (eg. mouse release after drag)
  37223. */
  37224. onDragEndObservable: Observable<{}>;
  37225. /**
  37226. * 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
  37227. */
  37228. constructor();
  37229. /**
  37230. * The name of the behavior
  37231. */
  37232. readonly name: string;
  37233. /**
  37234. * Initializes the behavior
  37235. */
  37236. init(): void;
  37237. /**
  37238. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37239. */
  37240. private readonly _pointerCamera;
  37241. /**
  37242. * Attaches the scale behavior the passed in mesh
  37243. * @param ownerNode The mesh that will be scaled around once attached
  37244. */
  37245. attach(ownerNode: Mesh): void;
  37246. /**
  37247. * Detaches the behavior from the mesh
  37248. */
  37249. detach(): void;
  37250. }
  37251. }
  37252. declare module "babylonjs/Behaviors/Meshes/index" {
  37253. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37254. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37255. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37256. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37257. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37258. }
  37259. declare module "babylonjs/Behaviors/index" {
  37260. export * from "babylonjs/Behaviors/behavior";
  37261. export * from "babylonjs/Behaviors/Cameras/index";
  37262. export * from "babylonjs/Behaviors/Meshes/index";
  37263. }
  37264. declare module "babylonjs/Bones/boneIKController" {
  37265. import { Bone } from "babylonjs/Bones/bone";
  37266. import { Vector3 } from "babylonjs/Maths/math";
  37267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37268. import { Nullable } from "babylonjs/types";
  37269. /**
  37270. * Class used to apply inverse kinematics to bones
  37271. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37272. */
  37273. export class BoneIKController {
  37274. private static _tmpVecs;
  37275. private static _tmpQuat;
  37276. private static _tmpMats;
  37277. /**
  37278. * Gets or sets the target mesh
  37279. */
  37280. targetMesh: AbstractMesh;
  37281. /** Gets or sets the mesh used as pole */
  37282. poleTargetMesh: AbstractMesh;
  37283. /**
  37284. * Gets or sets the bone used as pole
  37285. */
  37286. poleTargetBone: Nullable<Bone>;
  37287. /**
  37288. * Gets or sets the target position
  37289. */
  37290. targetPosition: Vector3;
  37291. /**
  37292. * Gets or sets the pole target position
  37293. */
  37294. poleTargetPosition: Vector3;
  37295. /**
  37296. * Gets or sets the pole target local offset
  37297. */
  37298. poleTargetLocalOffset: Vector3;
  37299. /**
  37300. * Gets or sets the pole angle
  37301. */
  37302. poleAngle: number;
  37303. /**
  37304. * Gets or sets the mesh associated with the controller
  37305. */
  37306. mesh: AbstractMesh;
  37307. /**
  37308. * 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)
  37309. */
  37310. slerpAmount: number;
  37311. private _bone1Quat;
  37312. private _bone1Mat;
  37313. private _bone2Ang;
  37314. private _bone1;
  37315. private _bone2;
  37316. private _bone1Length;
  37317. private _bone2Length;
  37318. private _maxAngle;
  37319. private _maxReach;
  37320. private _rightHandedSystem;
  37321. private _bendAxis;
  37322. private _slerping;
  37323. private _adjustRoll;
  37324. /**
  37325. * Gets or sets maximum allowed angle
  37326. */
  37327. maxAngle: number;
  37328. /**
  37329. * Creates a new BoneIKController
  37330. * @param mesh defines the mesh to control
  37331. * @param bone defines the bone to control
  37332. * @param options defines options to set up the controller
  37333. */
  37334. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37335. targetMesh?: AbstractMesh;
  37336. poleTargetMesh?: AbstractMesh;
  37337. poleTargetBone?: Bone;
  37338. poleTargetLocalOffset?: Vector3;
  37339. poleAngle?: number;
  37340. bendAxis?: Vector3;
  37341. maxAngle?: number;
  37342. slerpAmount?: number;
  37343. });
  37344. private _setMaxAngle;
  37345. /**
  37346. * Force the controller to update the bones
  37347. */
  37348. update(): void;
  37349. }
  37350. }
  37351. declare module "babylonjs/Bones/boneLookController" {
  37352. import { Vector3, Space } from "babylonjs/Maths/math";
  37353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37354. import { Bone } from "babylonjs/Bones/bone";
  37355. /**
  37356. * Class used to make a bone look toward a point in space
  37357. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37358. */
  37359. export class BoneLookController {
  37360. private static _tmpVecs;
  37361. private static _tmpQuat;
  37362. private static _tmpMats;
  37363. /**
  37364. * The target Vector3 that the bone will look at
  37365. */
  37366. target: Vector3;
  37367. /**
  37368. * The mesh that the bone is attached to
  37369. */
  37370. mesh: AbstractMesh;
  37371. /**
  37372. * The bone that will be looking to the target
  37373. */
  37374. bone: Bone;
  37375. /**
  37376. * The up axis of the coordinate system that is used when the bone is rotated
  37377. */
  37378. upAxis: Vector3;
  37379. /**
  37380. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37381. */
  37382. upAxisSpace: Space;
  37383. /**
  37384. * Used to make an adjustment to the yaw of the bone
  37385. */
  37386. adjustYaw: number;
  37387. /**
  37388. * Used to make an adjustment to the pitch of the bone
  37389. */
  37390. adjustPitch: number;
  37391. /**
  37392. * Used to make an adjustment to the roll of the bone
  37393. */
  37394. adjustRoll: number;
  37395. /**
  37396. * 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)
  37397. */
  37398. slerpAmount: number;
  37399. private _minYaw;
  37400. private _maxYaw;
  37401. private _minPitch;
  37402. private _maxPitch;
  37403. private _minYawSin;
  37404. private _minYawCos;
  37405. private _maxYawSin;
  37406. private _maxYawCos;
  37407. private _midYawConstraint;
  37408. private _minPitchTan;
  37409. private _maxPitchTan;
  37410. private _boneQuat;
  37411. private _slerping;
  37412. private _transformYawPitch;
  37413. private _transformYawPitchInv;
  37414. private _firstFrameSkipped;
  37415. private _yawRange;
  37416. private _fowardAxis;
  37417. /**
  37418. * Gets or sets the minimum yaw angle that the bone can look to
  37419. */
  37420. minYaw: number;
  37421. /**
  37422. * Gets or sets the maximum yaw angle that the bone can look to
  37423. */
  37424. maxYaw: number;
  37425. /**
  37426. * Gets or sets the minimum pitch angle that the bone can look to
  37427. */
  37428. minPitch: number;
  37429. /**
  37430. * Gets or sets the maximum pitch angle that the bone can look to
  37431. */
  37432. maxPitch: number;
  37433. /**
  37434. * Create a BoneLookController
  37435. * @param mesh the mesh that the bone belongs to
  37436. * @param bone the bone that will be looking to the target
  37437. * @param target the target Vector3 to look at
  37438. * @param options optional settings:
  37439. * * maxYaw: the maximum angle the bone will yaw to
  37440. * * minYaw: the minimum angle the bone will yaw to
  37441. * * maxPitch: the maximum angle the bone will pitch to
  37442. * * minPitch: the minimum angle the bone will yaw to
  37443. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37444. * * upAxis: the up axis of the coordinate system
  37445. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37446. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37447. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37448. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37449. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37450. * * adjustRoll: used to make an adjustment to the roll of the bone
  37451. **/
  37452. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37453. maxYaw?: number;
  37454. minYaw?: number;
  37455. maxPitch?: number;
  37456. minPitch?: number;
  37457. slerpAmount?: number;
  37458. upAxis?: Vector3;
  37459. upAxisSpace?: Space;
  37460. yawAxis?: Vector3;
  37461. pitchAxis?: Vector3;
  37462. adjustYaw?: number;
  37463. adjustPitch?: number;
  37464. adjustRoll?: number;
  37465. });
  37466. /**
  37467. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37468. */
  37469. update(): void;
  37470. private _getAngleDiff;
  37471. private _getAngleBetween;
  37472. private _isAngleBetween;
  37473. }
  37474. }
  37475. declare module "babylonjs/Bones/index" {
  37476. export * from "babylonjs/Bones/bone";
  37477. export * from "babylonjs/Bones/boneIKController";
  37478. export * from "babylonjs/Bones/boneLookController";
  37479. export * from "babylonjs/Bones/skeleton";
  37480. }
  37481. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37482. import { Nullable } from "babylonjs/types";
  37483. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37484. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37485. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37486. /**
  37487. * Manage the gamepad inputs to control an arc rotate camera.
  37488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37489. */
  37490. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37491. /**
  37492. * Defines the camera the input is attached to.
  37493. */
  37494. camera: ArcRotateCamera;
  37495. /**
  37496. * Defines the gamepad the input is gathering event from.
  37497. */
  37498. gamepad: Nullable<Gamepad>;
  37499. /**
  37500. * Defines the gamepad rotation sensiblity.
  37501. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37502. */
  37503. gamepadRotationSensibility: number;
  37504. /**
  37505. * Defines the gamepad move sensiblity.
  37506. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37507. */
  37508. gamepadMoveSensibility: number;
  37509. private _onGamepadConnectedObserver;
  37510. private _onGamepadDisconnectedObserver;
  37511. /**
  37512. * Attach the input controls to a specific dom element to get the input from.
  37513. * @param element Defines the element the controls should be listened from
  37514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37515. */
  37516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37517. /**
  37518. * Detach the current controls from the specified dom element.
  37519. * @param element Defines the element to stop listening the inputs from
  37520. */
  37521. detachControl(element: Nullable<HTMLElement>): void;
  37522. /**
  37523. * Update the current camera state depending on the inputs that have been used this frame.
  37524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37525. */
  37526. checkInputs(): void;
  37527. /**
  37528. * Gets the class name of the current intput.
  37529. * @returns the class name
  37530. */
  37531. getClassName(): string;
  37532. /**
  37533. * Get the friendly name associated with the input class.
  37534. * @returns the input friendly name
  37535. */
  37536. getSimpleName(): string;
  37537. }
  37538. }
  37539. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37540. import { Nullable } from "babylonjs/types";
  37541. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37542. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37543. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37544. interface ArcRotateCameraInputsManager {
  37545. /**
  37546. * Add orientation input support to the input manager.
  37547. * @returns the current input manager
  37548. */
  37549. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37550. }
  37551. }
  37552. /**
  37553. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37555. */
  37556. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37557. /**
  37558. * Defines the camera the input is attached to.
  37559. */
  37560. camera: ArcRotateCamera;
  37561. /**
  37562. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37563. */
  37564. alphaCorrection: number;
  37565. /**
  37566. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37567. */
  37568. gammaCorrection: number;
  37569. private _alpha;
  37570. private _gamma;
  37571. private _dirty;
  37572. private _deviceOrientationHandler;
  37573. /**
  37574. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37575. */
  37576. constructor();
  37577. /**
  37578. * Attach the input controls to a specific dom element to get the input from.
  37579. * @param element Defines the element the controls should be listened from
  37580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37581. */
  37582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37583. /** @hidden */
  37584. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37585. /**
  37586. * Update the current camera state depending on the inputs that have been used this frame.
  37587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37588. */
  37589. checkInputs(): void;
  37590. /**
  37591. * Detach the current controls from the specified dom element.
  37592. * @param element Defines the element to stop listening the inputs from
  37593. */
  37594. detachControl(element: Nullable<HTMLElement>): void;
  37595. /**
  37596. * Gets the class name of the current intput.
  37597. * @returns the class name
  37598. */
  37599. getClassName(): string;
  37600. /**
  37601. * Get the friendly name associated with the input class.
  37602. * @returns the input friendly name
  37603. */
  37604. getSimpleName(): string;
  37605. }
  37606. }
  37607. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37608. import { Nullable } from "babylonjs/types";
  37609. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37610. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37611. /**
  37612. * Listen to mouse events to control the camera.
  37613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37614. */
  37615. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37616. /**
  37617. * Defines the camera the input is attached to.
  37618. */
  37619. camera: FlyCamera;
  37620. /**
  37621. * Defines if touch is enabled. (Default is true.)
  37622. */
  37623. touchEnabled: boolean;
  37624. /**
  37625. * Defines the buttons associated with the input to handle camera rotation.
  37626. */
  37627. buttons: number[];
  37628. /**
  37629. * Assign buttons for Yaw control.
  37630. */
  37631. buttonsYaw: number[];
  37632. /**
  37633. * Assign buttons for Pitch control.
  37634. */
  37635. buttonsPitch: number[];
  37636. /**
  37637. * Assign buttons for Roll control.
  37638. */
  37639. buttonsRoll: number[];
  37640. /**
  37641. * Detect if any button is being pressed while mouse is moved.
  37642. * -1 = Mouse locked.
  37643. * 0 = Left button.
  37644. * 1 = Middle Button.
  37645. * 2 = Right Button.
  37646. */
  37647. activeButton: number;
  37648. /**
  37649. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37650. * Higher values reduce its sensitivity.
  37651. */
  37652. angularSensibility: number;
  37653. private _mousemoveCallback;
  37654. private _observer;
  37655. private _rollObserver;
  37656. private previousPosition;
  37657. private noPreventDefault;
  37658. private element;
  37659. /**
  37660. * Listen to mouse events to control the camera.
  37661. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37663. */
  37664. constructor(touchEnabled?: boolean);
  37665. /**
  37666. * Attach the mouse control to the HTML DOM element.
  37667. * @param element Defines the element that listens to the input events.
  37668. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37669. */
  37670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37671. /**
  37672. * Detach the current controls from the specified dom element.
  37673. * @param element Defines the element to stop listening the inputs from
  37674. */
  37675. detachControl(element: Nullable<HTMLElement>): void;
  37676. /**
  37677. * Gets the class name of the current input.
  37678. * @returns the class name.
  37679. */
  37680. getClassName(): string;
  37681. /**
  37682. * Get the friendly name associated with the input class.
  37683. * @returns the input's friendly name.
  37684. */
  37685. getSimpleName(): string;
  37686. private _pointerInput;
  37687. private _onMouseMove;
  37688. /**
  37689. * Rotate camera by mouse offset.
  37690. */
  37691. private rotateCamera;
  37692. }
  37693. }
  37694. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37695. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37696. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37697. /**
  37698. * Default Inputs manager for the FlyCamera.
  37699. * It groups all the default supported inputs for ease of use.
  37700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37701. */
  37702. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37703. /**
  37704. * Instantiates a new FlyCameraInputsManager.
  37705. * @param camera Defines the camera the inputs belong to.
  37706. */
  37707. constructor(camera: FlyCamera);
  37708. /**
  37709. * Add keyboard input support to the input manager.
  37710. * @returns the new FlyCameraKeyboardMoveInput().
  37711. */
  37712. addKeyboard(): FlyCameraInputsManager;
  37713. /**
  37714. * Add mouse input support to the input manager.
  37715. * @param touchEnabled Enable touch screen support.
  37716. * @returns the new FlyCameraMouseInput().
  37717. */
  37718. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37719. }
  37720. }
  37721. declare module "babylonjs/Cameras/flyCamera" {
  37722. import { Scene } from "babylonjs/scene";
  37723. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37725. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37726. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37727. /**
  37728. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37729. * such as in a 3D Space Shooter or a Flight Simulator.
  37730. */
  37731. export class FlyCamera extends TargetCamera {
  37732. /**
  37733. * Define the collision ellipsoid of the camera.
  37734. * This is helpful for simulating a camera body, like a player's body.
  37735. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37736. */
  37737. ellipsoid: Vector3;
  37738. /**
  37739. * Define an offset for the position of the ellipsoid around the camera.
  37740. * This can be helpful if the camera is attached away from the player's body center,
  37741. * such as at its head.
  37742. */
  37743. ellipsoidOffset: Vector3;
  37744. /**
  37745. * Enable or disable collisions of the camera with the rest of the scene objects.
  37746. */
  37747. checkCollisions: boolean;
  37748. /**
  37749. * Enable or disable gravity on the camera.
  37750. */
  37751. applyGravity: boolean;
  37752. /**
  37753. * Define the current direction the camera is moving to.
  37754. */
  37755. cameraDirection: Vector3;
  37756. /**
  37757. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37758. * This overrides and empties cameraRotation.
  37759. */
  37760. rotationQuaternion: Quaternion;
  37761. /**
  37762. * Track Roll to maintain the wanted Rolling when looking around.
  37763. */
  37764. _trackRoll: number;
  37765. /**
  37766. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37767. */
  37768. rollCorrect: number;
  37769. /**
  37770. * Mimic a banked turn, Rolling the camera when Yawing.
  37771. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37772. */
  37773. bankedTurn: boolean;
  37774. /**
  37775. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37776. */
  37777. bankedTurnLimit: number;
  37778. /**
  37779. * Value of 0 disables the banked Roll.
  37780. * Value of 1 is equal to the Yaw angle in radians.
  37781. */
  37782. bankedTurnMultiplier: number;
  37783. /**
  37784. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37785. */
  37786. inputs: FlyCameraInputsManager;
  37787. /**
  37788. * Gets the input sensibility for mouse input.
  37789. * Higher values reduce sensitivity.
  37790. */
  37791. /**
  37792. * Sets the input sensibility for a mouse input.
  37793. * Higher values reduce sensitivity.
  37794. */
  37795. angularSensibility: number;
  37796. /**
  37797. * Get the keys for camera movement forward.
  37798. */
  37799. /**
  37800. * Set the keys for camera movement forward.
  37801. */
  37802. keysForward: number[];
  37803. /**
  37804. * Get the keys for camera movement backward.
  37805. */
  37806. keysBackward: number[];
  37807. /**
  37808. * Get the keys for camera movement up.
  37809. */
  37810. /**
  37811. * Set the keys for camera movement up.
  37812. */
  37813. keysUp: number[];
  37814. /**
  37815. * Get the keys for camera movement down.
  37816. */
  37817. /**
  37818. * Set the keys for camera movement down.
  37819. */
  37820. keysDown: number[];
  37821. /**
  37822. * Get the keys for camera movement left.
  37823. */
  37824. /**
  37825. * Set the keys for camera movement left.
  37826. */
  37827. keysLeft: number[];
  37828. /**
  37829. * Set the keys for camera movement right.
  37830. */
  37831. /**
  37832. * Set the keys for camera movement right.
  37833. */
  37834. keysRight: number[];
  37835. /**
  37836. * Event raised when the camera collides with a mesh in the scene.
  37837. */
  37838. onCollide: (collidedMesh: AbstractMesh) => void;
  37839. private _collider;
  37840. private _needMoveForGravity;
  37841. private _oldPosition;
  37842. private _diffPosition;
  37843. private _newPosition;
  37844. /** @hidden */
  37845. _localDirection: Vector3;
  37846. /** @hidden */
  37847. _transformedDirection: Vector3;
  37848. /**
  37849. * Instantiates a FlyCamera.
  37850. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37851. * such as in a 3D Space Shooter or a Flight Simulator.
  37852. * @param name Define the name of the camera in the scene.
  37853. * @param position Define the starting position of the camera in the scene.
  37854. * @param scene Define the scene the camera belongs to.
  37855. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37856. */
  37857. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37858. /**
  37859. * Attach a control to the HTML DOM element.
  37860. * @param element Defines the element that listens to the input events.
  37861. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37862. */
  37863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37864. /**
  37865. * Detach a control from the HTML DOM element.
  37866. * The camera will stop reacting to that input.
  37867. * @param element Defines the element that listens to the input events.
  37868. */
  37869. detachControl(element: HTMLElement): void;
  37870. private _collisionMask;
  37871. /**
  37872. * Get the mask that the camera ignores in collision events.
  37873. */
  37874. /**
  37875. * Set the mask that the camera ignores in collision events.
  37876. */
  37877. collisionMask: number;
  37878. /** @hidden */
  37879. _collideWithWorld(displacement: Vector3): void;
  37880. /** @hidden */
  37881. private _onCollisionPositionChange;
  37882. /** @hidden */
  37883. _checkInputs(): void;
  37884. /** @hidden */
  37885. _decideIfNeedsToMove(): boolean;
  37886. /** @hidden */
  37887. _updatePosition(): void;
  37888. /**
  37889. * Restore the Roll to its target value at the rate specified.
  37890. * @param rate - Higher means slower restoring.
  37891. * @hidden
  37892. */
  37893. restoreRoll(rate: number): void;
  37894. /**
  37895. * Destroy the camera and release the current resources held by it.
  37896. */
  37897. dispose(): void;
  37898. /**
  37899. * Get the current object class name.
  37900. * @returns the class name.
  37901. */
  37902. getClassName(): string;
  37903. }
  37904. }
  37905. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37906. import { Nullable } from "babylonjs/types";
  37907. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37908. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37909. /**
  37910. * Listen to keyboard events to control the camera.
  37911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37912. */
  37913. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37914. /**
  37915. * Defines the camera the input is attached to.
  37916. */
  37917. camera: FlyCamera;
  37918. /**
  37919. * The list of keyboard keys used to control the forward move of the camera.
  37920. */
  37921. keysForward: number[];
  37922. /**
  37923. * The list of keyboard keys used to control the backward move of the camera.
  37924. */
  37925. keysBackward: number[];
  37926. /**
  37927. * The list of keyboard keys used to control the forward move of the camera.
  37928. */
  37929. keysUp: number[];
  37930. /**
  37931. * The list of keyboard keys used to control the backward move of the camera.
  37932. */
  37933. keysDown: number[];
  37934. /**
  37935. * The list of keyboard keys used to control the right strafe move of the camera.
  37936. */
  37937. keysRight: number[];
  37938. /**
  37939. * The list of keyboard keys used to control the left strafe move of the camera.
  37940. */
  37941. keysLeft: number[];
  37942. private _keys;
  37943. private _onCanvasBlurObserver;
  37944. private _onKeyboardObserver;
  37945. private _engine;
  37946. private _scene;
  37947. /**
  37948. * Attach the input controls to a specific dom element to get the input from.
  37949. * @param element Defines the element the controls should be listened from
  37950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37951. */
  37952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37953. /**
  37954. * Detach the current controls from the specified dom element.
  37955. * @param element Defines the element to stop listening the inputs from
  37956. */
  37957. detachControl(element: Nullable<HTMLElement>): void;
  37958. /**
  37959. * Gets the class name of the current intput.
  37960. * @returns the class name
  37961. */
  37962. getClassName(): string;
  37963. /** @hidden */
  37964. _onLostFocus(e: FocusEvent): void;
  37965. /**
  37966. * Get the friendly name associated with the input class.
  37967. * @returns the input friendly name
  37968. */
  37969. getSimpleName(): string;
  37970. /**
  37971. * Update the current camera state depending on the inputs that have been used this frame.
  37972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37973. */
  37974. checkInputs(): void;
  37975. }
  37976. }
  37977. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37978. import { Nullable } from "babylonjs/types";
  37979. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37980. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37981. /**
  37982. * Manage the mouse wheel inputs to control a follow camera.
  37983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37984. */
  37985. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37986. /**
  37987. * Defines the camera the input is attached to.
  37988. */
  37989. camera: FollowCamera;
  37990. /**
  37991. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37992. */
  37993. axisControlRadius: boolean;
  37994. /**
  37995. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37996. */
  37997. axisControlHeight: boolean;
  37998. /**
  37999. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38000. */
  38001. axisControlRotation: boolean;
  38002. /**
  38003. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38004. * relation to mouseWheel events.
  38005. */
  38006. wheelPrecision: number;
  38007. /**
  38008. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38009. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38010. */
  38011. wheelDeltaPercentage: number;
  38012. private _wheel;
  38013. private _observer;
  38014. /**
  38015. * Attach the input controls to a specific dom element to get the input from.
  38016. * @param element Defines the element the controls should be listened from
  38017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38018. */
  38019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38020. /**
  38021. * Detach the current controls from the specified dom element.
  38022. * @param element Defines the element to stop listening the inputs from
  38023. */
  38024. detachControl(element: Nullable<HTMLElement>): void;
  38025. /**
  38026. * Gets the class name of the current intput.
  38027. * @returns the class name
  38028. */
  38029. getClassName(): string;
  38030. /**
  38031. * Get the friendly name associated with the input class.
  38032. * @returns the input friendly name
  38033. */
  38034. getSimpleName(): string;
  38035. }
  38036. }
  38037. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38038. import { Nullable } from "babylonjs/types";
  38039. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38040. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38041. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38042. /**
  38043. * Manage the pointers inputs to control an follow camera.
  38044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38045. */
  38046. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38047. /**
  38048. * Defines the camera the input is attached to.
  38049. */
  38050. camera: FollowCamera;
  38051. /**
  38052. * Gets the class name of the current input.
  38053. * @returns the class name
  38054. */
  38055. getClassName(): string;
  38056. /**
  38057. * Defines the pointer angular sensibility along the X axis or how fast is
  38058. * the camera rotating.
  38059. * A negative number will reverse the axis direction.
  38060. */
  38061. angularSensibilityX: number;
  38062. /**
  38063. * Defines the pointer angular sensibility along the Y axis or how fast is
  38064. * the camera rotating.
  38065. * A negative number will reverse the axis direction.
  38066. */
  38067. angularSensibilityY: number;
  38068. /**
  38069. * Defines the pointer pinch precision or how fast is the camera zooming.
  38070. * A negative number will reverse the axis direction.
  38071. */
  38072. pinchPrecision: number;
  38073. /**
  38074. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38075. * from 0.
  38076. * It defines the percentage of current camera.radius to use as delta when
  38077. * pinch zoom is used.
  38078. */
  38079. pinchDeltaPercentage: number;
  38080. /**
  38081. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38082. */
  38083. axisXControlRadius: boolean;
  38084. /**
  38085. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38086. */
  38087. axisXControlHeight: boolean;
  38088. /**
  38089. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38090. */
  38091. axisXControlRotation: boolean;
  38092. /**
  38093. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38094. */
  38095. axisYControlRadius: boolean;
  38096. /**
  38097. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38098. */
  38099. axisYControlHeight: boolean;
  38100. /**
  38101. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38102. */
  38103. axisYControlRotation: boolean;
  38104. /**
  38105. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38106. */
  38107. axisPinchControlRadius: boolean;
  38108. /**
  38109. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38110. */
  38111. axisPinchControlHeight: boolean;
  38112. /**
  38113. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38114. */
  38115. axisPinchControlRotation: boolean;
  38116. /**
  38117. * Log error messages if basic misconfiguration has occurred.
  38118. */
  38119. warningEnable: boolean;
  38120. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38121. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38122. private _warningCounter;
  38123. private _warning;
  38124. }
  38125. }
  38126. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38127. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38128. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38129. /**
  38130. * Default Inputs manager for the FollowCamera.
  38131. * It groups all the default supported inputs for ease of use.
  38132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38133. */
  38134. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38135. /**
  38136. * Instantiates a new FollowCameraInputsManager.
  38137. * @param camera Defines the camera the inputs belong to
  38138. */
  38139. constructor(camera: FollowCamera);
  38140. /**
  38141. * Add keyboard input support to the input manager.
  38142. * @returns the current input manager
  38143. */
  38144. addKeyboard(): FollowCameraInputsManager;
  38145. /**
  38146. * Add mouse wheel input support to the input manager.
  38147. * @returns the current input manager
  38148. */
  38149. addMouseWheel(): FollowCameraInputsManager;
  38150. /**
  38151. * Add pointers input support to the input manager.
  38152. * @returns the current input manager
  38153. */
  38154. addPointers(): FollowCameraInputsManager;
  38155. /**
  38156. * Add orientation input support to the input manager.
  38157. * @returns the current input manager
  38158. */
  38159. addVRDeviceOrientation(): FollowCameraInputsManager;
  38160. }
  38161. }
  38162. declare module "babylonjs/Cameras/followCamera" {
  38163. import { Nullable } from "babylonjs/types";
  38164. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38165. import { Scene } from "babylonjs/scene";
  38166. import { Vector3 } from "babylonjs/Maths/math";
  38167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38168. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38169. /**
  38170. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38171. * an arc rotate version arcFollowCamera are available.
  38172. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38173. */
  38174. export class FollowCamera extends TargetCamera {
  38175. /**
  38176. * Distance the follow camera should follow an object at
  38177. */
  38178. radius: number;
  38179. /**
  38180. * Minimum allowed distance of the camera to the axis of rotation
  38181. * (The camera can not get closer).
  38182. * This can help limiting how the Camera is able to move in the scene.
  38183. */
  38184. lowerRadiusLimit: Nullable<number>;
  38185. /**
  38186. * Maximum allowed distance of the camera to the axis of rotation
  38187. * (The camera can not get further).
  38188. * This can help limiting how the Camera is able to move in the scene.
  38189. */
  38190. upperRadiusLimit: Nullable<number>;
  38191. /**
  38192. * Define a rotation offset between the camera and the object it follows
  38193. */
  38194. rotationOffset: number;
  38195. /**
  38196. * Minimum allowed angle to camera position relative to target object.
  38197. * This can help limiting how the Camera is able to move in the scene.
  38198. */
  38199. lowerRotationOffsetLimit: Nullable<number>;
  38200. /**
  38201. * Maximum allowed angle to camera position relative to target object.
  38202. * This can help limiting how the Camera is able to move in the scene.
  38203. */
  38204. upperRotationOffsetLimit: Nullable<number>;
  38205. /**
  38206. * Define a height offset between the camera and the object it follows.
  38207. * It can help following an object from the top (like a car chaing a plane)
  38208. */
  38209. heightOffset: number;
  38210. /**
  38211. * Minimum allowed height of camera position relative to target object.
  38212. * This can help limiting how the Camera is able to move in the scene.
  38213. */
  38214. lowerHeightOffsetLimit: Nullable<number>;
  38215. /**
  38216. * Maximum allowed height of camera position relative to target object.
  38217. * This can help limiting how the Camera is able to move in the scene.
  38218. */
  38219. upperHeightOffsetLimit: Nullable<number>;
  38220. /**
  38221. * Define how fast the camera can accelerate to follow it s target.
  38222. */
  38223. cameraAcceleration: number;
  38224. /**
  38225. * Define the speed limit of the camera following an object.
  38226. */
  38227. maxCameraSpeed: number;
  38228. /**
  38229. * Define the target of the camera.
  38230. */
  38231. lockedTarget: Nullable<AbstractMesh>;
  38232. /**
  38233. * Defines the input associated with the camera.
  38234. */
  38235. inputs: FollowCameraInputsManager;
  38236. /**
  38237. * Instantiates the follow camera.
  38238. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38239. * @param name Define the name of the camera in the scene
  38240. * @param position Define the position of the camera
  38241. * @param scene Define the scene the camera belong to
  38242. * @param lockedTarget Define the target of the camera
  38243. */
  38244. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38245. private _follow;
  38246. /**
  38247. * Attached controls to the current camera.
  38248. * @param element Defines the element the controls should be listened from
  38249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38250. */
  38251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38252. /**
  38253. * Detach the current controls from the camera.
  38254. * The camera will stop reacting to inputs.
  38255. * @param element Defines the element to stop listening the inputs from
  38256. */
  38257. detachControl(element: HTMLElement): void;
  38258. /** @hidden */
  38259. _checkInputs(): void;
  38260. private _checkLimits;
  38261. /**
  38262. * Gets the camera class name.
  38263. * @returns the class name
  38264. */
  38265. getClassName(): string;
  38266. }
  38267. /**
  38268. * Arc Rotate version of the follow camera.
  38269. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38270. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38271. */
  38272. export class ArcFollowCamera extends TargetCamera {
  38273. /** The longitudinal angle of the camera */
  38274. alpha: number;
  38275. /** The latitudinal angle of the camera */
  38276. beta: number;
  38277. /** The radius of the camera from its target */
  38278. radius: number;
  38279. /** Define the camera target (the messh it should follow) */
  38280. target: Nullable<AbstractMesh>;
  38281. private _cartesianCoordinates;
  38282. /**
  38283. * Instantiates a new ArcFollowCamera
  38284. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38285. * @param name Define the name of the camera
  38286. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38287. * @param beta Define the rotation angle of the camera around the elevation axis
  38288. * @param radius Define the radius of the camera from its target point
  38289. * @param target Define the target of the camera
  38290. * @param scene Define the scene the camera belongs to
  38291. */
  38292. constructor(name: string,
  38293. /** The longitudinal angle of the camera */
  38294. alpha: number,
  38295. /** The latitudinal angle of the camera */
  38296. beta: number,
  38297. /** The radius of the camera from its target */
  38298. radius: number,
  38299. /** Define the camera target (the messh it should follow) */
  38300. target: Nullable<AbstractMesh>, scene: Scene);
  38301. private _follow;
  38302. /** @hidden */
  38303. _checkInputs(): void;
  38304. /**
  38305. * Returns the class name of the object.
  38306. * It is mostly used internally for serialization purposes.
  38307. */
  38308. getClassName(): string;
  38309. }
  38310. }
  38311. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38312. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38313. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38314. import { Nullable } from "babylonjs/types";
  38315. /**
  38316. * Manage the keyboard inputs to control the movement of a follow camera.
  38317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38318. */
  38319. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38320. /**
  38321. * Defines the camera the input is attached to.
  38322. */
  38323. camera: FollowCamera;
  38324. /**
  38325. * Defines the list of key codes associated with the up action (increase heightOffset)
  38326. */
  38327. keysHeightOffsetIncr: number[];
  38328. /**
  38329. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38330. */
  38331. keysHeightOffsetDecr: number[];
  38332. /**
  38333. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38334. */
  38335. keysHeightOffsetModifierAlt: boolean;
  38336. /**
  38337. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38338. */
  38339. keysHeightOffsetModifierCtrl: boolean;
  38340. /**
  38341. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38342. */
  38343. keysHeightOffsetModifierShift: boolean;
  38344. /**
  38345. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38346. */
  38347. keysRotationOffsetIncr: number[];
  38348. /**
  38349. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38350. */
  38351. keysRotationOffsetDecr: number[];
  38352. /**
  38353. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38354. */
  38355. keysRotationOffsetModifierAlt: boolean;
  38356. /**
  38357. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38358. */
  38359. keysRotationOffsetModifierCtrl: boolean;
  38360. /**
  38361. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38362. */
  38363. keysRotationOffsetModifierShift: boolean;
  38364. /**
  38365. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38366. */
  38367. keysRadiusIncr: number[];
  38368. /**
  38369. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38370. */
  38371. keysRadiusDecr: number[];
  38372. /**
  38373. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38374. */
  38375. keysRadiusModifierAlt: boolean;
  38376. /**
  38377. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38378. */
  38379. keysRadiusModifierCtrl: boolean;
  38380. /**
  38381. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38382. */
  38383. keysRadiusModifierShift: boolean;
  38384. /**
  38385. * Defines the rate of change of heightOffset.
  38386. */
  38387. heightSensibility: number;
  38388. /**
  38389. * Defines the rate of change of rotationOffset.
  38390. */
  38391. rotationSensibility: number;
  38392. /**
  38393. * Defines the rate of change of radius.
  38394. */
  38395. radiusSensibility: number;
  38396. private _keys;
  38397. private _ctrlPressed;
  38398. private _altPressed;
  38399. private _shiftPressed;
  38400. private _onCanvasBlurObserver;
  38401. private _onKeyboardObserver;
  38402. private _engine;
  38403. private _scene;
  38404. /**
  38405. * Attach the input controls to a specific dom element to get the input from.
  38406. * @param element Defines the element the controls should be listened from
  38407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38408. */
  38409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38410. /**
  38411. * Detach the current controls from the specified dom element.
  38412. * @param element Defines the element to stop listening the inputs from
  38413. */
  38414. detachControl(element: Nullable<HTMLElement>): void;
  38415. /**
  38416. * Update the current camera state depending on the inputs that have been used this frame.
  38417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38418. */
  38419. checkInputs(): void;
  38420. /**
  38421. * Gets the class name of the current input.
  38422. * @returns the class name
  38423. */
  38424. getClassName(): string;
  38425. /**
  38426. * Get the friendly name associated with the input class.
  38427. * @returns the input friendly name
  38428. */
  38429. getSimpleName(): string;
  38430. /**
  38431. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38432. * allow modification of the heightOffset value.
  38433. */
  38434. private _modifierHeightOffset;
  38435. /**
  38436. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38437. * allow modification of the rotationOffset value.
  38438. */
  38439. private _modifierRotationOffset;
  38440. /**
  38441. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38442. * allow modification of the radius value.
  38443. */
  38444. private _modifierRadius;
  38445. }
  38446. }
  38447. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38448. import { Nullable } from "babylonjs/types";
  38449. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38450. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38451. import { Observable } from "babylonjs/Misc/observable";
  38452. module "babylonjs/Cameras/freeCameraInputsManager" {
  38453. interface FreeCameraInputsManager {
  38454. /**
  38455. * @hidden
  38456. */
  38457. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38458. /**
  38459. * Add orientation input support to the input manager.
  38460. * @returns the current input manager
  38461. */
  38462. addDeviceOrientation(): FreeCameraInputsManager;
  38463. }
  38464. }
  38465. /**
  38466. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38467. * Screen rotation is taken into account.
  38468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38469. */
  38470. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38471. private _camera;
  38472. private _screenOrientationAngle;
  38473. private _constantTranform;
  38474. private _screenQuaternion;
  38475. private _alpha;
  38476. private _beta;
  38477. private _gamma;
  38478. /**
  38479. * @hidden
  38480. */
  38481. _onDeviceOrientationChangedObservable: Observable<void>;
  38482. /**
  38483. * Instantiates a new input
  38484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38485. */
  38486. constructor();
  38487. /**
  38488. * Define the camera controlled by the input.
  38489. */
  38490. camera: FreeCamera;
  38491. /**
  38492. * Attach the input controls to a specific dom element to get the input from.
  38493. * @param element Defines the element the controls should be listened from
  38494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38495. */
  38496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38497. private _orientationChanged;
  38498. private _deviceOrientation;
  38499. /**
  38500. * Detach the current controls from the specified dom element.
  38501. * @param element Defines the element to stop listening the inputs from
  38502. */
  38503. detachControl(element: Nullable<HTMLElement>): void;
  38504. /**
  38505. * Update the current camera state depending on the inputs that have been used this frame.
  38506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38507. */
  38508. checkInputs(): void;
  38509. /**
  38510. * Gets the class name of the current intput.
  38511. * @returns the class name
  38512. */
  38513. getClassName(): string;
  38514. /**
  38515. * Get the friendly name associated with the input class.
  38516. * @returns the input friendly name
  38517. */
  38518. getSimpleName(): string;
  38519. }
  38520. }
  38521. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38522. import { Nullable } from "babylonjs/types";
  38523. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38524. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38525. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38526. /**
  38527. * Manage the gamepad inputs to control a free camera.
  38528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38529. */
  38530. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38531. /**
  38532. * Define the camera the input is attached to.
  38533. */
  38534. camera: FreeCamera;
  38535. /**
  38536. * Define the Gamepad controlling the input
  38537. */
  38538. gamepad: Nullable<Gamepad>;
  38539. /**
  38540. * Defines the gamepad rotation sensiblity.
  38541. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38542. */
  38543. gamepadAngularSensibility: number;
  38544. /**
  38545. * Defines the gamepad move sensiblity.
  38546. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38547. */
  38548. gamepadMoveSensibility: number;
  38549. private _onGamepadConnectedObserver;
  38550. private _onGamepadDisconnectedObserver;
  38551. private _cameraTransform;
  38552. private _deltaTransform;
  38553. private _vector3;
  38554. private _vector2;
  38555. /**
  38556. * Attach the input controls to a specific dom element to get the input from.
  38557. * @param element Defines the element the controls should be listened from
  38558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38559. */
  38560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38561. /**
  38562. * Detach the current controls from the specified dom element.
  38563. * @param element Defines the element to stop listening the inputs from
  38564. */
  38565. detachControl(element: Nullable<HTMLElement>): void;
  38566. /**
  38567. * Update the current camera state depending on the inputs that have been used this frame.
  38568. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38569. */
  38570. checkInputs(): void;
  38571. /**
  38572. * Gets the class name of the current intput.
  38573. * @returns the class name
  38574. */
  38575. getClassName(): string;
  38576. /**
  38577. * Get the friendly name associated with the input class.
  38578. * @returns the input friendly name
  38579. */
  38580. getSimpleName(): string;
  38581. }
  38582. }
  38583. declare module "babylonjs/Misc/virtualJoystick" {
  38584. import { Nullable } from "babylonjs/types";
  38585. import { Vector3 } from "babylonjs/Maths/math";
  38586. /**
  38587. * Defines the potential axis of a Joystick
  38588. */
  38589. export enum JoystickAxis {
  38590. /** X axis */
  38591. X = 0,
  38592. /** Y axis */
  38593. Y = 1,
  38594. /** Z axis */
  38595. Z = 2
  38596. }
  38597. /**
  38598. * Class used to define virtual joystick (used in touch mode)
  38599. */
  38600. export class VirtualJoystick {
  38601. /**
  38602. * Gets or sets a boolean indicating that left and right values must be inverted
  38603. */
  38604. reverseLeftRight: boolean;
  38605. /**
  38606. * Gets or sets a boolean indicating that up and down values must be inverted
  38607. */
  38608. reverseUpDown: boolean;
  38609. /**
  38610. * Gets the offset value for the position (ie. the change of the position value)
  38611. */
  38612. deltaPosition: Vector3;
  38613. /**
  38614. * Gets a boolean indicating if the virtual joystick was pressed
  38615. */
  38616. pressed: boolean;
  38617. /**
  38618. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38619. */
  38620. static Canvas: Nullable<HTMLCanvasElement>;
  38621. private static _globalJoystickIndex;
  38622. private static vjCanvasContext;
  38623. private static vjCanvasWidth;
  38624. private static vjCanvasHeight;
  38625. private static halfWidth;
  38626. private _action;
  38627. private _axisTargetedByLeftAndRight;
  38628. private _axisTargetedByUpAndDown;
  38629. private _joystickSensibility;
  38630. private _inversedSensibility;
  38631. private _joystickPointerID;
  38632. private _joystickColor;
  38633. private _joystickPointerPos;
  38634. private _joystickPreviousPointerPos;
  38635. private _joystickPointerStartPos;
  38636. private _deltaJoystickVector;
  38637. private _leftJoystick;
  38638. private _touches;
  38639. private _onPointerDownHandlerRef;
  38640. private _onPointerMoveHandlerRef;
  38641. private _onPointerUpHandlerRef;
  38642. private _onResize;
  38643. /**
  38644. * Creates a new virtual joystick
  38645. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38646. */
  38647. constructor(leftJoystick?: boolean);
  38648. /**
  38649. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38650. * @param newJoystickSensibility defines the new sensibility
  38651. */
  38652. setJoystickSensibility(newJoystickSensibility: number): void;
  38653. private _onPointerDown;
  38654. private _onPointerMove;
  38655. private _onPointerUp;
  38656. /**
  38657. * Change the color of the virtual joystick
  38658. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38659. */
  38660. setJoystickColor(newColor: string): void;
  38661. /**
  38662. * Defines a callback to call when the joystick is touched
  38663. * @param action defines the callback
  38664. */
  38665. setActionOnTouch(action: () => any): void;
  38666. /**
  38667. * Defines which axis you'd like to control for left & right
  38668. * @param axis defines the axis to use
  38669. */
  38670. setAxisForLeftRight(axis: JoystickAxis): void;
  38671. /**
  38672. * Defines which axis you'd like to control for up & down
  38673. * @param axis defines the axis to use
  38674. */
  38675. setAxisForUpDown(axis: JoystickAxis): void;
  38676. private _drawVirtualJoystick;
  38677. /**
  38678. * Release internal HTML canvas
  38679. */
  38680. releaseCanvas(): void;
  38681. }
  38682. }
  38683. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38684. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38685. import { Nullable } from "babylonjs/types";
  38686. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38687. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38688. module "babylonjs/Cameras/freeCameraInputsManager" {
  38689. interface FreeCameraInputsManager {
  38690. /**
  38691. * Add virtual joystick input support to the input manager.
  38692. * @returns the current input manager
  38693. */
  38694. addVirtualJoystick(): FreeCameraInputsManager;
  38695. }
  38696. }
  38697. /**
  38698. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38700. */
  38701. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38702. /**
  38703. * Defines the camera the input is attached to.
  38704. */
  38705. camera: FreeCamera;
  38706. private _leftjoystick;
  38707. private _rightjoystick;
  38708. /**
  38709. * Gets the left stick of the virtual joystick.
  38710. * @returns The virtual Joystick
  38711. */
  38712. getLeftJoystick(): VirtualJoystick;
  38713. /**
  38714. * Gets the right stick of the virtual joystick.
  38715. * @returns The virtual Joystick
  38716. */
  38717. getRightJoystick(): VirtualJoystick;
  38718. /**
  38719. * Update the current camera state depending on the inputs that have been used this frame.
  38720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38721. */
  38722. checkInputs(): void;
  38723. /**
  38724. * Attach the input controls to a specific dom element to get the input from.
  38725. * @param element Defines the element the controls should be listened from
  38726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38727. */
  38728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38729. /**
  38730. * Detach the current controls from the specified dom element.
  38731. * @param element Defines the element to stop listening the inputs from
  38732. */
  38733. detachControl(element: Nullable<HTMLElement>): void;
  38734. /**
  38735. * Gets the class name of the current intput.
  38736. * @returns the class name
  38737. */
  38738. getClassName(): string;
  38739. /**
  38740. * Get the friendly name associated with the input class.
  38741. * @returns the input friendly name
  38742. */
  38743. getSimpleName(): string;
  38744. }
  38745. }
  38746. declare module "babylonjs/Cameras/Inputs/index" {
  38747. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38748. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38749. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38750. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38751. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38752. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38753. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38754. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38755. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38756. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38757. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38758. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38759. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38760. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38761. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38762. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38763. }
  38764. declare module "babylonjs/Cameras/touchCamera" {
  38765. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38766. import { Scene } from "babylonjs/scene";
  38767. import { Vector3 } from "babylonjs/Maths/math";
  38768. /**
  38769. * This represents a FPS type of camera controlled by touch.
  38770. * This is like a universal camera minus the Gamepad controls.
  38771. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38772. */
  38773. export class TouchCamera extends FreeCamera {
  38774. /**
  38775. * Defines the touch sensibility for rotation.
  38776. * The higher the faster.
  38777. */
  38778. touchAngularSensibility: number;
  38779. /**
  38780. * Defines the touch sensibility for move.
  38781. * The higher the faster.
  38782. */
  38783. touchMoveSensibility: number;
  38784. /**
  38785. * Instantiates a new touch camera.
  38786. * This represents a FPS type of camera controlled by touch.
  38787. * This is like a universal camera minus the Gamepad controls.
  38788. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38789. * @param name Define the name of the camera in the scene
  38790. * @param position Define the start position of the camera in the scene
  38791. * @param scene Define the scene the camera belongs to
  38792. */
  38793. constructor(name: string, position: Vector3, scene: Scene);
  38794. /**
  38795. * Gets the current object class name.
  38796. * @return the class name
  38797. */
  38798. getClassName(): string;
  38799. /** @hidden */
  38800. _setupInputs(): void;
  38801. }
  38802. }
  38803. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38804. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38805. import { Scene } from "babylonjs/scene";
  38806. import { Vector3, Axis } from "babylonjs/Maths/math";
  38807. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38808. /**
  38809. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38810. * being tilted forward or back and left or right.
  38811. */
  38812. export class DeviceOrientationCamera extends FreeCamera {
  38813. private _initialQuaternion;
  38814. private _quaternionCache;
  38815. private _tmpDragQuaternion;
  38816. /**
  38817. * Creates a new device orientation camera
  38818. * @param name The name of the camera
  38819. * @param position The start position camera
  38820. * @param scene The scene the camera belongs to
  38821. */
  38822. constructor(name: string, position: Vector3, scene: Scene);
  38823. /**
  38824. * @hidden
  38825. * Disabled pointer input on first orientation sensor update (Default: true)
  38826. */
  38827. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38828. private _dragFactor;
  38829. /**
  38830. * Enabled turning on the y axis when the orientation sensor is active
  38831. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38832. */
  38833. enableHorizontalDragging(dragFactor?: number): void;
  38834. /**
  38835. * Gets the current instance class name ("DeviceOrientationCamera").
  38836. * This helps avoiding instanceof at run time.
  38837. * @returns the class name
  38838. */
  38839. getClassName(): string;
  38840. /**
  38841. * @hidden
  38842. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38843. */
  38844. _checkInputs(): void;
  38845. /**
  38846. * Reset the camera to its default orientation on the specified axis only.
  38847. * @param axis The axis to reset
  38848. */
  38849. resetToCurrentRotation(axis?: Axis): void;
  38850. }
  38851. }
  38852. declare module "babylonjs/Gamepads/xboxGamepad" {
  38853. import { Observable } from "babylonjs/Misc/observable";
  38854. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38855. /**
  38856. * Defines supported buttons for XBox360 compatible gamepads
  38857. */
  38858. export enum Xbox360Button {
  38859. /** A */
  38860. A = 0,
  38861. /** B */
  38862. B = 1,
  38863. /** X */
  38864. X = 2,
  38865. /** Y */
  38866. Y = 3,
  38867. /** Start */
  38868. Start = 4,
  38869. /** Back */
  38870. Back = 5,
  38871. /** Left button */
  38872. LB = 6,
  38873. /** Right button */
  38874. RB = 7,
  38875. /** Left stick */
  38876. LeftStick = 8,
  38877. /** Right stick */
  38878. RightStick = 9
  38879. }
  38880. /** Defines values for XBox360 DPad */
  38881. export enum Xbox360Dpad {
  38882. /** Up */
  38883. Up = 0,
  38884. /** Down */
  38885. Down = 1,
  38886. /** Left */
  38887. Left = 2,
  38888. /** Right */
  38889. Right = 3
  38890. }
  38891. /**
  38892. * Defines a XBox360 gamepad
  38893. */
  38894. export class Xbox360Pad extends Gamepad {
  38895. private _leftTrigger;
  38896. private _rightTrigger;
  38897. private _onlefttriggerchanged;
  38898. private _onrighttriggerchanged;
  38899. private _onbuttondown;
  38900. private _onbuttonup;
  38901. private _ondpaddown;
  38902. private _ondpadup;
  38903. /** Observable raised when a button is pressed */
  38904. onButtonDownObservable: Observable<Xbox360Button>;
  38905. /** Observable raised when a button is released */
  38906. onButtonUpObservable: Observable<Xbox360Button>;
  38907. /** Observable raised when a pad is pressed */
  38908. onPadDownObservable: Observable<Xbox360Dpad>;
  38909. /** Observable raised when a pad is released */
  38910. onPadUpObservable: Observable<Xbox360Dpad>;
  38911. private _buttonA;
  38912. private _buttonB;
  38913. private _buttonX;
  38914. private _buttonY;
  38915. private _buttonBack;
  38916. private _buttonStart;
  38917. private _buttonLB;
  38918. private _buttonRB;
  38919. private _buttonLeftStick;
  38920. private _buttonRightStick;
  38921. private _dPadUp;
  38922. private _dPadDown;
  38923. private _dPadLeft;
  38924. private _dPadRight;
  38925. private _isXboxOnePad;
  38926. /**
  38927. * Creates a new XBox360 gamepad object
  38928. * @param id defines the id of this gamepad
  38929. * @param index defines its index
  38930. * @param gamepad defines the internal HTML gamepad object
  38931. * @param xboxOne defines if it is a XBox One gamepad
  38932. */
  38933. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38934. /**
  38935. * Defines the callback to call when left trigger is pressed
  38936. * @param callback defines the callback to use
  38937. */
  38938. onlefttriggerchanged(callback: (value: number) => void): void;
  38939. /**
  38940. * Defines the callback to call when right trigger is pressed
  38941. * @param callback defines the callback to use
  38942. */
  38943. onrighttriggerchanged(callback: (value: number) => void): void;
  38944. /**
  38945. * Gets the left trigger value
  38946. */
  38947. /**
  38948. * Sets the left trigger value
  38949. */
  38950. leftTrigger: number;
  38951. /**
  38952. * Gets the right trigger value
  38953. */
  38954. /**
  38955. * Sets the right trigger value
  38956. */
  38957. rightTrigger: number;
  38958. /**
  38959. * Defines the callback to call when a button is pressed
  38960. * @param callback defines the callback to use
  38961. */
  38962. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38963. /**
  38964. * Defines the callback to call when a button is released
  38965. * @param callback defines the callback to use
  38966. */
  38967. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38968. /**
  38969. * Defines the callback to call when a pad is pressed
  38970. * @param callback defines the callback to use
  38971. */
  38972. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38973. /**
  38974. * Defines the callback to call when a pad is released
  38975. * @param callback defines the callback to use
  38976. */
  38977. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38978. private _setButtonValue;
  38979. private _setDPadValue;
  38980. /**
  38981. * Gets the value of the `A` button
  38982. */
  38983. /**
  38984. * Sets the value of the `A` button
  38985. */
  38986. buttonA: number;
  38987. /**
  38988. * Gets the value of the `B` button
  38989. */
  38990. /**
  38991. * Sets the value of the `B` button
  38992. */
  38993. buttonB: number;
  38994. /**
  38995. * Gets the value of the `X` button
  38996. */
  38997. /**
  38998. * Sets the value of the `X` button
  38999. */
  39000. buttonX: number;
  39001. /**
  39002. * Gets the value of the `Y` button
  39003. */
  39004. /**
  39005. * Sets the value of the `Y` button
  39006. */
  39007. buttonY: number;
  39008. /**
  39009. * Gets the value of the `Start` button
  39010. */
  39011. /**
  39012. * Sets the value of the `Start` button
  39013. */
  39014. buttonStart: number;
  39015. /**
  39016. * Gets the value of the `Back` button
  39017. */
  39018. /**
  39019. * Sets the value of the `Back` button
  39020. */
  39021. buttonBack: number;
  39022. /**
  39023. * Gets the value of the `Left` button
  39024. */
  39025. /**
  39026. * Sets the value of the `Left` button
  39027. */
  39028. buttonLB: number;
  39029. /**
  39030. * Gets the value of the `Right` button
  39031. */
  39032. /**
  39033. * Sets the value of the `Right` button
  39034. */
  39035. buttonRB: number;
  39036. /**
  39037. * Gets the value of the Left joystick
  39038. */
  39039. /**
  39040. * Sets the value of the Left joystick
  39041. */
  39042. buttonLeftStick: number;
  39043. /**
  39044. * Gets the value of the Right joystick
  39045. */
  39046. /**
  39047. * Sets the value of the Right joystick
  39048. */
  39049. buttonRightStick: number;
  39050. /**
  39051. * Gets the value of D-pad up
  39052. */
  39053. /**
  39054. * Sets the value of D-pad up
  39055. */
  39056. dPadUp: number;
  39057. /**
  39058. * Gets the value of D-pad down
  39059. */
  39060. /**
  39061. * Sets the value of D-pad down
  39062. */
  39063. dPadDown: number;
  39064. /**
  39065. * Gets the value of D-pad left
  39066. */
  39067. /**
  39068. * Sets the value of D-pad left
  39069. */
  39070. dPadLeft: number;
  39071. /**
  39072. * Gets the value of D-pad right
  39073. */
  39074. /**
  39075. * Sets the value of D-pad right
  39076. */
  39077. dPadRight: number;
  39078. /**
  39079. * Force the gamepad to synchronize with device values
  39080. */
  39081. update(): void;
  39082. /**
  39083. * Disposes the gamepad
  39084. */
  39085. dispose(): void;
  39086. }
  39087. }
  39088. declare module "babylonjs/Gamepads/gamepadManager" {
  39089. import { Observable } from "babylonjs/Misc/observable";
  39090. import { Nullable } from "babylonjs/types";
  39091. import { Scene } from "babylonjs/scene";
  39092. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39093. /**
  39094. * Manager for handling gamepads
  39095. */
  39096. export class GamepadManager {
  39097. private _scene?;
  39098. private _babylonGamepads;
  39099. private _oneGamepadConnected;
  39100. /** @hidden */
  39101. _isMonitoring: boolean;
  39102. private _gamepadEventSupported;
  39103. private _gamepadSupport;
  39104. /**
  39105. * observable to be triggered when the gamepad controller has been connected
  39106. */
  39107. onGamepadConnectedObservable: Observable<Gamepad>;
  39108. /**
  39109. * observable to be triggered when the gamepad controller has been disconnected
  39110. */
  39111. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39112. private _onGamepadConnectedEvent;
  39113. private _onGamepadDisconnectedEvent;
  39114. /**
  39115. * Initializes the gamepad manager
  39116. * @param _scene BabylonJS scene
  39117. */
  39118. constructor(_scene?: Scene | undefined);
  39119. /**
  39120. * The gamepads in the game pad manager
  39121. */
  39122. readonly gamepads: Gamepad[];
  39123. /**
  39124. * Get the gamepad controllers based on type
  39125. * @param type The type of gamepad controller
  39126. * @returns Nullable gamepad
  39127. */
  39128. getGamepadByType(type?: number): Nullable<Gamepad>;
  39129. /**
  39130. * Disposes the gamepad manager
  39131. */
  39132. dispose(): void;
  39133. private _addNewGamepad;
  39134. private _startMonitoringGamepads;
  39135. private _stopMonitoringGamepads;
  39136. /** @hidden */
  39137. _checkGamepadsStatus(): void;
  39138. private _updateGamepadObjects;
  39139. }
  39140. }
  39141. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39142. import { Nullable } from "babylonjs/types";
  39143. import { Scene } from "babylonjs/scene";
  39144. import { ISceneComponent } from "babylonjs/sceneComponent";
  39145. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39146. module "babylonjs/scene" {
  39147. interface Scene {
  39148. /** @hidden */
  39149. _gamepadManager: Nullable<GamepadManager>;
  39150. /**
  39151. * Gets the gamepad manager associated with the scene
  39152. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39153. */
  39154. gamepadManager: GamepadManager;
  39155. }
  39156. }
  39157. module "babylonjs/Cameras/freeCameraInputsManager" {
  39158. /**
  39159. * Interface representing a free camera inputs manager
  39160. */
  39161. interface FreeCameraInputsManager {
  39162. /**
  39163. * Adds gamepad input support to the FreeCameraInputsManager.
  39164. * @returns the FreeCameraInputsManager
  39165. */
  39166. addGamepad(): FreeCameraInputsManager;
  39167. }
  39168. }
  39169. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39170. /**
  39171. * Interface representing an arc rotate camera inputs manager
  39172. */
  39173. interface ArcRotateCameraInputsManager {
  39174. /**
  39175. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39176. * @returns the camera inputs manager
  39177. */
  39178. addGamepad(): ArcRotateCameraInputsManager;
  39179. }
  39180. }
  39181. /**
  39182. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39183. */
  39184. export class GamepadSystemSceneComponent implements ISceneComponent {
  39185. /**
  39186. * The component name helpfull to identify the component in the list of scene components.
  39187. */
  39188. readonly name: string;
  39189. /**
  39190. * The scene the component belongs to.
  39191. */
  39192. scene: Scene;
  39193. /**
  39194. * Creates a new instance of the component for the given scene
  39195. * @param scene Defines the scene to register the component in
  39196. */
  39197. constructor(scene: Scene);
  39198. /**
  39199. * Registers the component in a given scene
  39200. */
  39201. register(): void;
  39202. /**
  39203. * Rebuilds the elements related to this component in case of
  39204. * context lost for instance.
  39205. */
  39206. rebuild(): void;
  39207. /**
  39208. * Disposes the component and the associated ressources
  39209. */
  39210. dispose(): void;
  39211. private _beforeCameraUpdate;
  39212. }
  39213. }
  39214. declare module "babylonjs/Cameras/universalCamera" {
  39215. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39216. import { Scene } from "babylonjs/scene";
  39217. import { Vector3 } from "babylonjs/Maths/math";
  39218. import "babylonjs/Gamepads/gamepadSceneComponent";
  39219. /**
  39220. * 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,
  39221. * which still works and will still be found in many Playgrounds.
  39222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39223. */
  39224. export class UniversalCamera extends TouchCamera {
  39225. /**
  39226. * Defines the gamepad rotation sensiblity.
  39227. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39228. */
  39229. gamepadAngularSensibility: number;
  39230. /**
  39231. * Defines the gamepad move sensiblity.
  39232. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39233. */
  39234. gamepadMoveSensibility: number;
  39235. /**
  39236. * 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,
  39237. * which still works and will still be found in many Playgrounds.
  39238. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39239. * @param name Define the name of the camera in the scene
  39240. * @param position Define the start position of the camera in the scene
  39241. * @param scene Define the scene the camera belongs to
  39242. */
  39243. constructor(name: string, position: Vector3, scene: Scene);
  39244. /**
  39245. * Gets the current object class name.
  39246. * @return the class name
  39247. */
  39248. getClassName(): string;
  39249. }
  39250. }
  39251. declare module "babylonjs/Cameras/gamepadCamera" {
  39252. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39253. import { Scene } from "babylonjs/scene";
  39254. import { Vector3 } from "babylonjs/Maths/math";
  39255. /**
  39256. * This represents a FPS type of camera. This is only here for back compat purpose.
  39257. * Please use the UniversalCamera instead as both are identical.
  39258. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39259. */
  39260. export class GamepadCamera extends UniversalCamera {
  39261. /**
  39262. * Instantiates a new Gamepad Camera
  39263. * This represents a FPS type of camera. This is only here for back compat purpose.
  39264. * Please use the UniversalCamera instead as both are identical.
  39265. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39266. * @param name Define the name of the camera in the scene
  39267. * @param position Define the start position of the camera in the scene
  39268. * @param scene Define the scene the camera belongs to
  39269. */
  39270. constructor(name: string, position: Vector3, scene: Scene);
  39271. /**
  39272. * Gets the current object class name.
  39273. * @return the class name
  39274. */
  39275. getClassName(): string;
  39276. }
  39277. }
  39278. declare module "babylonjs/Shaders/pass.fragment" {
  39279. /** @hidden */
  39280. export var passPixelShader: {
  39281. name: string;
  39282. shader: string;
  39283. };
  39284. }
  39285. declare module "babylonjs/Shaders/passCube.fragment" {
  39286. /** @hidden */
  39287. export var passCubePixelShader: {
  39288. name: string;
  39289. shader: string;
  39290. };
  39291. }
  39292. declare module "babylonjs/PostProcesses/passPostProcess" {
  39293. import { Nullable } from "babylonjs/types";
  39294. import { Camera } from "babylonjs/Cameras/camera";
  39295. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39296. import { Engine } from "babylonjs/Engines/engine";
  39297. import "babylonjs/Shaders/pass.fragment";
  39298. import "babylonjs/Shaders/passCube.fragment";
  39299. /**
  39300. * PassPostProcess which produces an output the same as it's input
  39301. */
  39302. export class PassPostProcess extends PostProcess {
  39303. /**
  39304. * Creates the PassPostProcess
  39305. * @param name The name of the effect.
  39306. * @param options The required width/height ratio to downsize to before computing the render pass.
  39307. * @param camera The camera to apply the render pass to.
  39308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39309. * @param engine The engine which the post process will be applied. (default: current engine)
  39310. * @param reusable If the post process can be reused on the same frame. (default: false)
  39311. * @param textureType The type of texture to be used when performing the post processing.
  39312. * @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)
  39313. */
  39314. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39315. }
  39316. /**
  39317. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39318. */
  39319. export class PassCubePostProcess extends PostProcess {
  39320. private _face;
  39321. /**
  39322. * Gets or sets the cube face to display.
  39323. * * 0 is +X
  39324. * * 1 is -X
  39325. * * 2 is +Y
  39326. * * 3 is -Y
  39327. * * 4 is +Z
  39328. * * 5 is -Z
  39329. */
  39330. face: number;
  39331. /**
  39332. * Creates the PassCubePostProcess
  39333. * @param name The name of the effect.
  39334. * @param options The required width/height ratio to downsize to before computing the render pass.
  39335. * @param camera The camera to apply the render pass to.
  39336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39337. * @param engine The engine which the post process will be applied. (default: current engine)
  39338. * @param reusable If the post process can be reused on the same frame. (default: false)
  39339. * @param textureType The type of texture to be used when performing the post processing.
  39340. * @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)
  39341. */
  39342. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39343. }
  39344. }
  39345. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39346. /** @hidden */
  39347. export var anaglyphPixelShader: {
  39348. name: string;
  39349. shader: string;
  39350. };
  39351. }
  39352. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39353. import { Engine } from "babylonjs/Engines/engine";
  39354. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39355. import { Camera } from "babylonjs/Cameras/camera";
  39356. import "babylonjs/Shaders/anaglyph.fragment";
  39357. /**
  39358. * Postprocess used to generate anaglyphic rendering
  39359. */
  39360. export class AnaglyphPostProcess extends PostProcess {
  39361. private _passedProcess;
  39362. /**
  39363. * Creates a new AnaglyphPostProcess
  39364. * @param name defines postprocess name
  39365. * @param options defines creation options or target ratio scale
  39366. * @param rigCameras defines cameras using this postprocess
  39367. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39368. * @param engine defines hosting engine
  39369. * @param reusable defines if the postprocess will be reused multiple times per frame
  39370. */
  39371. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39372. }
  39373. }
  39374. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39375. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39376. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39377. import { Scene } from "babylonjs/scene";
  39378. import { Vector3 } from "babylonjs/Maths/math";
  39379. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39380. /**
  39381. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39382. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39383. */
  39384. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39385. /**
  39386. * Creates a new AnaglyphArcRotateCamera
  39387. * @param name defines camera name
  39388. * @param alpha defines alpha angle (in radians)
  39389. * @param beta defines beta angle (in radians)
  39390. * @param radius defines radius
  39391. * @param target defines camera target
  39392. * @param interaxialDistance defines distance between each color axis
  39393. * @param scene defines the hosting scene
  39394. */
  39395. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39396. /**
  39397. * Gets camera class name
  39398. * @returns AnaglyphArcRotateCamera
  39399. */
  39400. getClassName(): string;
  39401. }
  39402. }
  39403. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39405. import { Scene } from "babylonjs/scene";
  39406. import { Vector3 } from "babylonjs/Maths/math";
  39407. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39408. /**
  39409. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39410. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39411. */
  39412. export class AnaglyphFreeCamera extends FreeCamera {
  39413. /**
  39414. * Creates a new AnaglyphFreeCamera
  39415. * @param name defines camera name
  39416. * @param position defines initial position
  39417. * @param interaxialDistance defines distance between each color axis
  39418. * @param scene defines the hosting scene
  39419. */
  39420. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39421. /**
  39422. * Gets camera class name
  39423. * @returns AnaglyphFreeCamera
  39424. */
  39425. getClassName(): string;
  39426. }
  39427. }
  39428. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39429. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39430. import { Scene } from "babylonjs/scene";
  39431. import { Vector3 } from "babylonjs/Maths/math";
  39432. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39433. /**
  39434. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39435. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39436. */
  39437. export class AnaglyphGamepadCamera extends GamepadCamera {
  39438. /**
  39439. * Creates a new AnaglyphGamepadCamera
  39440. * @param name defines camera name
  39441. * @param position defines initial position
  39442. * @param interaxialDistance defines distance between each color axis
  39443. * @param scene defines the hosting scene
  39444. */
  39445. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39446. /**
  39447. * Gets camera class name
  39448. * @returns AnaglyphGamepadCamera
  39449. */
  39450. getClassName(): string;
  39451. }
  39452. }
  39453. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39454. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39455. import { Scene } from "babylonjs/scene";
  39456. import { Vector3 } from "babylonjs/Maths/math";
  39457. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39458. /**
  39459. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39460. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39461. */
  39462. export class AnaglyphUniversalCamera extends UniversalCamera {
  39463. /**
  39464. * Creates a new AnaglyphUniversalCamera
  39465. * @param name defines camera name
  39466. * @param position defines initial position
  39467. * @param interaxialDistance defines distance between each color axis
  39468. * @param scene defines the hosting scene
  39469. */
  39470. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39471. /**
  39472. * Gets camera class name
  39473. * @returns AnaglyphUniversalCamera
  39474. */
  39475. getClassName(): string;
  39476. }
  39477. }
  39478. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39479. /** @hidden */
  39480. export var stereoscopicInterlacePixelShader: {
  39481. name: string;
  39482. shader: string;
  39483. };
  39484. }
  39485. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39486. import { Camera } from "babylonjs/Cameras/camera";
  39487. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39488. import { Engine } from "babylonjs/Engines/engine";
  39489. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39490. /**
  39491. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39492. */
  39493. export class StereoscopicInterlacePostProcess extends PostProcess {
  39494. private _stepSize;
  39495. private _passedProcess;
  39496. /**
  39497. * Initializes a StereoscopicInterlacePostProcess
  39498. * @param name The name of the effect.
  39499. * @param rigCameras The rig cameras to be appled to the post process
  39500. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39502. * @param engine The engine which the post process will be applied. (default: current engine)
  39503. * @param reusable If the post process can be reused on the same frame. (default: false)
  39504. */
  39505. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39506. }
  39507. }
  39508. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39509. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39510. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39511. import { Scene } from "babylonjs/scene";
  39512. import { Vector3 } from "babylonjs/Maths/math";
  39513. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39514. /**
  39515. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39516. * @see http://doc.babylonjs.com/features/cameras
  39517. */
  39518. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39519. /**
  39520. * Creates a new StereoscopicArcRotateCamera
  39521. * @param name defines camera name
  39522. * @param alpha defines alpha angle (in radians)
  39523. * @param beta defines beta angle (in radians)
  39524. * @param radius defines radius
  39525. * @param target defines camera target
  39526. * @param interaxialDistance defines distance between each color axis
  39527. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39528. * @param scene defines the hosting scene
  39529. */
  39530. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39531. /**
  39532. * Gets camera class name
  39533. * @returns StereoscopicArcRotateCamera
  39534. */
  39535. getClassName(): string;
  39536. }
  39537. }
  39538. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39539. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39540. import { Scene } from "babylonjs/scene";
  39541. import { Vector3 } from "babylonjs/Maths/math";
  39542. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39543. /**
  39544. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39545. * @see http://doc.babylonjs.com/features/cameras
  39546. */
  39547. export class StereoscopicFreeCamera extends FreeCamera {
  39548. /**
  39549. * Creates a new StereoscopicFreeCamera
  39550. * @param name defines camera name
  39551. * @param position defines initial position
  39552. * @param interaxialDistance defines distance between each color axis
  39553. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39554. * @param scene defines the hosting scene
  39555. */
  39556. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39557. /**
  39558. * Gets camera class name
  39559. * @returns StereoscopicFreeCamera
  39560. */
  39561. getClassName(): string;
  39562. }
  39563. }
  39564. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39565. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39566. import { Scene } from "babylonjs/scene";
  39567. import { Vector3 } from "babylonjs/Maths/math";
  39568. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39569. /**
  39570. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39571. * @see http://doc.babylonjs.com/features/cameras
  39572. */
  39573. export class StereoscopicGamepadCamera extends GamepadCamera {
  39574. /**
  39575. * Creates a new StereoscopicGamepadCamera
  39576. * @param name defines camera name
  39577. * @param position defines initial position
  39578. * @param interaxialDistance defines distance between each color axis
  39579. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39580. * @param scene defines the hosting scene
  39581. */
  39582. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39583. /**
  39584. * Gets camera class name
  39585. * @returns StereoscopicGamepadCamera
  39586. */
  39587. getClassName(): string;
  39588. }
  39589. }
  39590. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39591. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39592. import { Scene } from "babylonjs/scene";
  39593. import { Vector3 } from "babylonjs/Maths/math";
  39594. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39595. /**
  39596. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39597. * @see http://doc.babylonjs.com/features/cameras
  39598. */
  39599. export class StereoscopicUniversalCamera extends UniversalCamera {
  39600. /**
  39601. * Creates a new StereoscopicUniversalCamera
  39602. * @param name defines camera name
  39603. * @param position defines initial position
  39604. * @param interaxialDistance defines distance between each color axis
  39605. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39606. * @param scene defines the hosting scene
  39607. */
  39608. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39609. /**
  39610. * Gets camera class name
  39611. * @returns StereoscopicUniversalCamera
  39612. */
  39613. getClassName(): string;
  39614. }
  39615. }
  39616. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39617. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39618. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39619. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39620. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39621. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39622. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39623. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39624. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39625. }
  39626. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39627. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39628. import { Scene } from "babylonjs/scene";
  39629. import { Vector3 } from "babylonjs/Maths/math";
  39630. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39631. /**
  39632. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39633. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39634. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39635. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39636. */
  39637. export class VirtualJoysticksCamera extends FreeCamera {
  39638. /**
  39639. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39640. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39641. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39642. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39643. * @param name Define the name of the camera in the scene
  39644. * @param position Define the start position of the camera in the scene
  39645. * @param scene Define the scene the camera belongs to
  39646. */
  39647. constructor(name: string, position: Vector3, scene: Scene);
  39648. /**
  39649. * Gets the current object class name.
  39650. * @return the class name
  39651. */
  39652. getClassName(): string;
  39653. }
  39654. }
  39655. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39656. import { Matrix } from "babylonjs/Maths/math";
  39657. /**
  39658. * This represents all the required metrics to create a VR camera.
  39659. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39660. */
  39661. export class VRCameraMetrics {
  39662. /**
  39663. * Define the horizontal resolution off the screen.
  39664. */
  39665. hResolution: number;
  39666. /**
  39667. * Define the vertical resolution off the screen.
  39668. */
  39669. vResolution: number;
  39670. /**
  39671. * Define the horizontal screen size.
  39672. */
  39673. hScreenSize: number;
  39674. /**
  39675. * Define the vertical screen size.
  39676. */
  39677. vScreenSize: number;
  39678. /**
  39679. * Define the vertical screen center position.
  39680. */
  39681. vScreenCenter: number;
  39682. /**
  39683. * Define the distance of the eyes to the screen.
  39684. */
  39685. eyeToScreenDistance: number;
  39686. /**
  39687. * Define the distance between both lenses
  39688. */
  39689. lensSeparationDistance: number;
  39690. /**
  39691. * Define the distance between both viewer's eyes.
  39692. */
  39693. interpupillaryDistance: number;
  39694. /**
  39695. * Define the distortion factor of the VR postprocess.
  39696. * Please, touch with care.
  39697. */
  39698. distortionK: number[];
  39699. /**
  39700. * Define the chromatic aberration correction factors for the VR post process.
  39701. */
  39702. chromaAbCorrection: number[];
  39703. /**
  39704. * Define the scale factor of the post process.
  39705. * The smaller the better but the slower.
  39706. */
  39707. postProcessScaleFactor: number;
  39708. /**
  39709. * Define an offset for the lens center.
  39710. */
  39711. lensCenterOffset: number;
  39712. /**
  39713. * Define if the current vr camera should compensate the distortion of the lense or not.
  39714. */
  39715. compensateDistortion: boolean;
  39716. /**
  39717. * Defines if multiview should be enabled when rendering (Default: false)
  39718. */
  39719. multiviewEnabled: boolean;
  39720. /**
  39721. * Gets the rendering aspect ratio based on the provided resolutions.
  39722. */
  39723. readonly aspectRatio: number;
  39724. /**
  39725. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39726. */
  39727. readonly aspectRatioFov: number;
  39728. /**
  39729. * @hidden
  39730. */
  39731. readonly leftHMatrix: Matrix;
  39732. /**
  39733. * @hidden
  39734. */
  39735. readonly rightHMatrix: Matrix;
  39736. /**
  39737. * @hidden
  39738. */
  39739. readonly leftPreViewMatrix: Matrix;
  39740. /**
  39741. * @hidden
  39742. */
  39743. readonly rightPreViewMatrix: Matrix;
  39744. /**
  39745. * Get the default VRMetrics based on the most generic setup.
  39746. * @returns the default vr metrics
  39747. */
  39748. static GetDefault(): VRCameraMetrics;
  39749. }
  39750. }
  39751. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39752. /** @hidden */
  39753. export var vrDistortionCorrectionPixelShader: {
  39754. name: string;
  39755. shader: string;
  39756. };
  39757. }
  39758. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39759. import { Camera } from "babylonjs/Cameras/camera";
  39760. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39761. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39762. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39763. /**
  39764. * VRDistortionCorrectionPostProcess used for mobile VR
  39765. */
  39766. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39767. private _isRightEye;
  39768. private _distortionFactors;
  39769. private _postProcessScaleFactor;
  39770. private _lensCenterOffset;
  39771. private _scaleIn;
  39772. private _scaleFactor;
  39773. private _lensCenter;
  39774. /**
  39775. * Initializes the VRDistortionCorrectionPostProcess
  39776. * @param name The name of the effect.
  39777. * @param camera The camera to apply the render pass to.
  39778. * @param isRightEye If this is for the right eye distortion
  39779. * @param vrMetrics All the required metrics for the VR camera
  39780. */
  39781. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39782. }
  39783. }
  39784. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39785. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39786. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39787. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39788. import { Scene } from "babylonjs/scene";
  39789. import { Vector3 } from "babylonjs/Maths/math";
  39790. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39791. import "babylonjs/Cameras/RigModes/vrRigMode";
  39792. /**
  39793. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39794. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39795. */
  39796. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39797. /**
  39798. * Creates a new VRDeviceOrientationArcRotateCamera
  39799. * @param name defines camera name
  39800. * @param alpha defines the camera rotation along the logitudinal axis
  39801. * @param beta defines the camera rotation along the latitudinal axis
  39802. * @param radius defines the camera distance from its target
  39803. * @param target defines the camera target
  39804. * @param scene defines the scene the camera belongs to
  39805. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39806. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39807. */
  39808. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39809. /**
  39810. * Gets camera class name
  39811. * @returns VRDeviceOrientationArcRotateCamera
  39812. */
  39813. getClassName(): string;
  39814. }
  39815. }
  39816. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39817. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39818. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39819. import { Scene } from "babylonjs/scene";
  39820. import { Vector3 } from "babylonjs/Maths/math";
  39821. import "babylonjs/Cameras/RigModes/vrRigMode";
  39822. /**
  39823. * Camera used to simulate VR rendering (based on FreeCamera)
  39824. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39825. */
  39826. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39827. /**
  39828. * Creates a new VRDeviceOrientationFreeCamera
  39829. * @param name defines camera name
  39830. * @param position defines the start position of the camera
  39831. * @param scene defines the scene the camera belongs to
  39832. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39833. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39834. */
  39835. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39836. /**
  39837. * Gets camera class name
  39838. * @returns VRDeviceOrientationFreeCamera
  39839. */
  39840. getClassName(): string;
  39841. }
  39842. }
  39843. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39844. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39845. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39846. import { Scene } from "babylonjs/scene";
  39847. import { Vector3 } from "babylonjs/Maths/math";
  39848. import "babylonjs/Gamepads/gamepadSceneComponent";
  39849. /**
  39850. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39851. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39852. */
  39853. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39854. /**
  39855. * Creates a new VRDeviceOrientationGamepadCamera
  39856. * @param name defines camera name
  39857. * @param position defines the start position of the camera
  39858. * @param scene defines the scene the camera belongs to
  39859. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39860. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39861. */
  39862. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39863. /**
  39864. * Gets camera class name
  39865. * @returns VRDeviceOrientationGamepadCamera
  39866. */
  39867. getClassName(): string;
  39868. }
  39869. }
  39870. declare module "babylonjs/Materials/pushMaterial" {
  39871. import { Nullable } from "babylonjs/types";
  39872. import { Scene } from "babylonjs/scene";
  39873. import { Matrix } from "babylonjs/Maths/math";
  39874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39875. import { Mesh } from "babylonjs/Meshes/mesh";
  39876. import { Material } from "babylonjs/Materials/material";
  39877. import { Effect } from "babylonjs/Materials/effect";
  39878. /**
  39879. * Base class of materials working in push mode in babylon JS
  39880. * @hidden
  39881. */
  39882. export class PushMaterial extends Material {
  39883. protected _activeEffect: Effect;
  39884. protected _normalMatrix: Matrix;
  39885. /**
  39886. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39887. * This means that the material can keep using a previous shader while a new one is being compiled.
  39888. * This is mostly used when shader parallel compilation is supported (true by default)
  39889. */
  39890. allowShaderHotSwapping: boolean;
  39891. constructor(name: string, scene: Scene);
  39892. getEffect(): Effect;
  39893. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39894. /**
  39895. * Binds the given world matrix to the active effect
  39896. *
  39897. * @param world the matrix to bind
  39898. */
  39899. bindOnlyWorldMatrix(world: Matrix): void;
  39900. /**
  39901. * Binds the given normal matrix to the active effect
  39902. *
  39903. * @param normalMatrix the matrix to bind
  39904. */
  39905. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39906. bind(world: Matrix, mesh?: Mesh): void;
  39907. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39908. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39909. }
  39910. }
  39911. declare module "babylonjs/Materials/materialFlags" {
  39912. /**
  39913. * This groups all the flags used to control the materials channel.
  39914. */
  39915. export class MaterialFlags {
  39916. private static _DiffuseTextureEnabled;
  39917. /**
  39918. * Are diffuse textures enabled in the application.
  39919. */
  39920. static DiffuseTextureEnabled: boolean;
  39921. private static _AmbientTextureEnabled;
  39922. /**
  39923. * Are ambient textures enabled in the application.
  39924. */
  39925. static AmbientTextureEnabled: boolean;
  39926. private static _OpacityTextureEnabled;
  39927. /**
  39928. * Are opacity textures enabled in the application.
  39929. */
  39930. static OpacityTextureEnabled: boolean;
  39931. private static _ReflectionTextureEnabled;
  39932. /**
  39933. * Are reflection textures enabled in the application.
  39934. */
  39935. static ReflectionTextureEnabled: boolean;
  39936. private static _EmissiveTextureEnabled;
  39937. /**
  39938. * Are emissive textures enabled in the application.
  39939. */
  39940. static EmissiveTextureEnabled: boolean;
  39941. private static _SpecularTextureEnabled;
  39942. /**
  39943. * Are specular textures enabled in the application.
  39944. */
  39945. static SpecularTextureEnabled: boolean;
  39946. private static _BumpTextureEnabled;
  39947. /**
  39948. * Are bump textures enabled in the application.
  39949. */
  39950. static BumpTextureEnabled: boolean;
  39951. private static _LightmapTextureEnabled;
  39952. /**
  39953. * Are lightmap textures enabled in the application.
  39954. */
  39955. static LightmapTextureEnabled: boolean;
  39956. private static _RefractionTextureEnabled;
  39957. /**
  39958. * Are refraction textures enabled in the application.
  39959. */
  39960. static RefractionTextureEnabled: boolean;
  39961. private static _ColorGradingTextureEnabled;
  39962. /**
  39963. * Are color grading textures enabled in the application.
  39964. */
  39965. static ColorGradingTextureEnabled: boolean;
  39966. private static _FresnelEnabled;
  39967. /**
  39968. * Are fresnels enabled in the application.
  39969. */
  39970. static FresnelEnabled: boolean;
  39971. private static _ClearCoatTextureEnabled;
  39972. /**
  39973. * Are clear coat textures enabled in the application.
  39974. */
  39975. static ClearCoatTextureEnabled: boolean;
  39976. private static _ClearCoatBumpTextureEnabled;
  39977. /**
  39978. * Are clear coat bump textures enabled in the application.
  39979. */
  39980. static ClearCoatBumpTextureEnabled: boolean;
  39981. private static _ClearCoatTintTextureEnabled;
  39982. /**
  39983. * Are clear coat tint textures enabled in the application.
  39984. */
  39985. static ClearCoatTintTextureEnabled: boolean;
  39986. private static _SheenTextureEnabled;
  39987. /**
  39988. * Are sheen textures enabled in the application.
  39989. */
  39990. static SheenTextureEnabled: boolean;
  39991. private static _AnisotropicTextureEnabled;
  39992. /**
  39993. * Are anisotropic textures enabled in the application.
  39994. */
  39995. static AnisotropicTextureEnabled: boolean;
  39996. private static _ThicknessTextureEnabled;
  39997. /**
  39998. * Are thickness textures enabled in the application.
  39999. */
  40000. static ThicknessTextureEnabled: boolean;
  40001. }
  40002. }
  40003. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40004. /** @hidden */
  40005. export var defaultFragmentDeclaration: {
  40006. name: string;
  40007. shader: string;
  40008. };
  40009. }
  40010. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40011. /** @hidden */
  40012. export var defaultUboDeclaration: {
  40013. name: string;
  40014. shader: string;
  40015. };
  40016. }
  40017. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40018. /** @hidden */
  40019. export var lightFragmentDeclaration: {
  40020. name: string;
  40021. shader: string;
  40022. };
  40023. }
  40024. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40025. /** @hidden */
  40026. export var lightUboDeclaration: {
  40027. name: string;
  40028. shader: string;
  40029. };
  40030. }
  40031. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40032. /** @hidden */
  40033. export var lightsFragmentFunctions: {
  40034. name: string;
  40035. shader: string;
  40036. };
  40037. }
  40038. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40039. /** @hidden */
  40040. export var shadowsFragmentFunctions: {
  40041. name: string;
  40042. shader: string;
  40043. };
  40044. }
  40045. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40046. /** @hidden */
  40047. export var fresnelFunction: {
  40048. name: string;
  40049. shader: string;
  40050. };
  40051. }
  40052. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40053. /** @hidden */
  40054. export var reflectionFunction: {
  40055. name: string;
  40056. shader: string;
  40057. };
  40058. }
  40059. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40060. /** @hidden */
  40061. export var bumpFragmentFunctions: {
  40062. name: string;
  40063. shader: string;
  40064. };
  40065. }
  40066. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40067. /** @hidden */
  40068. export var logDepthDeclaration: {
  40069. name: string;
  40070. shader: string;
  40071. };
  40072. }
  40073. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40074. /** @hidden */
  40075. export var bumpFragment: {
  40076. name: string;
  40077. shader: string;
  40078. };
  40079. }
  40080. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40081. /** @hidden */
  40082. export var depthPrePass: {
  40083. name: string;
  40084. shader: string;
  40085. };
  40086. }
  40087. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40088. /** @hidden */
  40089. export var lightFragment: {
  40090. name: string;
  40091. shader: string;
  40092. };
  40093. }
  40094. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40095. /** @hidden */
  40096. export var logDepthFragment: {
  40097. name: string;
  40098. shader: string;
  40099. };
  40100. }
  40101. declare module "babylonjs/Shaders/default.fragment" {
  40102. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40103. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40104. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40105. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40106. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40107. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40108. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40109. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40110. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40111. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40112. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40113. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40114. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40115. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40116. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40117. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40118. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40119. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40120. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40121. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40122. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40123. /** @hidden */
  40124. export var defaultPixelShader: {
  40125. name: string;
  40126. shader: string;
  40127. };
  40128. }
  40129. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40130. /** @hidden */
  40131. export var defaultVertexDeclaration: {
  40132. name: string;
  40133. shader: string;
  40134. };
  40135. }
  40136. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40137. /** @hidden */
  40138. export var bumpVertexDeclaration: {
  40139. name: string;
  40140. shader: string;
  40141. };
  40142. }
  40143. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40144. /** @hidden */
  40145. export var bumpVertex: {
  40146. name: string;
  40147. shader: string;
  40148. };
  40149. }
  40150. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40151. /** @hidden */
  40152. export var fogVertex: {
  40153. name: string;
  40154. shader: string;
  40155. };
  40156. }
  40157. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40158. /** @hidden */
  40159. export var shadowsVertex: {
  40160. name: string;
  40161. shader: string;
  40162. };
  40163. }
  40164. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40165. /** @hidden */
  40166. export var pointCloudVertex: {
  40167. name: string;
  40168. shader: string;
  40169. };
  40170. }
  40171. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40172. /** @hidden */
  40173. export var logDepthVertex: {
  40174. name: string;
  40175. shader: string;
  40176. };
  40177. }
  40178. declare module "babylonjs/Shaders/default.vertex" {
  40179. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40180. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40181. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40182. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40183. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40184. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40185. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40186. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40187. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40188. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40189. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40190. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40191. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40192. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40193. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40194. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40195. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40196. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40197. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40198. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40199. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40200. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40201. /** @hidden */
  40202. export var defaultVertexShader: {
  40203. name: string;
  40204. shader: string;
  40205. };
  40206. }
  40207. declare module "babylonjs/Materials/standardMaterial" {
  40208. import { SmartArray } from "babylonjs/Misc/smartArray";
  40209. import { IAnimatable } from "babylonjs/Misc/tools";
  40210. import { Nullable } from "babylonjs/types";
  40211. import { Scene } from "babylonjs/scene";
  40212. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40213. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40215. import { Mesh } from "babylonjs/Meshes/mesh";
  40216. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40217. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40218. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40219. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40220. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40222. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40223. import "babylonjs/Shaders/default.fragment";
  40224. import "babylonjs/Shaders/default.vertex";
  40225. /** @hidden */
  40226. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40227. MAINUV1: boolean;
  40228. MAINUV2: boolean;
  40229. DIFFUSE: boolean;
  40230. DIFFUSEDIRECTUV: number;
  40231. AMBIENT: boolean;
  40232. AMBIENTDIRECTUV: number;
  40233. OPACITY: boolean;
  40234. OPACITYDIRECTUV: number;
  40235. OPACITYRGB: boolean;
  40236. REFLECTION: boolean;
  40237. EMISSIVE: boolean;
  40238. EMISSIVEDIRECTUV: number;
  40239. SPECULAR: boolean;
  40240. SPECULARDIRECTUV: number;
  40241. BUMP: boolean;
  40242. BUMPDIRECTUV: number;
  40243. PARALLAX: boolean;
  40244. PARALLAXOCCLUSION: boolean;
  40245. SPECULAROVERALPHA: boolean;
  40246. CLIPPLANE: boolean;
  40247. CLIPPLANE2: boolean;
  40248. CLIPPLANE3: boolean;
  40249. CLIPPLANE4: boolean;
  40250. ALPHATEST: boolean;
  40251. DEPTHPREPASS: boolean;
  40252. ALPHAFROMDIFFUSE: boolean;
  40253. POINTSIZE: boolean;
  40254. FOG: boolean;
  40255. SPECULARTERM: boolean;
  40256. DIFFUSEFRESNEL: boolean;
  40257. OPACITYFRESNEL: boolean;
  40258. REFLECTIONFRESNEL: boolean;
  40259. REFRACTIONFRESNEL: boolean;
  40260. EMISSIVEFRESNEL: boolean;
  40261. FRESNEL: boolean;
  40262. NORMAL: boolean;
  40263. UV1: boolean;
  40264. UV2: boolean;
  40265. VERTEXCOLOR: boolean;
  40266. VERTEXALPHA: boolean;
  40267. NUM_BONE_INFLUENCERS: number;
  40268. BonesPerMesh: number;
  40269. BONETEXTURE: boolean;
  40270. INSTANCES: boolean;
  40271. GLOSSINESS: boolean;
  40272. ROUGHNESS: boolean;
  40273. EMISSIVEASILLUMINATION: boolean;
  40274. LINKEMISSIVEWITHDIFFUSE: boolean;
  40275. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40276. LIGHTMAP: boolean;
  40277. LIGHTMAPDIRECTUV: number;
  40278. OBJECTSPACE_NORMALMAP: boolean;
  40279. USELIGHTMAPASSHADOWMAP: boolean;
  40280. REFLECTIONMAP_3D: boolean;
  40281. REFLECTIONMAP_SPHERICAL: boolean;
  40282. REFLECTIONMAP_PLANAR: boolean;
  40283. REFLECTIONMAP_CUBIC: boolean;
  40284. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40285. REFLECTIONMAP_PROJECTION: boolean;
  40286. REFLECTIONMAP_SKYBOX: boolean;
  40287. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40288. REFLECTIONMAP_EXPLICIT: boolean;
  40289. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40290. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40291. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40292. INVERTCUBICMAP: boolean;
  40293. LOGARITHMICDEPTH: boolean;
  40294. REFRACTION: boolean;
  40295. REFRACTIONMAP_3D: boolean;
  40296. REFLECTIONOVERALPHA: boolean;
  40297. TWOSIDEDLIGHTING: boolean;
  40298. SHADOWFLOAT: boolean;
  40299. MORPHTARGETS: boolean;
  40300. MORPHTARGETS_NORMAL: boolean;
  40301. MORPHTARGETS_TANGENT: boolean;
  40302. NUM_MORPH_INFLUENCERS: number;
  40303. NONUNIFORMSCALING: boolean;
  40304. PREMULTIPLYALPHA: boolean;
  40305. IMAGEPROCESSING: boolean;
  40306. VIGNETTE: boolean;
  40307. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40308. VIGNETTEBLENDMODEOPAQUE: boolean;
  40309. TONEMAPPING: boolean;
  40310. TONEMAPPING_ACES: boolean;
  40311. CONTRAST: boolean;
  40312. COLORCURVES: boolean;
  40313. COLORGRADING: boolean;
  40314. COLORGRADING3D: boolean;
  40315. SAMPLER3DGREENDEPTH: boolean;
  40316. SAMPLER3DBGRMAP: boolean;
  40317. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40318. MULTIVIEW: boolean;
  40319. /**
  40320. * If the reflection texture on this material is in linear color space
  40321. * @hidden
  40322. */
  40323. IS_REFLECTION_LINEAR: boolean;
  40324. /**
  40325. * If the refraction texture on this material is in linear color space
  40326. * @hidden
  40327. */
  40328. IS_REFRACTION_LINEAR: boolean;
  40329. EXPOSURE: boolean;
  40330. constructor();
  40331. setReflectionMode(modeToEnable: string): void;
  40332. }
  40333. /**
  40334. * This is the default material used in Babylon. It is the best trade off between quality
  40335. * and performances.
  40336. * @see http://doc.babylonjs.com/babylon101/materials
  40337. */
  40338. export class StandardMaterial extends PushMaterial {
  40339. private _diffuseTexture;
  40340. /**
  40341. * The basic texture of the material as viewed under a light.
  40342. */
  40343. diffuseTexture: Nullable<BaseTexture>;
  40344. private _ambientTexture;
  40345. /**
  40346. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40347. */
  40348. ambientTexture: Nullable<BaseTexture>;
  40349. private _opacityTexture;
  40350. /**
  40351. * Define the transparency of the material from a texture.
  40352. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40353. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40354. */
  40355. opacityTexture: Nullable<BaseTexture>;
  40356. private _reflectionTexture;
  40357. /**
  40358. * Define the texture used to display the reflection.
  40359. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40360. */
  40361. reflectionTexture: Nullable<BaseTexture>;
  40362. private _emissiveTexture;
  40363. /**
  40364. * Define texture of the material as if self lit.
  40365. * This will be mixed in the final result even in the absence of light.
  40366. */
  40367. emissiveTexture: Nullable<BaseTexture>;
  40368. private _specularTexture;
  40369. /**
  40370. * Define how the color and intensity of the highlight given by the light in the material.
  40371. */
  40372. specularTexture: Nullable<BaseTexture>;
  40373. private _bumpTexture;
  40374. /**
  40375. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40376. * 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.
  40377. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40378. */
  40379. bumpTexture: Nullable<BaseTexture>;
  40380. private _lightmapTexture;
  40381. /**
  40382. * Complex lighting can be computationally expensive to compute at runtime.
  40383. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40384. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40385. */
  40386. lightmapTexture: Nullable<BaseTexture>;
  40387. private _refractionTexture;
  40388. /**
  40389. * Define the texture used to display the refraction.
  40390. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40391. */
  40392. refractionTexture: Nullable<BaseTexture>;
  40393. /**
  40394. * The color of the material lit by the environmental background lighting.
  40395. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40396. */
  40397. ambientColor: Color3;
  40398. /**
  40399. * The basic color of the material as viewed under a light.
  40400. */
  40401. diffuseColor: Color3;
  40402. /**
  40403. * Define how the color and intensity of the highlight given by the light in the material.
  40404. */
  40405. specularColor: Color3;
  40406. /**
  40407. * Define the color of the material as if self lit.
  40408. * This will be mixed in the final result even in the absence of light.
  40409. */
  40410. emissiveColor: Color3;
  40411. /**
  40412. * Defines how sharp are the highlights in the material.
  40413. * The bigger the value the sharper giving a more glossy feeling to the result.
  40414. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40415. */
  40416. specularPower: number;
  40417. private _useAlphaFromDiffuseTexture;
  40418. /**
  40419. * Does the transparency come from the diffuse texture alpha channel.
  40420. */
  40421. useAlphaFromDiffuseTexture: boolean;
  40422. private _useEmissiveAsIllumination;
  40423. /**
  40424. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40425. */
  40426. useEmissiveAsIllumination: boolean;
  40427. private _linkEmissiveWithDiffuse;
  40428. /**
  40429. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40430. * the emissive level when the final color is close to one.
  40431. */
  40432. linkEmissiveWithDiffuse: boolean;
  40433. private _useSpecularOverAlpha;
  40434. /**
  40435. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40436. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40437. */
  40438. useSpecularOverAlpha: boolean;
  40439. private _useReflectionOverAlpha;
  40440. /**
  40441. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40442. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40443. */
  40444. useReflectionOverAlpha: boolean;
  40445. private _disableLighting;
  40446. /**
  40447. * Does lights from the scene impacts this material.
  40448. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40449. */
  40450. disableLighting: boolean;
  40451. private _useObjectSpaceNormalMap;
  40452. /**
  40453. * Allows using an object space normal map (instead of tangent space).
  40454. */
  40455. useObjectSpaceNormalMap: boolean;
  40456. private _useParallax;
  40457. /**
  40458. * Is parallax enabled or not.
  40459. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40460. */
  40461. useParallax: boolean;
  40462. private _useParallaxOcclusion;
  40463. /**
  40464. * Is parallax occlusion enabled or not.
  40465. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40466. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40467. */
  40468. useParallaxOcclusion: boolean;
  40469. /**
  40470. * 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.
  40471. */
  40472. parallaxScaleBias: number;
  40473. private _roughness;
  40474. /**
  40475. * Helps to define how blurry the reflections should appears in the material.
  40476. */
  40477. roughness: number;
  40478. /**
  40479. * In case of refraction, define the value of the index of refraction.
  40480. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40481. */
  40482. indexOfRefraction: number;
  40483. /**
  40484. * Invert the refraction texture alongside the y axis.
  40485. * It can be useful with procedural textures or probe for instance.
  40486. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40487. */
  40488. invertRefractionY: boolean;
  40489. /**
  40490. * Defines the alpha limits in alpha test mode.
  40491. */
  40492. alphaCutOff: number;
  40493. private _useLightmapAsShadowmap;
  40494. /**
  40495. * In case of light mapping, define whether the map contains light or shadow informations.
  40496. */
  40497. useLightmapAsShadowmap: boolean;
  40498. private _diffuseFresnelParameters;
  40499. /**
  40500. * Define the diffuse fresnel parameters of the material.
  40501. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40502. */
  40503. diffuseFresnelParameters: FresnelParameters;
  40504. private _opacityFresnelParameters;
  40505. /**
  40506. * Define the opacity fresnel parameters of the material.
  40507. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40508. */
  40509. opacityFresnelParameters: FresnelParameters;
  40510. private _reflectionFresnelParameters;
  40511. /**
  40512. * Define the reflection fresnel parameters of the material.
  40513. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40514. */
  40515. reflectionFresnelParameters: FresnelParameters;
  40516. private _refractionFresnelParameters;
  40517. /**
  40518. * Define the refraction fresnel parameters of the material.
  40519. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40520. */
  40521. refractionFresnelParameters: FresnelParameters;
  40522. private _emissiveFresnelParameters;
  40523. /**
  40524. * Define the emissive fresnel parameters of the material.
  40525. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40526. */
  40527. emissiveFresnelParameters: FresnelParameters;
  40528. private _useReflectionFresnelFromSpecular;
  40529. /**
  40530. * If true automatically deducts the fresnels values from the material specularity.
  40531. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40532. */
  40533. useReflectionFresnelFromSpecular: boolean;
  40534. private _useGlossinessFromSpecularMapAlpha;
  40535. /**
  40536. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40537. */
  40538. useGlossinessFromSpecularMapAlpha: boolean;
  40539. private _maxSimultaneousLights;
  40540. /**
  40541. * Defines the maximum number of lights that can be used in the material
  40542. */
  40543. maxSimultaneousLights: number;
  40544. private _invertNormalMapX;
  40545. /**
  40546. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40547. */
  40548. invertNormalMapX: boolean;
  40549. private _invertNormalMapY;
  40550. /**
  40551. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40552. */
  40553. invertNormalMapY: boolean;
  40554. private _twoSidedLighting;
  40555. /**
  40556. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40557. */
  40558. twoSidedLighting: boolean;
  40559. /**
  40560. * Default configuration related to image processing available in the standard Material.
  40561. */
  40562. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40563. /**
  40564. * Gets the image processing configuration used either in this material.
  40565. */
  40566. /**
  40567. * Sets the Default image processing configuration used either in the this material.
  40568. *
  40569. * If sets to null, the scene one is in use.
  40570. */
  40571. imageProcessingConfiguration: ImageProcessingConfiguration;
  40572. /**
  40573. * Keep track of the image processing observer to allow dispose and replace.
  40574. */
  40575. private _imageProcessingObserver;
  40576. /**
  40577. * Attaches a new image processing configuration to the Standard Material.
  40578. * @param configuration
  40579. */
  40580. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40581. /**
  40582. * Gets wether the color curves effect is enabled.
  40583. */
  40584. /**
  40585. * Sets wether the color curves effect is enabled.
  40586. */
  40587. cameraColorCurvesEnabled: boolean;
  40588. /**
  40589. * Gets wether the color grading effect is enabled.
  40590. */
  40591. /**
  40592. * Gets wether the color grading effect is enabled.
  40593. */
  40594. cameraColorGradingEnabled: boolean;
  40595. /**
  40596. * Gets wether tonemapping is enabled or not.
  40597. */
  40598. /**
  40599. * Sets wether tonemapping is enabled or not
  40600. */
  40601. cameraToneMappingEnabled: boolean;
  40602. /**
  40603. * The camera exposure used on this material.
  40604. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40605. * This corresponds to a photographic exposure.
  40606. */
  40607. /**
  40608. * The camera exposure used on this material.
  40609. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40610. * This corresponds to a photographic exposure.
  40611. */
  40612. cameraExposure: number;
  40613. /**
  40614. * Gets The camera contrast used on this material.
  40615. */
  40616. /**
  40617. * Sets The camera contrast used on this material.
  40618. */
  40619. cameraContrast: number;
  40620. /**
  40621. * Gets the Color Grading 2D Lookup Texture.
  40622. */
  40623. /**
  40624. * Sets the Color Grading 2D Lookup Texture.
  40625. */
  40626. cameraColorGradingTexture: Nullable<BaseTexture>;
  40627. /**
  40628. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40629. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40630. * 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;
  40631. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40632. */
  40633. /**
  40634. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40635. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40636. * 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;
  40637. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40638. */
  40639. cameraColorCurves: Nullable<ColorCurves>;
  40640. /**
  40641. * Custom callback helping to override the default shader used in the material.
  40642. */
  40643. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40644. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40645. protected _worldViewProjectionMatrix: Matrix;
  40646. protected _globalAmbientColor: Color3;
  40647. protected _useLogarithmicDepth: boolean;
  40648. /**
  40649. * Instantiates a new standard material.
  40650. * This is the default material used in Babylon. It is the best trade off between quality
  40651. * and performances.
  40652. * @see http://doc.babylonjs.com/babylon101/materials
  40653. * @param name Define the name of the material in the scene
  40654. * @param scene Define the scene the material belong to
  40655. */
  40656. constructor(name: string, scene: Scene);
  40657. /**
  40658. * Gets a boolean indicating that current material needs to register RTT
  40659. */
  40660. readonly hasRenderTargetTextures: boolean;
  40661. /**
  40662. * Gets the current class name of the material e.g. "StandardMaterial"
  40663. * Mainly use in serialization.
  40664. * @returns the class name
  40665. */
  40666. getClassName(): string;
  40667. /**
  40668. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40669. * You can try switching to logarithmic depth.
  40670. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40671. */
  40672. useLogarithmicDepth: boolean;
  40673. /**
  40674. * Specifies if the material will require alpha blending
  40675. * @returns a boolean specifying if alpha blending is needed
  40676. */
  40677. needAlphaBlending(): boolean;
  40678. /**
  40679. * Specifies if this material should be rendered in alpha test mode
  40680. * @returns a boolean specifying if an alpha test is needed.
  40681. */
  40682. needAlphaTesting(): boolean;
  40683. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40684. /**
  40685. * Get the texture used for alpha test purpose.
  40686. * @returns the diffuse texture in case of the standard material.
  40687. */
  40688. getAlphaTestTexture(): Nullable<BaseTexture>;
  40689. /**
  40690. * Get if the submesh is ready to be used and all its information available.
  40691. * Child classes can use it to update shaders
  40692. * @param mesh defines the mesh to check
  40693. * @param subMesh defines which submesh to check
  40694. * @param useInstances specifies that instances should be used
  40695. * @returns a boolean indicating that the submesh is ready or not
  40696. */
  40697. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40698. /**
  40699. * Builds the material UBO layouts.
  40700. * Used internally during the effect preparation.
  40701. */
  40702. buildUniformLayout(): void;
  40703. /**
  40704. * Unbinds the material from the mesh
  40705. */
  40706. unbind(): void;
  40707. /**
  40708. * Binds the submesh to this material by preparing the effect and shader to draw
  40709. * @param world defines the world transformation matrix
  40710. * @param mesh defines the mesh containing the submesh
  40711. * @param subMesh defines the submesh to bind the material to
  40712. */
  40713. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40714. /**
  40715. * Get the list of animatables in the material.
  40716. * @returns the list of animatables object used in the material
  40717. */
  40718. getAnimatables(): IAnimatable[];
  40719. /**
  40720. * Gets the active textures from the material
  40721. * @returns an array of textures
  40722. */
  40723. getActiveTextures(): BaseTexture[];
  40724. /**
  40725. * Specifies if the material uses a texture
  40726. * @param texture defines the texture to check against the material
  40727. * @returns a boolean specifying if the material uses the texture
  40728. */
  40729. hasTexture(texture: BaseTexture): boolean;
  40730. /**
  40731. * Disposes the material
  40732. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40733. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40734. */
  40735. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40736. /**
  40737. * Makes a duplicate of the material, and gives it a new name
  40738. * @param name defines the new name for the duplicated material
  40739. * @returns the cloned material
  40740. */
  40741. clone(name: string): StandardMaterial;
  40742. /**
  40743. * Serializes this material in a JSON representation
  40744. * @returns the serialized material object
  40745. */
  40746. serialize(): any;
  40747. /**
  40748. * Creates a standard material from parsed material data
  40749. * @param source defines the JSON representation of the material
  40750. * @param scene defines the hosting scene
  40751. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40752. * @returns a new standard material
  40753. */
  40754. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40755. /**
  40756. * Are diffuse textures enabled in the application.
  40757. */
  40758. static DiffuseTextureEnabled: boolean;
  40759. /**
  40760. * Are ambient textures enabled in the application.
  40761. */
  40762. static AmbientTextureEnabled: boolean;
  40763. /**
  40764. * Are opacity textures enabled in the application.
  40765. */
  40766. static OpacityTextureEnabled: boolean;
  40767. /**
  40768. * Are reflection textures enabled in the application.
  40769. */
  40770. static ReflectionTextureEnabled: boolean;
  40771. /**
  40772. * Are emissive textures enabled in the application.
  40773. */
  40774. static EmissiveTextureEnabled: boolean;
  40775. /**
  40776. * Are specular textures enabled in the application.
  40777. */
  40778. static SpecularTextureEnabled: boolean;
  40779. /**
  40780. * Are bump textures enabled in the application.
  40781. */
  40782. static BumpTextureEnabled: boolean;
  40783. /**
  40784. * Are lightmap textures enabled in the application.
  40785. */
  40786. static LightmapTextureEnabled: boolean;
  40787. /**
  40788. * Are refraction textures enabled in the application.
  40789. */
  40790. static RefractionTextureEnabled: boolean;
  40791. /**
  40792. * Are color grading textures enabled in the application.
  40793. */
  40794. static ColorGradingTextureEnabled: boolean;
  40795. /**
  40796. * Are fresnels enabled in the application.
  40797. */
  40798. static FresnelEnabled: boolean;
  40799. }
  40800. }
  40801. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40802. import { Scene } from "babylonjs/scene";
  40803. import { Texture } from "babylonjs/Materials/Textures/texture";
  40804. /**
  40805. * A class extending Texture allowing drawing on a texture
  40806. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40807. */
  40808. export class DynamicTexture extends Texture {
  40809. private _generateMipMaps;
  40810. private _canvas;
  40811. private _context;
  40812. private _engine;
  40813. /**
  40814. * Creates a DynamicTexture
  40815. * @param name defines the name of the texture
  40816. * @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
  40817. * @param scene defines the scene where you want the texture
  40818. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40819. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40820. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40821. */
  40822. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40823. /**
  40824. * Get the current class name of the texture useful for serialization or dynamic coding.
  40825. * @returns "DynamicTexture"
  40826. */
  40827. getClassName(): string;
  40828. /**
  40829. * Gets the current state of canRescale
  40830. */
  40831. readonly canRescale: boolean;
  40832. private _recreate;
  40833. /**
  40834. * Scales the texture
  40835. * @param ratio the scale factor to apply to both width and height
  40836. */
  40837. scale(ratio: number): void;
  40838. /**
  40839. * Resizes the texture
  40840. * @param width the new width
  40841. * @param height the new height
  40842. */
  40843. scaleTo(width: number, height: number): void;
  40844. /**
  40845. * Gets the context of the canvas used by the texture
  40846. * @returns the canvas context of the dynamic texture
  40847. */
  40848. getContext(): CanvasRenderingContext2D;
  40849. /**
  40850. * Clears the texture
  40851. */
  40852. clear(): void;
  40853. /**
  40854. * Updates the texture
  40855. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40856. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40857. */
  40858. update(invertY?: boolean, premulAlpha?: boolean): void;
  40859. /**
  40860. * Draws text onto the texture
  40861. * @param text defines the text to be drawn
  40862. * @param x defines the placement of the text from the left
  40863. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40864. * @param font defines the font to be used with font-style, font-size, font-name
  40865. * @param color defines the color used for the text
  40866. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40867. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40868. * @param update defines whether texture is immediately update (default is true)
  40869. */
  40870. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40871. /**
  40872. * Clones the texture
  40873. * @returns the clone of the texture.
  40874. */
  40875. clone(): DynamicTexture;
  40876. /**
  40877. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40878. * @returns a serialized dynamic texture object
  40879. */
  40880. serialize(): any;
  40881. /** @hidden */
  40882. _rebuild(): void;
  40883. }
  40884. }
  40885. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40886. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40887. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40888. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40889. /** @hidden */
  40890. export var imageProcessingPixelShader: {
  40891. name: string;
  40892. shader: string;
  40893. };
  40894. }
  40895. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40896. import { Nullable } from "babylonjs/types";
  40897. import { Color4 } from "babylonjs/Maths/math";
  40898. import { Camera } from "babylonjs/Cameras/camera";
  40899. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40900. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40901. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40902. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40903. import { Engine } from "babylonjs/Engines/engine";
  40904. import "babylonjs/Shaders/imageProcessing.fragment";
  40905. import "babylonjs/Shaders/postprocess.vertex";
  40906. /**
  40907. * ImageProcessingPostProcess
  40908. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40909. */
  40910. export class ImageProcessingPostProcess extends PostProcess {
  40911. /**
  40912. * Default configuration related to image processing available in the PBR Material.
  40913. */
  40914. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40915. /**
  40916. * Gets the image processing configuration used either in this material.
  40917. */
  40918. /**
  40919. * Sets the Default image processing configuration used either in the this material.
  40920. *
  40921. * If sets to null, the scene one is in use.
  40922. */
  40923. imageProcessingConfiguration: ImageProcessingConfiguration;
  40924. /**
  40925. * Keep track of the image processing observer to allow dispose and replace.
  40926. */
  40927. private _imageProcessingObserver;
  40928. /**
  40929. * Attaches a new image processing configuration to the PBR Material.
  40930. * @param configuration
  40931. */
  40932. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40933. /**
  40934. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40935. */
  40936. /**
  40937. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40938. */
  40939. colorCurves: Nullable<ColorCurves>;
  40940. /**
  40941. * Gets wether the color curves effect is enabled.
  40942. */
  40943. /**
  40944. * Sets wether the color curves effect is enabled.
  40945. */
  40946. colorCurvesEnabled: boolean;
  40947. /**
  40948. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40949. */
  40950. /**
  40951. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40952. */
  40953. colorGradingTexture: Nullable<BaseTexture>;
  40954. /**
  40955. * Gets wether the color grading effect is enabled.
  40956. */
  40957. /**
  40958. * Gets wether the color grading effect is enabled.
  40959. */
  40960. colorGradingEnabled: boolean;
  40961. /**
  40962. * Gets exposure used in the effect.
  40963. */
  40964. /**
  40965. * Sets exposure used in the effect.
  40966. */
  40967. exposure: number;
  40968. /**
  40969. * Gets wether tonemapping is enabled or not.
  40970. */
  40971. /**
  40972. * Sets wether tonemapping is enabled or not
  40973. */
  40974. toneMappingEnabled: boolean;
  40975. /**
  40976. * Gets the type of tone mapping effect.
  40977. */
  40978. /**
  40979. * Sets the type of tone mapping effect.
  40980. */
  40981. toneMappingType: number;
  40982. /**
  40983. * Gets contrast used in the effect.
  40984. */
  40985. /**
  40986. * Sets contrast used in the effect.
  40987. */
  40988. contrast: number;
  40989. /**
  40990. * Gets Vignette stretch size.
  40991. */
  40992. /**
  40993. * Sets Vignette stretch size.
  40994. */
  40995. vignetteStretch: number;
  40996. /**
  40997. * Gets Vignette centre X Offset.
  40998. */
  40999. /**
  41000. * Sets Vignette centre X Offset.
  41001. */
  41002. vignetteCentreX: number;
  41003. /**
  41004. * Gets Vignette centre Y Offset.
  41005. */
  41006. /**
  41007. * Sets Vignette centre Y Offset.
  41008. */
  41009. vignetteCentreY: number;
  41010. /**
  41011. * Gets Vignette weight or intensity of the vignette effect.
  41012. */
  41013. /**
  41014. * Sets Vignette weight or intensity of the vignette effect.
  41015. */
  41016. vignetteWeight: number;
  41017. /**
  41018. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41019. * if vignetteEnabled is set to true.
  41020. */
  41021. /**
  41022. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41023. * if vignetteEnabled is set to true.
  41024. */
  41025. vignetteColor: Color4;
  41026. /**
  41027. * Gets Camera field of view used by the Vignette effect.
  41028. */
  41029. /**
  41030. * Sets Camera field of view used by the Vignette effect.
  41031. */
  41032. vignetteCameraFov: number;
  41033. /**
  41034. * Gets the vignette blend mode allowing different kind of effect.
  41035. */
  41036. /**
  41037. * Sets the vignette blend mode allowing different kind of effect.
  41038. */
  41039. vignetteBlendMode: number;
  41040. /**
  41041. * Gets wether the vignette effect is enabled.
  41042. */
  41043. /**
  41044. * Sets wether the vignette effect is enabled.
  41045. */
  41046. vignetteEnabled: boolean;
  41047. private _fromLinearSpace;
  41048. /**
  41049. * Gets wether the input of the processing is in Gamma or Linear Space.
  41050. */
  41051. /**
  41052. * Sets wether the input of the processing is in Gamma or Linear Space.
  41053. */
  41054. fromLinearSpace: boolean;
  41055. /**
  41056. * Defines cache preventing GC.
  41057. */
  41058. private _defines;
  41059. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41060. /**
  41061. * "ImageProcessingPostProcess"
  41062. * @returns "ImageProcessingPostProcess"
  41063. */
  41064. getClassName(): string;
  41065. protected _updateParameters(): void;
  41066. dispose(camera?: Camera): void;
  41067. }
  41068. }
  41069. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41070. import { Scene } from "babylonjs/scene";
  41071. import { Color3 } from "babylonjs/Maths/math";
  41072. import { Mesh } from "babylonjs/Meshes/mesh";
  41073. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41074. import { Nullable } from "babylonjs/types";
  41075. /**
  41076. * Class containing static functions to help procedurally build meshes
  41077. */
  41078. export class GroundBuilder {
  41079. /**
  41080. * Creates a ground mesh
  41081. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41082. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41084. * @param name defines the name of the mesh
  41085. * @param options defines the options used to create the mesh
  41086. * @param scene defines the hosting scene
  41087. * @returns the ground mesh
  41088. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41089. */
  41090. static CreateGround(name: string, options: {
  41091. width?: number;
  41092. height?: number;
  41093. subdivisions?: number;
  41094. subdivisionsX?: number;
  41095. subdivisionsY?: number;
  41096. updatable?: boolean;
  41097. }, scene: any): Mesh;
  41098. /**
  41099. * Creates a tiled ground mesh
  41100. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41101. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41102. * * 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
  41103. * * 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
  41104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41105. * @param name defines the name of the mesh
  41106. * @param options defines the options used to create the mesh
  41107. * @param scene defines the hosting scene
  41108. * @returns the tiled ground mesh
  41109. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41110. */
  41111. static CreateTiledGround(name: string, options: {
  41112. xmin: number;
  41113. zmin: number;
  41114. xmax: number;
  41115. zmax: number;
  41116. subdivisions?: {
  41117. w: number;
  41118. h: number;
  41119. };
  41120. precision?: {
  41121. w: number;
  41122. h: number;
  41123. };
  41124. updatable?: boolean;
  41125. }, scene?: Nullable<Scene>): Mesh;
  41126. /**
  41127. * Creates a ground mesh from a height map
  41128. * * The parameter `url` sets the URL of the height map image resource.
  41129. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41130. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41131. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41132. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41133. * * 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.
  41134. * * 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).
  41135. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41137. * @param name defines the name of the mesh
  41138. * @param url defines the url to the height map
  41139. * @param options defines the options used to create the mesh
  41140. * @param scene defines the hosting scene
  41141. * @returns the ground mesh
  41142. * @see https://doc.babylonjs.com/babylon101/height_map
  41143. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41144. */
  41145. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41146. width?: number;
  41147. height?: number;
  41148. subdivisions?: number;
  41149. minHeight?: number;
  41150. maxHeight?: number;
  41151. colorFilter?: Color3;
  41152. alphaFilter?: number;
  41153. updatable?: boolean;
  41154. onReady?: (mesh: GroundMesh) => void;
  41155. }, scene?: Nullable<Scene>): GroundMesh;
  41156. }
  41157. }
  41158. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41159. import { Vector4 } from "babylonjs/Maths/math";
  41160. import { Mesh } from "babylonjs/Meshes/mesh";
  41161. /**
  41162. * Class containing static functions to help procedurally build meshes
  41163. */
  41164. export class TorusBuilder {
  41165. /**
  41166. * Creates a torus mesh
  41167. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41168. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41169. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41173. * @param name defines the name of the mesh
  41174. * @param options defines the options used to create the mesh
  41175. * @param scene defines the hosting scene
  41176. * @returns the torus mesh
  41177. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41178. */
  41179. static CreateTorus(name: string, options: {
  41180. diameter?: number;
  41181. thickness?: number;
  41182. tessellation?: number;
  41183. updatable?: boolean;
  41184. sideOrientation?: number;
  41185. frontUVs?: Vector4;
  41186. backUVs?: Vector4;
  41187. }, scene: any): Mesh;
  41188. }
  41189. }
  41190. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41191. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41192. import { Mesh } from "babylonjs/Meshes/mesh";
  41193. /**
  41194. * Class containing static functions to help procedurally build meshes
  41195. */
  41196. export class CylinderBuilder {
  41197. /**
  41198. * Creates a cylinder or a cone mesh
  41199. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41200. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41201. * * 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.
  41202. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41203. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41204. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41205. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41206. * * 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).
  41207. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41208. * * 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).
  41209. * * 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
  41210. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41211. * * 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
  41212. * * 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.
  41213. * * If `enclose` is false, a ring surface is one element.
  41214. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41215. * * 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
  41216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41219. * @param name defines the name of the mesh
  41220. * @param options defines the options used to create the mesh
  41221. * @param scene defines the hosting scene
  41222. * @returns the cylinder mesh
  41223. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41224. */
  41225. static CreateCylinder(name: string, options: {
  41226. height?: number;
  41227. diameterTop?: number;
  41228. diameterBottom?: number;
  41229. diameter?: number;
  41230. tessellation?: number;
  41231. subdivisions?: number;
  41232. arc?: number;
  41233. faceColors?: Color4[];
  41234. faceUV?: Vector4[];
  41235. updatable?: boolean;
  41236. hasRings?: boolean;
  41237. enclose?: boolean;
  41238. cap?: number;
  41239. sideOrientation?: number;
  41240. frontUVs?: Vector4;
  41241. backUVs?: Vector4;
  41242. }, scene: any): Mesh;
  41243. }
  41244. }
  41245. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41246. import { Observable } from "babylonjs/Misc/observable";
  41247. import { Nullable } from "babylonjs/types";
  41248. import { Camera } from "babylonjs/Cameras/camera";
  41249. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41250. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41251. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41252. import { Scene } from "babylonjs/scene";
  41253. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41254. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41256. import { Mesh } from "babylonjs/Meshes/mesh";
  41257. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41258. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41259. import "babylonjs/Meshes/Builders/groundBuilder";
  41260. import "babylonjs/Meshes/Builders/torusBuilder";
  41261. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41262. import "babylonjs/Gamepads/gamepadSceneComponent";
  41263. import "babylonjs/Animations/animatable";
  41264. /**
  41265. * Options to modify the vr teleportation behavior.
  41266. */
  41267. export interface VRTeleportationOptions {
  41268. /**
  41269. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41270. */
  41271. floorMeshName?: string;
  41272. /**
  41273. * A list of meshes to be used as the teleportation floor. (default: empty)
  41274. */
  41275. floorMeshes?: Mesh[];
  41276. }
  41277. /**
  41278. * Options to modify the vr experience helper's behavior.
  41279. */
  41280. export interface VRExperienceHelperOptions extends WebVROptions {
  41281. /**
  41282. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41283. */
  41284. createDeviceOrientationCamera?: boolean;
  41285. /**
  41286. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41287. */
  41288. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41289. /**
  41290. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41291. */
  41292. laserToggle?: boolean;
  41293. /**
  41294. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41295. */
  41296. floorMeshes?: Mesh[];
  41297. /**
  41298. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41299. */
  41300. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41301. }
  41302. /**
  41303. * Event containing information after VR has been entered
  41304. */
  41305. export class OnAfterEnteringVRObservableEvent {
  41306. /**
  41307. * If entering vr was successful
  41308. */
  41309. success: boolean;
  41310. }
  41311. /**
  41312. * Helps to quickly add VR support to an existing scene.
  41313. * See http://doc.babylonjs.com/how_to/webvr_helper
  41314. */
  41315. export class VRExperienceHelper {
  41316. /** Options to modify the vr experience helper's behavior. */
  41317. webVROptions: VRExperienceHelperOptions;
  41318. private _scene;
  41319. private _position;
  41320. private _btnVR;
  41321. private _btnVRDisplayed;
  41322. private _webVRsupported;
  41323. private _webVRready;
  41324. private _webVRrequesting;
  41325. private _webVRpresenting;
  41326. private _hasEnteredVR;
  41327. private _fullscreenVRpresenting;
  41328. private _canvas;
  41329. private _webVRCamera;
  41330. private _vrDeviceOrientationCamera;
  41331. private _deviceOrientationCamera;
  41332. private _existingCamera;
  41333. private _onKeyDown;
  41334. private _onVrDisplayPresentChange;
  41335. private _onVRDisplayChanged;
  41336. private _onVRRequestPresentStart;
  41337. private _onVRRequestPresentComplete;
  41338. /**
  41339. * Observable raised right before entering VR.
  41340. */
  41341. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41342. /**
  41343. * Observable raised when entering VR has completed.
  41344. */
  41345. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41346. /**
  41347. * Observable raised when exiting VR.
  41348. */
  41349. onExitingVRObservable: Observable<VRExperienceHelper>;
  41350. /**
  41351. * Observable raised when controller mesh is loaded.
  41352. */
  41353. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41354. /** Return this.onEnteringVRObservable
  41355. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41356. */
  41357. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41358. /** Return this.onExitingVRObservable
  41359. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41360. */
  41361. readonly onExitingVR: Observable<VRExperienceHelper>;
  41362. /** Return this.onControllerMeshLoadedObservable
  41363. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41364. */
  41365. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41366. private _rayLength;
  41367. private _useCustomVRButton;
  41368. private _teleportationRequested;
  41369. private _teleportActive;
  41370. private _floorMeshName;
  41371. private _floorMeshesCollection;
  41372. private _rotationAllowed;
  41373. private _teleportBackwardsVector;
  41374. private _teleportationTarget;
  41375. private _isDefaultTeleportationTarget;
  41376. private _postProcessMove;
  41377. private _teleportationFillColor;
  41378. private _teleportationBorderColor;
  41379. private _rotationAngle;
  41380. private _haloCenter;
  41381. private _cameraGazer;
  41382. private _padSensibilityUp;
  41383. private _padSensibilityDown;
  41384. private _leftController;
  41385. private _rightController;
  41386. /**
  41387. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41388. */
  41389. onNewMeshSelected: Observable<AbstractMesh>;
  41390. /**
  41391. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41392. */
  41393. onNewMeshPicked: Observable<PickingInfo>;
  41394. private _circleEase;
  41395. /**
  41396. * Observable raised before camera teleportation
  41397. */
  41398. onBeforeCameraTeleport: Observable<Vector3>;
  41399. /**
  41400. * Observable raised after camera teleportation
  41401. */
  41402. onAfterCameraTeleport: Observable<Vector3>;
  41403. /**
  41404. * Observable raised when current selected mesh gets unselected
  41405. */
  41406. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41407. private _raySelectionPredicate;
  41408. /**
  41409. * To be optionaly changed by user to define custom ray selection
  41410. */
  41411. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41412. /**
  41413. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41414. */
  41415. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41416. /**
  41417. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41418. */
  41419. teleportationEnabled: boolean;
  41420. private _defaultHeight;
  41421. private _teleportationInitialized;
  41422. private _interactionsEnabled;
  41423. private _interactionsRequested;
  41424. private _displayGaze;
  41425. private _displayLaserPointer;
  41426. /**
  41427. * The mesh used to display where the user is going to teleport.
  41428. */
  41429. /**
  41430. * Sets the mesh to be used to display where the user is going to teleport.
  41431. */
  41432. teleportationTarget: Mesh;
  41433. /**
  41434. * 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
  41435. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41436. * See http://doc.babylonjs.com/resources/baking_transformations
  41437. */
  41438. gazeTrackerMesh: Mesh;
  41439. /**
  41440. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41441. */
  41442. updateGazeTrackerScale: boolean;
  41443. /**
  41444. * If the gaze trackers color should be updated when selecting meshes
  41445. */
  41446. updateGazeTrackerColor: boolean;
  41447. /**
  41448. * The gaze tracking mesh corresponding to the left controller
  41449. */
  41450. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41451. /**
  41452. * The gaze tracking mesh corresponding to the right controller
  41453. */
  41454. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41455. /**
  41456. * If the ray of the gaze should be displayed.
  41457. */
  41458. /**
  41459. * Sets if the ray of the gaze should be displayed.
  41460. */
  41461. displayGaze: boolean;
  41462. /**
  41463. * If the ray of the LaserPointer should be displayed.
  41464. */
  41465. /**
  41466. * Sets if the ray of the LaserPointer should be displayed.
  41467. */
  41468. displayLaserPointer: boolean;
  41469. /**
  41470. * The deviceOrientationCamera used as the camera when not in VR.
  41471. */
  41472. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41473. /**
  41474. * Based on the current WebVR support, returns the current VR camera used.
  41475. */
  41476. readonly currentVRCamera: Nullable<Camera>;
  41477. /**
  41478. * The webVRCamera which is used when in VR.
  41479. */
  41480. readonly webVRCamera: WebVRFreeCamera;
  41481. /**
  41482. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41483. */
  41484. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41485. private readonly _teleportationRequestInitiated;
  41486. /**
  41487. * Defines wether or not Pointer lock should be requested when switching to
  41488. * full screen.
  41489. */
  41490. requestPointerLockOnFullScreen: boolean;
  41491. /**
  41492. * Instantiates a VRExperienceHelper.
  41493. * Helps to quickly add VR support to an existing scene.
  41494. * @param scene The scene the VRExperienceHelper belongs to.
  41495. * @param webVROptions Options to modify the vr experience helper's behavior.
  41496. */
  41497. constructor(scene: Scene,
  41498. /** Options to modify the vr experience helper's behavior. */
  41499. webVROptions?: VRExperienceHelperOptions);
  41500. private _onDefaultMeshLoaded;
  41501. private _onResize;
  41502. private _onFullscreenChange;
  41503. /**
  41504. * Gets a value indicating if we are currently in VR mode.
  41505. */
  41506. readonly isInVRMode: boolean;
  41507. private onVrDisplayPresentChange;
  41508. private onVRDisplayChanged;
  41509. private moveButtonToBottomRight;
  41510. private displayVRButton;
  41511. private updateButtonVisibility;
  41512. private _cachedAngularSensibility;
  41513. /**
  41514. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41515. * Otherwise, will use the fullscreen API.
  41516. */
  41517. enterVR(): void;
  41518. /**
  41519. * Attempt to exit VR, or fullscreen.
  41520. */
  41521. exitVR(): void;
  41522. /**
  41523. * The position of the vr experience helper.
  41524. */
  41525. /**
  41526. * Sets the position of the vr experience helper.
  41527. */
  41528. position: Vector3;
  41529. /**
  41530. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41531. */
  41532. enableInteractions(): void;
  41533. private readonly _noControllerIsActive;
  41534. private beforeRender;
  41535. private _isTeleportationFloor;
  41536. /**
  41537. * Adds a floor mesh to be used for teleportation.
  41538. * @param floorMesh the mesh to be used for teleportation.
  41539. */
  41540. addFloorMesh(floorMesh: Mesh): void;
  41541. /**
  41542. * Removes a floor mesh from being used for teleportation.
  41543. * @param floorMesh the mesh to be removed.
  41544. */
  41545. removeFloorMesh(floorMesh: Mesh): void;
  41546. /**
  41547. * Enables interactions and teleportation using the VR controllers and gaze.
  41548. * @param vrTeleportationOptions options to modify teleportation behavior.
  41549. */
  41550. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41551. private _onNewGamepadConnected;
  41552. private _tryEnableInteractionOnController;
  41553. private _onNewGamepadDisconnected;
  41554. private _enableInteractionOnController;
  41555. private _checkTeleportWithRay;
  41556. private _checkRotate;
  41557. private _checkTeleportBackwards;
  41558. private _enableTeleportationOnController;
  41559. private _createTeleportationCircles;
  41560. private _displayTeleportationTarget;
  41561. private _hideTeleportationTarget;
  41562. private _rotateCamera;
  41563. private _moveTeleportationSelectorTo;
  41564. private _workingVector;
  41565. private _workingQuaternion;
  41566. private _workingMatrix;
  41567. /**
  41568. * Teleports the users feet to the desired location
  41569. * @param location The location where the user's feet should be placed
  41570. */
  41571. teleportCamera(location: Vector3): void;
  41572. private _convertNormalToDirectionOfRay;
  41573. private _castRayAndSelectObject;
  41574. private _notifySelectedMeshUnselected;
  41575. /**
  41576. * Sets the color of the laser ray from the vr controllers.
  41577. * @param color new color for the ray.
  41578. */
  41579. changeLaserColor(color: Color3): void;
  41580. /**
  41581. * Sets the color of the ray from the vr headsets gaze.
  41582. * @param color new color for the ray.
  41583. */
  41584. changeGazeColor(color: Color3): void;
  41585. /**
  41586. * Exits VR and disposes of the vr experience helper
  41587. */
  41588. dispose(): void;
  41589. /**
  41590. * Gets the name of the VRExperienceHelper class
  41591. * @returns "VRExperienceHelper"
  41592. */
  41593. getClassName(): string;
  41594. }
  41595. }
  41596. declare module "babylonjs/Cameras/VR/index" {
  41597. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41598. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41599. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41600. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41601. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41602. export * from "babylonjs/Cameras/VR/webVRCamera";
  41603. }
  41604. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41605. import { Observable } from "babylonjs/Misc/observable";
  41606. import { Nullable } from "babylonjs/types";
  41607. import { IDisposable, Scene } from "babylonjs/scene";
  41608. import { Vector3 } from "babylonjs/Maths/math";
  41609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41610. import { Ray } from "babylonjs/Culling/ray";
  41611. /**
  41612. * Manages an XRSession
  41613. * @see https://doc.babylonjs.com/how_to/webxr
  41614. */
  41615. export class WebXRSessionManager implements IDisposable {
  41616. private scene;
  41617. /**
  41618. * Fires every time a new xrFrame arrives which can be used to update the camera
  41619. */
  41620. onXRFrameObservable: Observable<any>;
  41621. /**
  41622. * Fires when the xr session is ended either by the device or manually done
  41623. */
  41624. onXRSessionEnded: Observable<any>;
  41625. /** @hidden */
  41626. _xrSession: XRSession;
  41627. /** @hidden */
  41628. _frameOfReference: XRFrameOfReference;
  41629. /** @hidden */
  41630. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41631. /** @hidden */
  41632. _currentXRFrame: Nullable<XRFrame>;
  41633. private _xrNavigator;
  41634. private _xrDevice;
  41635. private _tmpMatrix;
  41636. /**
  41637. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41638. * @param scene The scene which the session should be created for
  41639. */
  41640. constructor(scene: Scene);
  41641. /**
  41642. * Initializes the manager
  41643. * After initialization enterXR can be called to start an XR session
  41644. * @returns Promise which resolves after it is initialized
  41645. */
  41646. initializeAsync(): Promise<void>;
  41647. /**
  41648. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41649. * @param sessionCreationOptions xr options to create the session with
  41650. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41651. * @returns Promise which resolves after it enters XR
  41652. */
  41653. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41654. /**
  41655. * Stops the xrSession and restores the renderloop
  41656. * @returns Promise which resolves after it exits XR
  41657. */
  41658. exitXRAsync(): Promise<void>;
  41659. /**
  41660. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41661. * @param ray ray to cast into the environment
  41662. * @returns Promise which resolves with a collision point in the environment if it exists
  41663. */
  41664. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41665. /**
  41666. * Checks if a session would be supported for the creation options specified
  41667. * @param options creation options to check if they are supported
  41668. * @returns true if supported
  41669. */
  41670. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41671. /**
  41672. * @hidden
  41673. * Converts the render layer of xrSession to a render target
  41674. * @param session session to create render target for
  41675. * @param scene scene the new render target should be created for
  41676. */
  41677. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41678. /**
  41679. * Disposes of the session manager
  41680. */
  41681. dispose(): void;
  41682. }
  41683. }
  41684. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41685. import { Scene } from "babylonjs/scene";
  41686. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41687. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41688. /**
  41689. * WebXR Camera which holds the views for the xrSession
  41690. * @see https://doc.babylonjs.com/how_to/webxr
  41691. */
  41692. export class WebXRCamera extends FreeCamera {
  41693. private static _TmpMatrix;
  41694. /**
  41695. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41696. * @param name the name of the camera
  41697. * @param scene the scene to add the camera to
  41698. */
  41699. constructor(name: string, scene: Scene);
  41700. private _updateNumberOfRigCameras;
  41701. /** @hidden */
  41702. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41703. /**
  41704. * Updates the cameras position from the current pose information of the XR session
  41705. * @param xrSessionManager the session containing pose information
  41706. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41707. */
  41708. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41709. }
  41710. }
  41711. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41712. import { Nullable } from "babylonjs/types";
  41713. import { Observable } from "babylonjs/Misc/observable";
  41714. import { IDisposable, Scene } from "babylonjs/scene";
  41715. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41717. import { Ray } from "babylonjs/Culling/ray";
  41718. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41719. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41720. /**
  41721. * States of the webXR experience
  41722. */
  41723. export enum WebXRState {
  41724. /**
  41725. * Transitioning to being in XR mode
  41726. */
  41727. ENTERING_XR = 0,
  41728. /**
  41729. * Transitioning to non XR mode
  41730. */
  41731. EXITING_XR = 1,
  41732. /**
  41733. * In XR mode and presenting
  41734. */
  41735. IN_XR = 2,
  41736. /**
  41737. * Not entered XR mode
  41738. */
  41739. NOT_IN_XR = 3
  41740. }
  41741. /**
  41742. * Helper class used to enable XR
  41743. * @see https://doc.babylonjs.com/how_to/webxr
  41744. */
  41745. export class WebXRExperienceHelper implements IDisposable {
  41746. private scene;
  41747. /**
  41748. * 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
  41749. */
  41750. container: AbstractMesh;
  41751. /**
  41752. * Camera used to render xr content
  41753. */
  41754. camera: WebXRCamera;
  41755. /**
  41756. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41757. */
  41758. state: WebXRState;
  41759. private _setState;
  41760. private static _TmpVector;
  41761. /**
  41762. * Fires when the state of the experience helper has changed
  41763. */
  41764. onStateChangedObservable: Observable<WebXRState>;
  41765. /** @hidden */
  41766. _sessionManager: WebXRSessionManager;
  41767. private _nonVRCamera;
  41768. private _originalSceneAutoClear;
  41769. private _supported;
  41770. /**
  41771. * Creates the experience helper
  41772. * @param scene the scene to attach the experience helper to
  41773. * @returns a promise for the experience helper
  41774. */
  41775. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41776. /**
  41777. * Creates a WebXRExperienceHelper
  41778. * @param scene The scene the helper should be created in
  41779. */
  41780. private constructor();
  41781. /**
  41782. * Exits XR mode and returns the scene to its original state
  41783. * @returns promise that resolves after xr mode has exited
  41784. */
  41785. exitXRAsync(): Promise<void>;
  41786. /**
  41787. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41788. * @param sessionCreationOptions options for the XR session
  41789. * @param frameOfReference frame of reference of the XR session
  41790. * @returns promise that resolves after xr mode has entered
  41791. */
  41792. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41793. /**
  41794. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41795. * @param ray ray to cast into the environment
  41796. * @returns Promise which resolves with a collision point in the environment if it exists
  41797. */
  41798. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41799. /**
  41800. * Updates the global position of the camera by moving the camera's container
  41801. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41802. * @param position The desired global position of the camera
  41803. */
  41804. setPositionOfCameraUsingContainer(position: Vector3): void;
  41805. /**
  41806. * Rotates the xr camera by rotating the camera's container around the camera's position
  41807. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41808. * @param rotation the desired quaternion rotation to apply to the camera
  41809. */
  41810. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41811. /**
  41812. * Checks if the creation options are supported by the xr session
  41813. * @param options creation options
  41814. * @returns true if supported
  41815. */
  41816. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41817. /**
  41818. * Disposes of the experience helper
  41819. */
  41820. dispose(): void;
  41821. }
  41822. }
  41823. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41824. import { Nullable } from "babylonjs/types";
  41825. import { Observable } from "babylonjs/Misc/observable";
  41826. import { IDisposable, Scene } from "babylonjs/scene";
  41827. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41828. /**
  41829. * Button which can be used to enter a different mode of XR
  41830. */
  41831. export class WebXREnterExitUIButton {
  41832. /** button element */
  41833. element: HTMLElement;
  41834. /** XR initialization options for the button */
  41835. initializationOptions: XRSessionCreationOptions;
  41836. /**
  41837. * Creates a WebXREnterExitUIButton
  41838. * @param element button element
  41839. * @param initializationOptions XR initialization options for the button
  41840. */
  41841. constructor(
  41842. /** button element */
  41843. element: HTMLElement,
  41844. /** XR initialization options for the button */
  41845. initializationOptions: XRSessionCreationOptions);
  41846. /**
  41847. * Overwritable function which can be used to update the button's visuals when the state changes
  41848. * @param activeButton the current active button in the UI
  41849. */
  41850. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41851. }
  41852. /**
  41853. * Options to create the webXR UI
  41854. */
  41855. export class WebXREnterExitUIOptions {
  41856. /**
  41857. * Context to enter xr with
  41858. */
  41859. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41860. /**
  41861. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41862. */
  41863. customButtons?: Array<WebXREnterExitUIButton>;
  41864. }
  41865. /**
  41866. * UI to allow the user to enter/exit XR mode
  41867. */
  41868. export class WebXREnterExitUI implements IDisposable {
  41869. private scene;
  41870. private _overlay;
  41871. private _buttons;
  41872. private _activeButton;
  41873. /**
  41874. * Fired every time the active button is changed.
  41875. *
  41876. * When xr is entered via a button that launches xr that button will be the callback parameter
  41877. *
  41878. * When exiting xr the callback parameter will be null)
  41879. */
  41880. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41881. /**
  41882. * Creates UI to allow the user to enter/exit XR mode
  41883. * @param scene the scene to add the ui to
  41884. * @param helper the xr experience helper to enter/exit xr with
  41885. * @param options options to configure the UI
  41886. * @returns the created ui
  41887. */
  41888. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41889. private constructor();
  41890. private _updateButtons;
  41891. /**
  41892. * Disposes of the object
  41893. */
  41894. dispose(): void;
  41895. }
  41896. }
  41897. declare module "babylonjs/Cameras/XR/webXRInput" {
  41898. import { IDisposable, Scene } from "babylonjs/scene";
  41899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41900. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41901. /**
  41902. * Represents an XR input
  41903. */
  41904. export class WebXRController {
  41905. /**
  41906. * 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
  41907. */
  41908. grip?: AbstractMesh;
  41909. /**
  41910. * Pointer which can be used to select objects or attach a visible laser to
  41911. */
  41912. pointer: AbstractMesh;
  41913. /**
  41914. * Creates the controller
  41915. * @see https://doc.babylonjs.com/how_to/webxr
  41916. * @param scene the scene which the controller should be associated to
  41917. */
  41918. constructor(scene: Scene);
  41919. /**
  41920. * Disposes of the object
  41921. */
  41922. dispose(): void;
  41923. }
  41924. /**
  41925. * XR input used to track XR inputs such as controllers/rays
  41926. */
  41927. export class WebXRInput implements IDisposable {
  41928. private helper;
  41929. /**
  41930. * XR controllers being tracked
  41931. */
  41932. controllers: Array<WebXRController>;
  41933. private _tmpMatrix;
  41934. private _frameObserver;
  41935. /**
  41936. * Initializes the WebXRInput
  41937. * @param helper experience helper which the input should be created for
  41938. */
  41939. constructor(helper: WebXRExperienceHelper);
  41940. /**
  41941. * Disposes of the object
  41942. */
  41943. dispose(): void;
  41944. }
  41945. }
  41946. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41947. import { Nullable } from "babylonjs/types";
  41948. import { IDisposable } from "babylonjs/scene";
  41949. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41950. /**
  41951. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41952. */
  41953. export class WebXRManagedOutputCanvas implements IDisposable {
  41954. private _canvas;
  41955. /**
  41956. * xrpresent context of the canvas which can be used to display/mirror xr content
  41957. */
  41958. canvasContext: Nullable<WebGLRenderingContext>;
  41959. /**
  41960. * Initializes the canvas to be added/removed upon entering/exiting xr
  41961. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41962. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41963. */
  41964. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41965. /**
  41966. * Disposes of the object
  41967. */
  41968. dispose(): void;
  41969. private _setManagedOutputCanvas;
  41970. private _addCanvas;
  41971. private _removeCanvas;
  41972. }
  41973. }
  41974. declare module "babylonjs/Cameras/XR/index" {
  41975. export * from "babylonjs/Cameras/XR/webXRCamera";
  41976. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41977. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41978. export * from "babylonjs/Cameras/XR/webXRInput";
  41979. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41980. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41981. }
  41982. declare module "babylonjs/Cameras/RigModes/index" {
  41983. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41984. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41985. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41986. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41987. }
  41988. declare module "babylonjs/Cameras/index" {
  41989. export * from "babylonjs/Cameras/Inputs/index";
  41990. export * from "babylonjs/Cameras/cameraInputsManager";
  41991. export * from "babylonjs/Cameras/camera";
  41992. export * from "babylonjs/Cameras/targetCamera";
  41993. export * from "babylonjs/Cameras/freeCamera";
  41994. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41995. export * from "babylonjs/Cameras/touchCamera";
  41996. export * from "babylonjs/Cameras/arcRotateCamera";
  41997. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41998. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41999. export * from "babylonjs/Cameras/flyCamera";
  42000. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42001. export * from "babylonjs/Cameras/followCamera";
  42002. export * from "babylonjs/Cameras/gamepadCamera";
  42003. export * from "babylonjs/Cameras/Stereoscopic/index";
  42004. export * from "babylonjs/Cameras/universalCamera";
  42005. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42006. export * from "babylonjs/Cameras/VR/index";
  42007. export * from "babylonjs/Cameras/XR/index";
  42008. export * from "babylonjs/Cameras/RigModes/index";
  42009. }
  42010. declare module "babylonjs/Collisions/index" {
  42011. export * from "babylonjs/Collisions/collider";
  42012. export * from "babylonjs/Collisions/collisionCoordinator";
  42013. export * from "babylonjs/Collisions/pickingInfo";
  42014. export * from "babylonjs/Collisions/intersectionInfo";
  42015. export * from "babylonjs/Collisions/meshCollisionData";
  42016. }
  42017. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42018. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42019. import { Vector3, Plane } from "babylonjs/Maths/math";
  42020. import { Ray } from "babylonjs/Culling/ray";
  42021. /**
  42022. * Contains an array of blocks representing the octree
  42023. */
  42024. export interface IOctreeContainer<T> {
  42025. /**
  42026. * Blocks within the octree
  42027. */
  42028. blocks: Array<OctreeBlock<T>>;
  42029. }
  42030. /**
  42031. * Class used to store a cell in an octree
  42032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42033. */
  42034. export class OctreeBlock<T> {
  42035. /**
  42036. * Gets the content of the current block
  42037. */
  42038. entries: T[];
  42039. /**
  42040. * Gets the list of block children
  42041. */
  42042. blocks: Array<OctreeBlock<T>>;
  42043. private _depth;
  42044. private _maxDepth;
  42045. private _capacity;
  42046. private _minPoint;
  42047. private _maxPoint;
  42048. private _boundingVectors;
  42049. private _creationFunc;
  42050. /**
  42051. * Creates a new block
  42052. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42053. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42054. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42055. * @param depth defines the current depth of this block in the octree
  42056. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42057. * @param creationFunc defines a callback to call when an element is added to the block
  42058. */
  42059. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42060. /**
  42061. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42062. */
  42063. readonly capacity: number;
  42064. /**
  42065. * Gets the minimum vector (in world space) of the block's bounding box
  42066. */
  42067. readonly minPoint: Vector3;
  42068. /**
  42069. * Gets the maximum vector (in world space) of the block's bounding box
  42070. */
  42071. readonly maxPoint: Vector3;
  42072. /**
  42073. * Add a new element to this block
  42074. * @param entry defines the element to add
  42075. */
  42076. addEntry(entry: T): void;
  42077. /**
  42078. * Remove an element from this block
  42079. * @param entry defines the element to remove
  42080. */
  42081. removeEntry(entry: T): void;
  42082. /**
  42083. * Add an array of elements to this block
  42084. * @param entries defines the array of elements to add
  42085. */
  42086. addEntries(entries: T[]): void;
  42087. /**
  42088. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42089. * @param frustumPlanes defines the frustum planes to test
  42090. * @param selection defines the array to store current content if selection is positive
  42091. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42092. */
  42093. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42094. /**
  42095. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42096. * @param sphereCenter defines the bounding sphere center
  42097. * @param sphereRadius defines the bounding sphere radius
  42098. * @param selection defines the array to store current content if selection is positive
  42099. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42100. */
  42101. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42102. /**
  42103. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42104. * @param ray defines the ray to test with
  42105. * @param selection defines the array to store current content if selection is positive
  42106. */
  42107. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42108. /**
  42109. * Subdivide the content into child blocks (this block will then be empty)
  42110. */
  42111. createInnerBlocks(): void;
  42112. /**
  42113. * @hidden
  42114. */
  42115. 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;
  42116. }
  42117. }
  42118. declare module "babylonjs/Culling/Octrees/octree" {
  42119. import { SmartArray } from "babylonjs/Misc/smartArray";
  42120. import { Vector3, Plane } from "babylonjs/Maths/math";
  42121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42123. import { Ray } from "babylonjs/Culling/ray";
  42124. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42125. /**
  42126. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42127. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42128. */
  42129. export class Octree<T> {
  42130. /** 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.) */
  42131. maxDepth: number;
  42132. /**
  42133. * Blocks within the octree containing objects
  42134. */
  42135. blocks: Array<OctreeBlock<T>>;
  42136. /**
  42137. * Content stored in the octree
  42138. */
  42139. dynamicContent: T[];
  42140. private _maxBlockCapacity;
  42141. private _selectionContent;
  42142. private _creationFunc;
  42143. /**
  42144. * Creates a octree
  42145. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42146. * @param creationFunc function to be used to instatiate the octree
  42147. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42148. * @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.)
  42149. */
  42150. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42151. /** 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.) */
  42152. maxDepth?: number);
  42153. /**
  42154. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42155. * @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);
  42156. * @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);
  42157. * @param entries meshes to be added to the octree blocks
  42158. */
  42159. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42160. /**
  42161. * Adds a mesh to the octree
  42162. * @param entry Mesh to add to the octree
  42163. */
  42164. addMesh(entry: T): void;
  42165. /**
  42166. * Remove an element from the octree
  42167. * @param entry defines the element to remove
  42168. */
  42169. removeMesh(entry: T): void;
  42170. /**
  42171. * Selects an array of meshes within the frustum
  42172. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42173. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42174. * @returns array of meshes within the frustum
  42175. */
  42176. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42177. /**
  42178. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42179. * @param sphereCenter defines the bounding sphere center
  42180. * @param sphereRadius defines the bounding sphere radius
  42181. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42182. * @returns an array of objects that intersect the sphere
  42183. */
  42184. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42185. /**
  42186. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42187. * @param ray defines the ray to test with
  42188. * @returns array of intersected objects
  42189. */
  42190. intersectsRay(ray: Ray): SmartArray<T>;
  42191. /**
  42192. * Adds a mesh into the octree block if it intersects the block
  42193. */
  42194. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42195. /**
  42196. * Adds a submesh into the octree block if it intersects the block
  42197. */
  42198. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42199. }
  42200. }
  42201. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42202. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42203. import { Scene } from "babylonjs/scene";
  42204. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42206. import { Ray } from "babylonjs/Culling/ray";
  42207. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42208. import { Collider } from "babylonjs/Collisions/collider";
  42209. module "babylonjs/scene" {
  42210. interface Scene {
  42211. /**
  42212. * @hidden
  42213. * Backing Filed
  42214. */
  42215. _selectionOctree: Octree<AbstractMesh>;
  42216. /**
  42217. * Gets the octree used to boost mesh selection (picking)
  42218. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42219. */
  42220. selectionOctree: Octree<AbstractMesh>;
  42221. /**
  42222. * Creates or updates the octree used to boost selection (picking)
  42223. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42224. * @param maxCapacity defines the maximum capacity per leaf
  42225. * @param maxDepth defines the maximum depth of the octree
  42226. * @returns an octree of AbstractMesh
  42227. */
  42228. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42229. }
  42230. }
  42231. module "babylonjs/Meshes/abstractMesh" {
  42232. interface AbstractMesh {
  42233. /**
  42234. * @hidden
  42235. * Backing Field
  42236. */
  42237. _submeshesOctree: Octree<SubMesh>;
  42238. /**
  42239. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42240. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42241. * @param maxCapacity defines the maximum size of each block (64 by default)
  42242. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42243. * @returns the new octree
  42244. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42245. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42246. */
  42247. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42248. }
  42249. }
  42250. /**
  42251. * Defines the octree scene component responsible to manage any octrees
  42252. * in a given scene.
  42253. */
  42254. export class OctreeSceneComponent {
  42255. /**
  42256. * The component name help to identify the component in the list of scene components.
  42257. */
  42258. readonly name: string;
  42259. /**
  42260. * The scene the component belongs to.
  42261. */
  42262. scene: Scene;
  42263. /**
  42264. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42265. */
  42266. readonly checksIsEnabled: boolean;
  42267. /**
  42268. * Creates a new instance of the component for the given scene
  42269. * @param scene Defines the scene to register the component in
  42270. */
  42271. constructor(scene: Scene);
  42272. /**
  42273. * Registers the component in a given scene
  42274. */
  42275. register(): void;
  42276. /**
  42277. * Return the list of active meshes
  42278. * @returns the list of active meshes
  42279. */
  42280. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42281. /**
  42282. * Return the list of active sub meshes
  42283. * @param mesh The mesh to get the candidates sub meshes from
  42284. * @returns the list of active sub meshes
  42285. */
  42286. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42287. private _tempRay;
  42288. /**
  42289. * Return the list of sub meshes intersecting with a given local ray
  42290. * @param mesh defines the mesh to find the submesh for
  42291. * @param localRay defines the ray in local space
  42292. * @returns the list of intersecting sub meshes
  42293. */
  42294. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42295. /**
  42296. * Return the list of sub meshes colliding with a collider
  42297. * @param mesh defines the mesh to find the submesh for
  42298. * @param collider defines the collider to evaluate the collision against
  42299. * @returns the list of colliding sub meshes
  42300. */
  42301. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42302. /**
  42303. * Rebuilds the elements related to this component in case of
  42304. * context lost for instance.
  42305. */
  42306. rebuild(): void;
  42307. /**
  42308. * Disposes the component and the associated ressources.
  42309. */
  42310. dispose(): void;
  42311. }
  42312. }
  42313. declare module "babylonjs/Culling/Octrees/index" {
  42314. export * from "babylonjs/Culling/Octrees/octree";
  42315. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42316. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42317. }
  42318. declare module "babylonjs/Culling/index" {
  42319. export * from "babylonjs/Culling/boundingBox";
  42320. export * from "babylonjs/Culling/boundingInfo";
  42321. export * from "babylonjs/Culling/boundingSphere";
  42322. export * from "babylonjs/Culling/Octrees/index";
  42323. export * from "babylonjs/Culling/ray";
  42324. }
  42325. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42326. import { IDisposable, Scene } from "babylonjs/scene";
  42327. import { Nullable } from "babylonjs/types";
  42328. import { Observable } from "babylonjs/Misc/observable";
  42329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42330. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42331. import { Camera } from "babylonjs/Cameras/camera";
  42332. /**
  42333. * Renders a layer on top of an existing scene
  42334. */
  42335. export class UtilityLayerRenderer implements IDisposable {
  42336. /** the original scene that will be rendered on top of */
  42337. originalScene: Scene;
  42338. private _pointerCaptures;
  42339. private _lastPointerEvents;
  42340. private static _DefaultUtilityLayer;
  42341. private static _DefaultKeepDepthUtilityLayer;
  42342. private _sharedGizmoLight;
  42343. private _renderCamera;
  42344. /**
  42345. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42346. * @returns the camera that is used when rendering the utility layer
  42347. */
  42348. getRenderCamera(): Nullable<Camera>;
  42349. /**
  42350. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42351. * @param cam the camera that should be used when rendering the utility layer
  42352. */
  42353. setRenderCamera(cam: Nullable<Camera>): void;
  42354. /**
  42355. * @hidden
  42356. * Light which used by gizmos to get light shading
  42357. */
  42358. _getSharedGizmoLight(): HemisphericLight;
  42359. /**
  42360. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42361. */
  42362. pickUtilitySceneFirst: boolean;
  42363. /**
  42364. * 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)
  42365. */
  42366. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42367. /**
  42368. * 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)
  42369. */
  42370. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42371. /**
  42372. * The scene that is rendered on top of the original scene
  42373. */
  42374. utilityLayerScene: Scene;
  42375. /**
  42376. * If the utility layer should automatically be rendered on top of existing scene
  42377. */
  42378. shouldRender: boolean;
  42379. /**
  42380. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42381. */
  42382. onlyCheckPointerDownEvents: boolean;
  42383. /**
  42384. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42385. */
  42386. processAllEvents: boolean;
  42387. /**
  42388. * Observable raised when the pointer move from the utility layer scene to the main scene
  42389. */
  42390. onPointerOutObservable: Observable<number>;
  42391. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42392. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42393. private _afterRenderObserver;
  42394. private _sceneDisposeObserver;
  42395. private _originalPointerObserver;
  42396. /**
  42397. * Instantiates a UtilityLayerRenderer
  42398. * @param originalScene the original scene that will be rendered on top of
  42399. * @param handleEvents boolean indicating if the utility layer should handle events
  42400. */
  42401. constructor(
  42402. /** the original scene that will be rendered on top of */
  42403. originalScene: Scene, handleEvents?: boolean);
  42404. private _notifyObservers;
  42405. /**
  42406. * Renders the utility layers scene on top of the original scene
  42407. */
  42408. render(): void;
  42409. /**
  42410. * Disposes of the renderer
  42411. */
  42412. dispose(): void;
  42413. private _updateCamera;
  42414. }
  42415. }
  42416. declare module "babylonjs/Gizmos/gizmo" {
  42417. import { Nullable } from "babylonjs/types";
  42418. import { IDisposable } from "babylonjs/scene";
  42419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42420. import { Mesh } from "babylonjs/Meshes/mesh";
  42421. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42422. /**
  42423. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42424. */
  42425. export class Gizmo implements IDisposable {
  42426. /** The utility layer the gizmo will be added to */
  42427. gizmoLayer: UtilityLayerRenderer;
  42428. /**
  42429. * The root mesh of the gizmo
  42430. */
  42431. _rootMesh: Mesh;
  42432. private _attachedMesh;
  42433. /**
  42434. * Ratio for the scale of the gizmo (Default: 1)
  42435. */
  42436. scaleRatio: number;
  42437. /**
  42438. * If a custom mesh has been set (Default: false)
  42439. */
  42440. protected _customMeshSet: boolean;
  42441. /**
  42442. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42443. * * When set, interactions will be enabled
  42444. */
  42445. attachedMesh: Nullable<AbstractMesh>;
  42446. /**
  42447. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42448. * @param mesh The mesh to replace the default mesh of the gizmo
  42449. */
  42450. setCustomMesh(mesh: Mesh): void;
  42451. /**
  42452. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42453. */
  42454. updateGizmoRotationToMatchAttachedMesh: boolean;
  42455. /**
  42456. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42457. */
  42458. updateGizmoPositionToMatchAttachedMesh: boolean;
  42459. /**
  42460. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42461. */
  42462. protected _updateScale: boolean;
  42463. protected _interactionsEnabled: boolean;
  42464. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42465. private _beforeRenderObserver;
  42466. private _tempVector;
  42467. /**
  42468. * Creates a gizmo
  42469. * @param gizmoLayer The utility layer the gizmo will be added to
  42470. */
  42471. constructor(
  42472. /** The utility layer the gizmo will be added to */
  42473. gizmoLayer?: UtilityLayerRenderer);
  42474. /**
  42475. * Updates the gizmo to match the attached mesh's position/rotation
  42476. */
  42477. protected _update(): void;
  42478. /**
  42479. * Disposes of the gizmo
  42480. */
  42481. dispose(): void;
  42482. }
  42483. }
  42484. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42485. import { Observable } from "babylonjs/Misc/observable";
  42486. import { Nullable } from "babylonjs/types";
  42487. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42488. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42490. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42491. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42492. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42493. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42494. import { Scene } from "babylonjs/scene";
  42495. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42496. /**
  42497. * Single plane drag gizmo
  42498. */
  42499. export class PlaneDragGizmo extends Gizmo {
  42500. /**
  42501. * Drag behavior responsible for the gizmos dragging interactions
  42502. */
  42503. dragBehavior: PointerDragBehavior;
  42504. private _pointerObserver;
  42505. /**
  42506. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42507. */
  42508. snapDistance: number;
  42509. /**
  42510. * Event that fires each time the gizmo snaps to a new location.
  42511. * * snapDistance is the the change in distance
  42512. */
  42513. onSnapObservable: Observable<{
  42514. snapDistance: number;
  42515. }>;
  42516. private _plane;
  42517. private _coloredMaterial;
  42518. private _hoverMaterial;
  42519. private _isEnabled;
  42520. private _parent;
  42521. /** @hidden */
  42522. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42523. /** @hidden */
  42524. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42525. /**
  42526. * Creates a PlaneDragGizmo
  42527. * @param gizmoLayer The utility layer the gizmo will be added to
  42528. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42529. * @param color The color of the gizmo
  42530. */
  42531. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42532. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42533. /**
  42534. * If the gizmo is enabled
  42535. */
  42536. isEnabled: boolean;
  42537. /**
  42538. * Disposes of the gizmo
  42539. */
  42540. dispose(): void;
  42541. }
  42542. }
  42543. declare module "babylonjs/Gizmos/positionGizmo" {
  42544. import { Observable } from "babylonjs/Misc/observable";
  42545. import { Nullable } from "babylonjs/types";
  42546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42547. import { Mesh } from "babylonjs/Meshes/mesh";
  42548. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42549. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42550. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42551. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42552. /**
  42553. * Gizmo that enables dragging a mesh along 3 axis
  42554. */
  42555. export class PositionGizmo extends Gizmo {
  42556. /**
  42557. * Internal gizmo used for interactions on the x axis
  42558. */
  42559. xGizmo: AxisDragGizmo;
  42560. /**
  42561. * Internal gizmo used for interactions on the y axis
  42562. */
  42563. yGizmo: AxisDragGizmo;
  42564. /**
  42565. * Internal gizmo used for interactions on the z axis
  42566. */
  42567. zGizmo: AxisDragGizmo;
  42568. /**
  42569. * Internal gizmo used for interactions on the yz plane
  42570. */
  42571. xPlaneGizmo: PlaneDragGizmo;
  42572. /**
  42573. * Internal gizmo used for interactions on the xz plane
  42574. */
  42575. yPlaneGizmo: PlaneDragGizmo;
  42576. /**
  42577. * Internal gizmo used for interactions on the xy plane
  42578. */
  42579. zPlaneGizmo: PlaneDragGizmo;
  42580. /**
  42581. * private variables
  42582. */
  42583. private _meshAttached;
  42584. private _updateGizmoRotationToMatchAttachedMesh;
  42585. private _snapDistance;
  42586. private _scaleRatio;
  42587. /** Fires an event when any of it's sub gizmos are dragged */
  42588. onDragStartObservable: Observable<{}>;
  42589. /** Fires an event when any of it's sub gizmos are released from dragging */
  42590. onDragEndObservable: Observable<{}>;
  42591. /**
  42592. * If set to true, planar drag is enabled
  42593. */
  42594. private _planarGizmoEnabled;
  42595. attachedMesh: Nullable<AbstractMesh>;
  42596. /**
  42597. * Creates a PositionGizmo
  42598. * @param gizmoLayer The utility layer the gizmo will be added to
  42599. */
  42600. constructor(gizmoLayer?: UtilityLayerRenderer);
  42601. /**
  42602. * If the planar drag gizmo is enabled
  42603. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42604. */
  42605. planarGizmoEnabled: boolean;
  42606. updateGizmoRotationToMatchAttachedMesh: boolean;
  42607. /**
  42608. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42609. */
  42610. snapDistance: number;
  42611. /**
  42612. * Ratio for the scale of the gizmo (Default: 1)
  42613. */
  42614. scaleRatio: number;
  42615. /**
  42616. * Disposes of the gizmo
  42617. */
  42618. dispose(): void;
  42619. /**
  42620. * CustomMeshes are not supported by this gizmo
  42621. * @param mesh The mesh to replace the default mesh of the gizmo
  42622. */
  42623. setCustomMesh(mesh: Mesh): void;
  42624. }
  42625. }
  42626. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42627. import { Observable } from "babylonjs/Misc/observable";
  42628. import { Nullable } from "babylonjs/types";
  42629. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42630. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42632. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42633. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42634. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42635. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42636. import { Scene } from "babylonjs/scene";
  42637. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42638. /**
  42639. * Single axis drag gizmo
  42640. */
  42641. export class AxisDragGizmo extends Gizmo {
  42642. /**
  42643. * Drag behavior responsible for the gizmos dragging interactions
  42644. */
  42645. dragBehavior: PointerDragBehavior;
  42646. private _pointerObserver;
  42647. /**
  42648. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42649. */
  42650. snapDistance: number;
  42651. /**
  42652. * Event that fires each time the gizmo snaps to a new location.
  42653. * * snapDistance is the the change in distance
  42654. */
  42655. onSnapObservable: Observable<{
  42656. snapDistance: number;
  42657. }>;
  42658. private _isEnabled;
  42659. private _parent;
  42660. private _arrow;
  42661. private _coloredMaterial;
  42662. private _hoverMaterial;
  42663. /** @hidden */
  42664. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42665. /** @hidden */
  42666. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42667. /**
  42668. * Creates an AxisDragGizmo
  42669. * @param gizmoLayer The utility layer the gizmo will be added to
  42670. * @param dragAxis The axis which the gizmo will be able to drag on
  42671. * @param color The color of the gizmo
  42672. */
  42673. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42674. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42675. /**
  42676. * If the gizmo is enabled
  42677. */
  42678. isEnabled: boolean;
  42679. /**
  42680. * Disposes of the gizmo
  42681. */
  42682. dispose(): void;
  42683. }
  42684. }
  42685. declare module "babylonjs/Debug/axesViewer" {
  42686. import { Vector3 } from "babylonjs/Maths/math";
  42687. import { Nullable } from "babylonjs/types";
  42688. import { Scene } from "babylonjs/scene";
  42689. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42690. /**
  42691. * The Axes viewer will show 3 axes in a specific point in space
  42692. */
  42693. export class AxesViewer {
  42694. private _xAxis;
  42695. private _yAxis;
  42696. private _zAxis;
  42697. private _scaleLinesFactor;
  42698. private _instanced;
  42699. /**
  42700. * Gets the hosting scene
  42701. */
  42702. scene: Scene;
  42703. /**
  42704. * Gets or sets a number used to scale line length
  42705. */
  42706. scaleLines: number;
  42707. /** Gets the node hierarchy used to render x-axis */
  42708. readonly xAxis: TransformNode;
  42709. /** Gets the node hierarchy used to render y-axis */
  42710. readonly yAxis: TransformNode;
  42711. /** Gets the node hierarchy used to render z-axis */
  42712. readonly zAxis: TransformNode;
  42713. /**
  42714. * Creates a new AxesViewer
  42715. * @param scene defines the hosting scene
  42716. * @param scaleLines defines a number used to scale line length (1 by default)
  42717. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42718. * @param xAxis defines the node hierarchy used to render the x-axis
  42719. * @param yAxis defines the node hierarchy used to render the y-axis
  42720. * @param zAxis defines the node hierarchy used to render the z-axis
  42721. */
  42722. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42723. /**
  42724. * Force the viewer to update
  42725. * @param position defines the position of the viewer
  42726. * @param xaxis defines the x axis of the viewer
  42727. * @param yaxis defines the y axis of the viewer
  42728. * @param zaxis defines the z axis of the viewer
  42729. */
  42730. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42731. /**
  42732. * Creates an instance of this axes viewer.
  42733. * @returns a new axes viewer with instanced meshes
  42734. */
  42735. createInstance(): AxesViewer;
  42736. /** Releases resources */
  42737. dispose(): void;
  42738. private static _SetRenderingGroupId;
  42739. }
  42740. }
  42741. declare module "babylonjs/Debug/boneAxesViewer" {
  42742. import { Nullable } from "babylonjs/types";
  42743. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42744. import { Vector3 } from "babylonjs/Maths/math";
  42745. import { Mesh } from "babylonjs/Meshes/mesh";
  42746. import { Bone } from "babylonjs/Bones/bone";
  42747. import { Scene } from "babylonjs/scene";
  42748. /**
  42749. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42750. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42751. */
  42752. export class BoneAxesViewer extends AxesViewer {
  42753. /**
  42754. * Gets or sets the target mesh where to display the axes viewer
  42755. */
  42756. mesh: Nullable<Mesh>;
  42757. /**
  42758. * Gets or sets the target bone where to display the axes viewer
  42759. */
  42760. bone: Nullable<Bone>;
  42761. /** Gets current position */
  42762. pos: Vector3;
  42763. /** Gets direction of X axis */
  42764. xaxis: Vector3;
  42765. /** Gets direction of Y axis */
  42766. yaxis: Vector3;
  42767. /** Gets direction of Z axis */
  42768. zaxis: Vector3;
  42769. /**
  42770. * Creates a new BoneAxesViewer
  42771. * @param scene defines the hosting scene
  42772. * @param bone defines the target bone
  42773. * @param mesh defines the target mesh
  42774. * @param scaleLines defines a scaling factor for line length (1 by default)
  42775. */
  42776. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42777. /**
  42778. * Force the viewer to update
  42779. */
  42780. update(): void;
  42781. /** Releases resources */
  42782. dispose(): void;
  42783. }
  42784. }
  42785. declare module "babylonjs/Debug/debugLayer" {
  42786. import { Observable } from "babylonjs/Misc/observable";
  42787. import { Scene } from "babylonjs/scene";
  42788. /**
  42789. * Interface used to define scene explorer extensibility option
  42790. */
  42791. export interface IExplorerExtensibilityOption {
  42792. /**
  42793. * Define the option label
  42794. */
  42795. label: string;
  42796. /**
  42797. * Defines the action to execute on click
  42798. */
  42799. action: (entity: any) => void;
  42800. }
  42801. /**
  42802. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42803. */
  42804. export interface IExplorerExtensibilityGroup {
  42805. /**
  42806. * Defines a predicate to test if a given type mut be extended
  42807. */
  42808. predicate: (entity: any) => boolean;
  42809. /**
  42810. * Gets the list of options added to a type
  42811. */
  42812. entries: IExplorerExtensibilityOption[];
  42813. }
  42814. /**
  42815. * Interface used to define the options to use to create the Inspector
  42816. */
  42817. export interface IInspectorOptions {
  42818. /**
  42819. * Display in overlay mode (default: false)
  42820. */
  42821. overlay?: boolean;
  42822. /**
  42823. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42824. */
  42825. globalRoot?: HTMLElement;
  42826. /**
  42827. * Display the Scene explorer
  42828. */
  42829. showExplorer?: boolean;
  42830. /**
  42831. * Display the property inspector
  42832. */
  42833. showInspector?: boolean;
  42834. /**
  42835. * Display in embed mode (both panes on the right)
  42836. */
  42837. embedMode?: boolean;
  42838. /**
  42839. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42840. */
  42841. handleResize?: boolean;
  42842. /**
  42843. * Allow the panes to popup (default: true)
  42844. */
  42845. enablePopup?: boolean;
  42846. /**
  42847. * Allow the panes to be closed by users (default: true)
  42848. */
  42849. enableClose?: boolean;
  42850. /**
  42851. * Optional list of extensibility entries
  42852. */
  42853. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42854. /**
  42855. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42856. */
  42857. inspectorURL?: string;
  42858. }
  42859. module "babylonjs/scene" {
  42860. interface Scene {
  42861. /**
  42862. * @hidden
  42863. * Backing field
  42864. */
  42865. _debugLayer: DebugLayer;
  42866. /**
  42867. * Gets the debug layer (aka Inspector) associated with the scene
  42868. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42869. */
  42870. debugLayer: DebugLayer;
  42871. }
  42872. }
  42873. /**
  42874. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42875. * what is happening in your scene
  42876. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42877. */
  42878. export class DebugLayer {
  42879. /**
  42880. * Define the url to get the inspector script from.
  42881. * By default it uses the babylonjs CDN.
  42882. * @ignoreNaming
  42883. */
  42884. static InspectorURL: string;
  42885. private _scene;
  42886. private BJSINSPECTOR;
  42887. /**
  42888. * Observable triggered when a property is changed through the inspector.
  42889. */
  42890. onPropertyChangedObservable: Observable<{
  42891. object: any;
  42892. property: string;
  42893. value: any;
  42894. initialValue: any;
  42895. }>;
  42896. /**
  42897. * Instantiates a new debug layer.
  42898. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42899. * what is happening in your scene
  42900. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42901. * @param scene Defines the scene to inspect
  42902. */
  42903. constructor(scene: Scene);
  42904. /** Creates the inspector window. */
  42905. private _createInspector;
  42906. /**
  42907. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42908. * @param entity defines the entity to select
  42909. * @param lineContainerTitle defines the specific block to highlight
  42910. */
  42911. select(entity: any, lineContainerTitle?: string): void;
  42912. /** Get the inspector from bundle or global */
  42913. private _getGlobalInspector;
  42914. /**
  42915. * Get if the inspector is visible or not.
  42916. * @returns true if visible otherwise, false
  42917. */
  42918. isVisible(): boolean;
  42919. /**
  42920. * Hide the inspector and close its window.
  42921. */
  42922. hide(): void;
  42923. /**
  42924. * Launch the debugLayer.
  42925. * @param config Define the configuration of the inspector
  42926. * @return a promise fulfilled when the debug layer is visible
  42927. */
  42928. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42929. }
  42930. }
  42931. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42932. import { Nullable } from "babylonjs/types";
  42933. import { Scene } from "babylonjs/scene";
  42934. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42935. import { Mesh } from "babylonjs/Meshes/mesh";
  42936. /**
  42937. * Class containing static functions to help procedurally build meshes
  42938. */
  42939. export class BoxBuilder {
  42940. /**
  42941. * Creates a box mesh
  42942. * * The parameter `size` sets the size (float) of each box side (default 1)
  42943. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42944. * * 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)
  42945. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42949. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42950. * @param name defines the name of the mesh
  42951. * @param options defines the options used to create the mesh
  42952. * @param scene defines the hosting scene
  42953. * @returns the box mesh
  42954. */
  42955. static CreateBox(name: string, options: {
  42956. size?: number;
  42957. width?: number;
  42958. height?: number;
  42959. depth?: number;
  42960. faceUV?: Vector4[];
  42961. faceColors?: Color4[];
  42962. sideOrientation?: number;
  42963. frontUVs?: Vector4;
  42964. backUVs?: Vector4;
  42965. wrap?: boolean;
  42966. topBaseAt?: number;
  42967. bottomBaseAt?: number;
  42968. updatable?: boolean;
  42969. }, scene?: Nullable<Scene>): Mesh;
  42970. }
  42971. }
  42972. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42973. import { Vector4 } from "babylonjs/Maths/math";
  42974. import { Mesh } from "babylonjs/Meshes/mesh";
  42975. /**
  42976. * Class containing static functions to help procedurally build meshes
  42977. */
  42978. export class SphereBuilder {
  42979. /**
  42980. * Creates a sphere mesh
  42981. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42982. * * 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`)
  42983. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42984. * * 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
  42985. * * 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)
  42986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42989. * @param name defines the name of the mesh
  42990. * @param options defines the options used to create the mesh
  42991. * @param scene defines the hosting scene
  42992. * @returns the sphere mesh
  42993. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42994. */
  42995. static CreateSphere(name: string, options: {
  42996. segments?: number;
  42997. diameter?: number;
  42998. diameterX?: number;
  42999. diameterY?: number;
  43000. diameterZ?: number;
  43001. arc?: number;
  43002. slice?: number;
  43003. sideOrientation?: number;
  43004. frontUVs?: Vector4;
  43005. backUVs?: Vector4;
  43006. updatable?: boolean;
  43007. }, scene: any): Mesh;
  43008. }
  43009. }
  43010. declare module "babylonjs/Debug/physicsViewer" {
  43011. import { Nullable } from "babylonjs/types";
  43012. import { Scene } from "babylonjs/scene";
  43013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43014. import { Mesh } from "babylonjs/Meshes/mesh";
  43015. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43016. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43017. /**
  43018. * Used to show the physics impostor around the specific mesh
  43019. */
  43020. export class PhysicsViewer {
  43021. /** @hidden */
  43022. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43023. /** @hidden */
  43024. protected _meshes: Array<Nullable<AbstractMesh>>;
  43025. /** @hidden */
  43026. protected _scene: Nullable<Scene>;
  43027. /** @hidden */
  43028. protected _numMeshes: number;
  43029. /** @hidden */
  43030. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43031. private _renderFunction;
  43032. private _utilityLayer;
  43033. private _debugBoxMesh;
  43034. private _debugSphereMesh;
  43035. private _debugCylinderMesh;
  43036. private _debugMaterial;
  43037. private _debugMeshMeshes;
  43038. /**
  43039. * Creates a new PhysicsViewer
  43040. * @param scene defines the hosting scene
  43041. */
  43042. constructor(scene: Scene);
  43043. /** @hidden */
  43044. protected _updateDebugMeshes(): void;
  43045. /**
  43046. * Renders a specified physic impostor
  43047. * @param impostor defines the impostor to render
  43048. * @param targetMesh defines the mesh represented by the impostor
  43049. * @returns the new debug mesh used to render the impostor
  43050. */
  43051. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43052. /**
  43053. * Hides a specified physic impostor
  43054. * @param impostor defines the impostor to hide
  43055. */
  43056. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43057. private _getDebugMaterial;
  43058. private _getDebugBoxMesh;
  43059. private _getDebugSphereMesh;
  43060. private _getDebugCylinderMesh;
  43061. private _getDebugMeshMesh;
  43062. private _getDebugMesh;
  43063. /** Releases all resources */
  43064. dispose(): void;
  43065. }
  43066. }
  43067. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43068. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43069. import { Nullable } from "babylonjs/types";
  43070. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43071. import { Scene } from "babylonjs/scene";
  43072. /**
  43073. * Class containing static functions to help procedurally build meshes
  43074. */
  43075. export class LinesBuilder {
  43076. /**
  43077. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43078. * * 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
  43079. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43080. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43081. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43082. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43083. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43084. * * 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
  43085. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43088. * @param name defines the name of the new line system
  43089. * @param options defines the options used to create the line system
  43090. * @param scene defines the hosting scene
  43091. * @returns a new line system mesh
  43092. */
  43093. static CreateLineSystem(name: string, options: {
  43094. lines: Vector3[][];
  43095. updatable?: boolean;
  43096. instance?: Nullable<LinesMesh>;
  43097. colors?: Nullable<Color4[][]>;
  43098. useVertexAlpha?: boolean;
  43099. }, scene: Nullable<Scene>): LinesMesh;
  43100. /**
  43101. * Creates a line mesh
  43102. * 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
  43103. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43104. * * The parameter `points` is an array successive Vector3
  43105. * * 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
  43106. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43107. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43108. * * When updating an instance, remember that only point positions can change, not the number of points
  43109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43111. * @param name defines the name of the new line system
  43112. * @param options defines the options used to create the line system
  43113. * @param scene defines the hosting scene
  43114. * @returns a new line mesh
  43115. */
  43116. static CreateLines(name: string, options: {
  43117. points: Vector3[];
  43118. updatable?: boolean;
  43119. instance?: Nullable<LinesMesh>;
  43120. colors?: Color4[];
  43121. useVertexAlpha?: boolean;
  43122. }, scene?: Nullable<Scene>): LinesMesh;
  43123. /**
  43124. * Creates a dashed line mesh
  43125. * * 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
  43126. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43127. * * The parameter `points` is an array successive Vector3
  43128. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43129. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43130. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43131. * * 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
  43132. * * When updating an instance, remember that only point positions can change, not the number of points
  43133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43134. * @param name defines the name of the mesh
  43135. * @param options defines the options used to create the mesh
  43136. * @param scene defines the hosting scene
  43137. * @returns the dashed line mesh
  43138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43139. */
  43140. static CreateDashedLines(name: string, options: {
  43141. points: Vector3[];
  43142. dashSize?: number;
  43143. gapSize?: number;
  43144. dashNb?: number;
  43145. updatable?: boolean;
  43146. instance?: LinesMesh;
  43147. }, scene?: Nullable<Scene>): LinesMesh;
  43148. }
  43149. }
  43150. declare module "babylonjs/Debug/rayHelper" {
  43151. import { Nullable } from "babylonjs/types";
  43152. import { Ray } from "babylonjs/Culling/ray";
  43153. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43154. import { Scene } from "babylonjs/scene";
  43155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43156. import "babylonjs/Meshes/Builders/linesBuilder";
  43157. /**
  43158. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43159. * in order to better appreciate the issue one might have.
  43160. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43161. */
  43162. export class RayHelper {
  43163. /**
  43164. * Defines the ray we are currently tryin to visualize.
  43165. */
  43166. ray: Nullable<Ray>;
  43167. private _renderPoints;
  43168. private _renderLine;
  43169. private _renderFunction;
  43170. private _scene;
  43171. private _updateToMeshFunction;
  43172. private _attachedToMesh;
  43173. private _meshSpaceDirection;
  43174. private _meshSpaceOrigin;
  43175. /**
  43176. * Helper function to create a colored helper in a scene in one line.
  43177. * @param ray Defines the ray we are currently tryin to visualize
  43178. * @param scene Defines the scene the ray is used in
  43179. * @param color Defines the color we want to see the ray in
  43180. * @returns The newly created ray helper.
  43181. */
  43182. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43183. /**
  43184. * Instantiate a new ray helper.
  43185. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43186. * in order to better appreciate the issue one might have.
  43187. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43188. * @param ray Defines the ray we are currently tryin to visualize
  43189. */
  43190. constructor(ray: Ray);
  43191. /**
  43192. * Shows the ray we are willing to debug.
  43193. * @param scene Defines the scene the ray needs to be rendered in
  43194. * @param color Defines the color the ray needs to be rendered in
  43195. */
  43196. show(scene: Scene, color?: Color3): void;
  43197. /**
  43198. * Hides the ray we are debugging.
  43199. */
  43200. hide(): void;
  43201. private _render;
  43202. /**
  43203. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43204. * @param mesh Defines the mesh we want the helper attached to
  43205. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43206. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43207. * @param length Defines the length of the ray
  43208. */
  43209. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43210. /**
  43211. * Detach the ray helper from the mesh it has previously been attached to.
  43212. */
  43213. detachFromMesh(): void;
  43214. private _updateToMesh;
  43215. /**
  43216. * Dispose the helper and release its associated resources.
  43217. */
  43218. dispose(): void;
  43219. }
  43220. }
  43221. declare module "babylonjs/Debug/skeletonViewer" {
  43222. import { Color3 } from "babylonjs/Maths/math";
  43223. import { Scene } from "babylonjs/scene";
  43224. import { Nullable } from "babylonjs/types";
  43225. import { Skeleton } from "babylonjs/Bones/skeleton";
  43226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43227. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43228. /**
  43229. * Class used to render a debug view of a given skeleton
  43230. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43231. */
  43232. export class SkeletonViewer {
  43233. /** defines the skeleton to render */
  43234. skeleton: Skeleton;
  43235. /** defines the mesh attached to the skeleton */
  43236. mesh: AbstractMesh;
  43237. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43238. autoUpdateBonesMatrices: boolean;
  43239. /** defines the rendering group id to use with the viewer */
  43240. renderingGroupId: number;
  43241. /** Gets or sets the color used to render the skeleton */
  43242. color: Color3;
  43243. private _scene;
  43244. private _debugLines;
  43245. private _debugMesh;
  43246. private _isEnabled;
  43247. private _renderFunction;
  43248. private _utilityLayer;
  43249. /**
  43250. * Returns the mesh used to render the bones
  43251. */
  43252. readonly debugMesh: Nullable<LinesMesh>;
  43253. /**
  43254. * Creates a new SkeletonViewer
  43255. * @param skeleton defines the skeleton to render
  43256. * @param mesh defines the mesh attached to the skeleton
  43257. * @param scene defines the hosting scene
  43258. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43259. * @param renderingGroupId defines the rendering group id to use with the viewer
  43260. */
  43261. constructor(
  43262. /** defines the skeleton to render */
  43263. skeleton: Skeleton,
  43264. /** defines the mesh attached to the skeleton */
  43265. mesh: AbstractMesh, scene: Scene,
  43266. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43267. autoUpdateBonesMatrices?: boolean,
  43268. /** defines the rendering group id to use with the viewer */
  43269. renderingGroupId?: number);
  43270. /** Gets or sets a boolean indicating if the viewer is enabled */
  43271. isEnabled: boolean;
  43272. private _getBonePosition;
  43273. private _getLinesForBonesWithLength;
  43274. private _getLinesForBonesNoLength;
  43275. /** Update the viewer to sync with current skeleton state */
  43276. update(): void;
  43277. /** Release associated resources */
  43278. dispose(): void;
  43279. }
  43280. }
  43281. declare module "babylonjs/Debug/index" {
  43282. export * from "babylonjs/Debug/axesViewer";
  43283. export * from "babylonjs/Debug/boneAxesViewer";
  43284. export * from "babylonjs/Debug/debugLayer";
  43285. export * from "babylonjs/Debug/physicsViewer";
  43286. export * from "babylonjs/Debug/rayHelper";
  43287. export * from "babylonjs/Debug/skeletonViewer";
  43288. }
  43289. declare module "babylonjs/Engines/nullEngine" {
  43290. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43291. import { Scene } from "babylonjs/scene";
  43292. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43293. import { Engine } from "babylonjs/Engines/engine";
  43294. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43295. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43296. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43297. import { Effect } from "babylonjs/Materials/effect";
  43298. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43299. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43300. /**
  43301. * Options to create the null engine
  43302. */
  43303. export class NullEngineOptions {
  43304. /**
  43305. * Render width (Default: 512)
  43306. */
  43307. renderWidth: number;
  43308. /**
  43309. * Render height (Default: 256)
  43310. */
  43311. renderHeight: number;
  43312. /**
  43313. * Texture size (Default: 512)
  43314. */
  43315. textureSize: number;
  43316. /**
  43317. * If delta time between frames should be constant
  43318. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43319. */
  43320. deterministicLockstep: boolean;
  43321. /**
  43322. * Maximum about of steps between frames (Default: 4)
  43323. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43324. */
  43325. lockstepMaxSteps: number;
  43326. }
  43327. /**
  43328. * The null engine class provides support for headless version of babylon.js.
  43329. * This can be used in server side scenario or for testing purposes
  43330. */
  43331. export class NullEngine extends Engine {
  43332. private _options;
  43333. /**
  43334. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43335. */
  43336. isDeterministicLockStep(): boolean;
  43337. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43338. getLockstepMaxSteps(): number;
  43339. /**
  43340. * Sets hardware scaling, used to save performance if needed
  43341. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43342. */
  43343. getHardwareScalingLevel(): number;
  43344. constructor(options?: NullEngineOptions);
  43345. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43346. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43347. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43348. getRenderWidth(useScreen?: boolean): number;
  43349. getRenderHeight(useScreen?: boolean): number;
  43350. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43351. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43352. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43353. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43354. bindSamplers(effect: Effect): void;
  43355. enableEffect(effect: Effect): void;
  43356. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43357. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43358. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43359. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43360. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43361. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43362. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43363. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43364. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43365. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43366. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43367. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43368. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43369. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43370. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43371. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43372. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43373. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43374. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43375. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43376. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43377. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43378. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43379. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43380. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43381. bindBuffers(vertexBuffers: {
  43382. [key: string]: VertexBuffer;
  43383. }, indexBuffer: DataBuffer, effect: Effect): void;
  43384. wipeCaches(bruteForce?: boolean): void;
  43385. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43386. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43387. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43388. /** @hidden */
  43389. _createTexture(): WebGLTexture;
  43390. /** @hidden */
  43391. _releaseTexture(texture: InternalTexture): void;
  43392. 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;
  43393. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43394. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43395. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43396. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43397. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43398. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43399. areAllEffectsReady(): boolean;
  43400. /**
  43401. * @hidden
  43402. * Get the current error code of the webGL context
  43403. * @returns the error code
  43404. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43405. */
  43406. getError(): number;
  43407. /** @hidden */
  43408. _getUnpackAlignement(): number;
  43409. /** @hidden */
  43410. _unpackFlipY(value: boolean): void;
  43411. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43412. /**
  43413. * Updates a dynamic vertex buffer.
  43414. * @param vertexBuffer the vertex buffer to update
  43415. * @param data the data used to update the vertex buffer
  43416. * @param byteOffset the byte offset of the data (optional)
  43417. * @param byteLength the byte length of the data (optional)
  43418. */
  43419. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43420. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43421. /** @hidden */
  43422. _bindTexture(channel: number, texture: InternalTexture): void;
  43423. /** @hidden */
  43424. _releaseBuffer(buffer: DataBuffer): boolean;
  43425. releaseEffects(): void;
  43426. displayLoadingUI(): void;
  43427. hideLoadingUI(): void;
  43428. /** @hidden */
  43429. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43430. /** @hidden */
  43431. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43432. /** @hidden */
  43433. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43434. /** @hidden */
  43435. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43436. }
  43437. }
  43438. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43439. import { Nullable, int } from "babylonjs/types";
  43440. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43441. /** @hidden */
  43442. export class _OcclusionDataStorage {
  43443. /** @hidden */
  43444. occlusionInternalRetryCounter: number;
  43445. /** @hidden */
  43446. isOcclusionQueryInProgress: boolean;
  43447. /** @hidden */
  43448. isOccluded: boolean;
  43449. /** @hidden */
  43450. occlusionRetryCount: number;
  43451. /** @hidden */
  43452. occlusionType: number;
  43453. /** @hidden */
  43454. occlusionQueryAlgorithmType: number;
  43455. }
  43456. module "babylonjs/Engines/engine" {
  43457. interface Engine {
  43458. /**
  43459. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43460. * @return the new query
  43461. */
  43462. createQuery(): WebGLQuery;
  43463. /**
  43464. * Delete and release a webGL query
  43465. * @param query defines the query to delete
  43466. * @return the current engine
  43467. */
  43468. deleteQuery(query: WebGLQuery): Engine;
  43469. /**
  43470. * Check if a given query has resolved and got its value
  43471. * @param query defines the query to check
  43472. * @returns true if the query got its value
  43473. */
  43474. isQueryResultAvailable(query: WebGLQuery): boolean;
  43475. /**
  43476. * Gets the value of a given query
  43477. * @param query defines the query to check
  43478. * @returns the value of the query
  43479. */
  43480. getQueryResult(query: WebGLQuery): number;
  43481. /**
  43482. * Initiates an occlusion query
  43483. * @param algorithmType defines the algorithm to use
  43484. * @param query defines the query to use
  43485. * @returns the current engine
  43486. * @see http://doc.babylonjs.com/features/occlusionquery
  43487. */
  43488. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43489. /**
  43490. * Ends an occlusion query
  43491. * @see http://doc.babylonjs.com/features/occlusionquery
  43492. * @param algorithmType defines the algorithm to use
  43493. * @returns the current engine
  43494. */
  43495. endOcclusionQuery(algorithmType: number): Engine;
  43496. /**
  43497. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43498. * Please note that only one query can be issued at a time
  43499. * @returns a time token used to track the time span
  43500. */
  43501. startTimeQuery(): Nullable<_TimeToken>;
  43502. /**
  43503. * Ends a time query
  43504. * @param token defines the token used to measure the time span
  43505. * @returns the time spent (in ns)
  43506. */
  43507. endTimeQuery(token: _TimeToken): int;
  43508. /** @hidden */
  43509. _currentNonTimestampToken: Nullable<_TimeToken>;
  43510. /** @hidden */
  43511. _createTimeQuery(): WebGLQuery;
  43512. /** @hidden */
  43513. _deleteTimeQuery(query: WebGLQuery): void;
  43514. /** @hidden */
  43515. _getGlAlgorithmType(algorithmType: number): number;
  43516. /** @hidden */
  43517. _getTimeQueryResult(query: WebGLQuery): any;
  43518. /** @hidden */
  43519. _getTimeQueryAvailability(query: WebGLQuery): any;
  43520. }
  43521. }
  43522. module "babylonjs/Meshes/abstractMesh" {
  43523. interface AbstractMesh {
  43524. /**
  43525. * Backing filed
  43526. * @hidden
  43527. */
  43528. __occlusionDataStorage: _OcclusionDataStorage;
  43529. /**
  43530. * Access property
  43531. * @hidden
  43532. */
  43533. _occlusionDataStorage: _OcclusionDataStorage;
  43534. /**
  43535. * 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.
  43536. * The default value is -1 which means don't break the query and wait till the result
  43537. * @see http://doc.babylonjs.com/features/occlusionquery
  43538. */
  43539. occlusionRetryCount: number;
  43540. /**
  43541. * 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:
  43542. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43543. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43544. * * 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.
  43545. * @see http://doc.babylonjs.com/features/occlusionquery
  43546. */
  43547. occlusionType: number;
  43548. /**
  43549. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43550. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43551. * * 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.
  43552. * @see http://doc.babylonjs.com/features/occlusionquery
  43553. */
  43554. occlusionQueryAlgorithmType: number;
  43555. /**
  43556. * 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
  43557. * @see http://doc.babylonjs.com/features/occlusionquery
  43558. */
  43559. isOccluded: boolean;
  43560. /**
  43561. * Flag to check the progress status of the query
  43562. * @see http://doc.babylonjs.com/features/occlusionquery
  43563. */
  43564. isOcclusionQueryInProgress: boolean;
  43565. }
  43566. }
  43567. }
  43568. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43569. import { Nullable } from "babylonjs/types";
  43570. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43571. /** @hidden */
  43572. export var _forceTransformFeedbackToBundle: boolean;
  43573. module "babylonjs/Engines/engine" {
  43574. interface Engine {
  43575. /**
  43576. * Creates a webGL transform feedback object
  43577. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43578. * @returns the webGL transform feedback object
  43579. */
  43580. createTransformFeedback(): WebGLTransformFeedback;
  43581. /**
  43582. * Delete a webGL transform feedback object
  43583. * @param value defines the webGL transform feedback object to delete
  43584. */
  43585. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43586. /**
  43587. * Bind a webGL transform feedback object to the webgl context
  43588. * @param value defines the webGL transform feedback object to bind
  43589. */
  43590. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43591. /**
  43592. * Begins a transform feedback operation
  43593. * @param usePoints defines if points or triangles must be used
  43594. */
  43595. beginTransformFeedback(usePoints: boolean): void;
  43596. /**
  43597. * Ends a transform feedback operation
  43598. */
  43599. endTransformFeedback(): void;
  43600. /**
  43601. * Specify the varyings to use with transform feedback
  43602. * @param program defines the associated webGL program
  43603. * @param value defines the list of strings representing the varying names
  43604. */
  43605. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43606. /**
  43607. * Bind a webGL buffer for a transform feedback operation
  43608. * @param value defines the webGL buffer to bind
  43609. */
  43610. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43611. }
  43612. }
  43613. }
  43614. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43615. import { Scene } from "babylonjs/scene";
  43616. import { Engine } from "babylonjs/Engines/engine";
  43617. import { Texture } from "babylonjs/Materials/Textures/texture";
  43618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43619. import "babylonjs/Engines/Extensions/engine.multiRender";
  43620. /**
  43621. * Creation options of the multi render target texture.
  43622. */
  43623. export interface IMultiRenderTargetOptions {
  43624. /**
  43625. * Define if the texture needs to create mip maps after render.
  43626. */
  43627. generateMipMaps?: boolean;
  43628. /**
  43629. * Define the types of all the draw buffers we want to create
  43630. */
  43631. types?: number[];
  43632. /**
  43633. * Define the sampling modes of all the draw buffers we want to create
  43634. */
  43635. samplingModes?: number[];
  43636. /**
  43637. * Define if a depth buffer is required
  43638. */
  43639. generateDepthBuffer?: boolean;
  43640. /**
  43641. * Define if a stencil buffer is required
  43642. */
  43643. generateStencilBuffer?: boolean;
  43644. /**
  43645. * Define if a depth texture is required instead of a depth buffer
  43646. */
  43647. generateDepthTexture?: boolean;
  43648. /**
  43649. * Define the number of desired draw buffers
  43650. */
  43651. textureCount?: number;
  43652. /**
  43653. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43654. */
  43655. doNotChangeAspectRatio?: boolean;
  43656. /**
  43657. * Define the default type of the buffers we are creating
  43658. */
  43659. defaultType?: number;
  43660. }
  43661. /**
  43662. * A multi render target, like a render target provides the ability to render to a texture.
  43663. * Unlike the render target, it can render to several draw buffers in one draw.
  43664. * This is specially interesting in deferred rendering or for any effects requiring more than
  43665. * just one color from a single pass.
  43666. */
  43667. export class MultiRenderTarget extends RenderTargetTexture {
  43668. private _internalTextures;
  43669. private _textures;
  43670. private _multiRenderTargetOptions;
  43671. /**
  43672. * Get if draw buffers are currently supported by the used hardware and browser.
  43673. */
  43674. readonly isSupported: boolean;
  43675. /**
  43676. * Get the list of textures generated by the multi render target.
  43677. */
  43678. readonly textures: Texture[];
  43679. /**
  43680. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43681. */
  43682. readonly depthTexture: Texture;
  43683. /**
  43684. * Set the wrapping mode on U of all the textures we are rendering to.
  43685. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43686. */
  43687. wrapU: number;
  43688. /**
  43689. * Set the wrapping mode on V of all the textures we are rendering to.
  43690. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43691. */
  43692. wrapV: number;
  43693. /**
  43694. * Instantiate a new multi render target texture.
  43695. * A multi render target, like a render target provides the ability to render to a texture.
  43696. * Unlike the render target, it can render to several draw buffers in one draw.
  43697. * This is specially interesting in deferred rendering or for any effects requiring more than
  43698. * just one color from a single pass.
  43699. * @param name Define the name of the texture
  43700. * @param size Define the size of the buffers to render to
  43701. * @param count Define the number of target we are rendering into
  43702. * @param scene Define the scene the texture belongs to
  43703. * @param options Define the options used to create the multi render target
  43704. */
  43705. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43706. /** @hidden */
  43707. _rebuild(): void;
  43708. private _createInternalTextures;
  43709. private _createTextures;
  43710. /**
  43711. * Define the number of samples used if MSAA is enabled.
  43712. */
  43713. samples: number;
  43714. /**
  43715. * Resize all the textures in the multi render target.
  43716. * Be carrefull as it will recreate all the data in the new texture.
  43717. * @param size Define the new size
  43718. */
  43719. resize(size: any): void;
  43720. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43721. /**
  43722. * Dispose the render targets and their associated resources
  43723. */
  43724. dispose(): void;
  43725. /**
  43726. * Release all the underlying texture used as draw buffers.
  43727. */
  43728. releaseInternalTextures(): void;
  43729. }
  43730. }
  43731. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43733. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43734. import { Nullable } from "babylonjs/types";
  43735. module "babylonjs/Engines/engine" {
  43736. interface Engine {
  43737. /**
  43738. * Unbind a list of render target textures from the webGL context
  43739. * This is used only when drawBuffer extension or webGL2 are active
  43740. * @param textures defines the render target textures to unbind
  43741. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43742. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43743. */
  43744. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43745. /**
  43746. * Create a multi render target texture
  43747. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43748. * @param size defines the size of the texture
  43749. * @param options defines the creation options
  43750. * @returns the cube texture as an InternalTexture
  43751. */
  43752. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43753. /**
  43754. * Update the sample count for a given multiple render target texture
  43755. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43756. * @param textures defines the textures to update
  43757. * @param samples defines the sample count to set
  43758. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43759. */
  43760. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43761. }
  43762. }
  43763. }
  43764. declare module "babylonjs/Engines/Extensions/index" {
  43765. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43766. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43767. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43768. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43769. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43770. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43771. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43772. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43773. }
  43774. declare module "babylonjs/Engines/index" {
  43775. export * from "babylonjs/Engines/constants";
  43776. export * from "babylonjs/Engines/engine";
  43777. export * from "babylonjs/Engines/engineStore";
  43778. export * from "babylonjs/Engines/nullEngine";
  43779. export * from "babylonjs/Engines/Extensions/index";
  43780. export * from "babylonjs/Engines/IPipelineContext";
  43781. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43782. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43783. }
  43784. declare module "babylonjs/Events/clipboardEvents" {
  43785. /**
  43786. * Gather the list of clipboard event types as constants.
  43787. */
  43788. export class ClipboardEventTypes {
  43789. /**
  43790. * The clipboard event is fired when a copy command is active (pressed).
  43791. */
  43792. static readonly COPY: number;
  43793. /**
  43794. * The clipboard event is fired when a cut command is active (pressed).
  43795. */
  43796. static readonly CUT: number;
  43797. /**
  43798. * The clipboard event is fired when a paste command is active (pressed).
  43799. */
  43800. static readonly PASTE: number;
  43801. }
  43802. /**
  43803. * This class is used to store clipboard related info for the onClipboardObservable event.
  43804. */
  43805. export class ClipboardInfo {
  43806. /**
  43807. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43808. */
  43809. type: number;
  43810. /**
  43811. * Defines the related dom event
  43812. */
  43813. event: ClipboardEvent;
  43814. /**
  43815. *Creates an instance of ClipboardInfo.
  43816. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43817. * @param event Defines the related dom event
  43818. */
  43819. constructor(
  43820. /**
  43821. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43822. */
  43823. type: number,
  43824. /**
  43825. * Defines the related dom event
  43826. */
  43827. event: ClipboardEvent);
  43828. /**
  43829. * Get the clipboard event's type from the keycode.
  43830. * @param keyCode Defines the keyCode for the current keyboard event.
  43831. * @return {number}
  43832. */
  43833. static GetTypeFromCharacter(keyCode: number): number;
  43834. }
  43835. }
  43836. declare module "babylonjs/Events/index" {
  43837. export * from "babylonjs/Events/keyboardEvents";
  43838. export * from "babylonjs/Events/pointerEvents";
  43839. export * from "babylonjs/Events/clipboardEvents";
  43840. }
  43841. declare module "babylonjs/Loading/sceneLoader" {
  43842. import { Observable } from "babylonjs/Misc/observable";
  43843. import { Nullable } from "babylonjs/types";
  43844. import { Scene } from "babylonjs/scene";
  43845. import { Engine } from "babylonjs/Engines/engine";
  43846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43847. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43848. import { AssetContainer } from "babylonjs/assetContainer";
  43849. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43850. import { Skeleton } from "babylonjs/Bones/skeleton";
  43851. /**
  43852. * Class used to represent data loading progression
  43853. */
  43854. export class SceneLoaderProgressEvent {
  43855. /** defines if data length to load can be evaluated */
  43856. readonly lengthComputable: boolean;
  43857. /** defines the loaded data length */
  43858. readonly loaded: number;
  43859. /** defines the data length to load */
  43860. readonly total: number;
  43861. /**
  43862. * Create a new progress event
  43863. * @param lengthComputable defines if data length to load can be evaluated
  43864. * @param loaded defines the loaded data length
  43865. * @param total defines the data length to load
  43866. */
  43867. constructor(
  43868. /** defines if data length to load can be evaluated */
  43869. lengthComputable: boolean,
  43870. /** defines the loaded data length */
  43871. loaded: number,
  43872. /** defines the data length to load */
  43873. total: number);
  43874. /**
  43875. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43876. * @param event defines the source event
  43877. * @returns a new SceneLoaderProgressEvent
  43878. */
  43879. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43880. }
  43881. /**
  43882. * Interface used by SceneLoader plugins to define supported file extensions
  43883. */
  43884. export interface ISceneLoaderPluginExtensions {
  43885. /**
  43886. * Defines the list of supported extensions
  43887. */
  43888. [extension: string]: {
  43889. isBinary: boolean;
  43890. };
  43891. }
  43892. /**
  43893. * Interface used by SceneLoader plugin factory
  43894. */
  43895. export interface ISceneLoaderPluginFactory {
  43896. /**
  43897. * Defines the name of the factory
  43898. */
  43899. name: string;
  43900. /**
  43901. * Function called to create a new plugin
  43902. * @return the new plugin
  43903. */
  43904. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43905. /**
  43906. * Boolean indicating if the plugin can direct load specific data
  43907. */
  43908. canDirectLoad?: (data: string) => boolean;
  43909. }
  43910. /**
  43911. * Interface used to define a SceneLoader plugin
  43912. */
  43913. export interface ISceneLoaderPlugin {
  43914. /**
  43915. * The friendly name of this plugin.
  43916. */
  43917. name: string;
  43918. /**
  43919. * The file extensions supported by this plugin.
  43920. */
  43921. extensions: string | ISceneLoaderPluginExtensions;
  43922. /**
  43923. * Import meshes into a scene.
  43924. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43925. * @param scene The scene to import into
  43926. * @param data The data to import
  43927. * @param rootUrl The root url for scene and resources
  43928. * @param meshes The meshes array to import into
  43929. * @param particleSystems The particle systems array to import into
  43930. * @param skeletons The skeletons array to import into
  43931. * @param onError The callback when import fails
  43932. * @returns True if successful or false otherwise
  43933. */
  43934. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43935. /**
  43936. * Load into a scene.
  43937. * @param scene The scene to load into
  43938. * @param data The data to import
  43939. * @param rootUrl The root url for scene and resources
  43940. * @param onError The callback when import fails
  43941. * @returns true if successful or false otherwise
  43942. */
  43943. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43944. /**
  43945. * The callback that returns true if the data can be directly loaded.
  43946. */
  43947. canDirectLoad?: (data: string) => boolean;
  43948. /**
  43949. * The callback that allows custom handling of the root url based on the response url.
  43950. */
  43951. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43952. /**
  43953. * Load into an asset container.
  43954. * @param scene The scene to load into
  43955. * @param data The data to import
  43956. * @param rootUrl The root url for scene and resources
  43957. * @param onError The callback when import fails
  43958. * @returns The loaded asset container
  43959. */
  43960. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43961. }
  43962. /**
  43963. * Interface used to define an async SceneLoader plugin
  43964. */
  43965. export interface ISceneLoaderPluginAsync {
  43966. /**
  43967. * The friendly name of this plugin.
  43968. */
  43969. name: string;
  43970. /**
  43971. * The file extensions supported by this plugin.
  43972. */
  43973. extensions: string | ISceneLoaderPluginExtensions;
  43974. /**
  43975. * Import meshes into a scene.
  43976. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43977. * @param scene The scene to import into
  43978. * @param data The data to import
  43979. * @param rootUrl The root url for scene and resources
  43980. * @param onProgress The callback when the load progresses
  43981. * @param fileName Defines the name of the file to load
  43982. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43983. */
  43984. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43985. meshes: AbstractMesh[];
  43986. particleSystems: IParticleSystem[];
  43987. skeletons: Skeleton[];
  43988. animationGroups: AnimationGroup[];
  43989. }>;
  43990. /**
  43991. * Load into a scene.
  43992. * @param scene The scene to load into
  43993. * @param data The data to import
  43994. * @param rootUrl The root url for scene and resources
  43995. * @param onProgress The callback when the load progresses
  43996. * @param fileName Defines the name of the file to load
  43997. * @returns Nothing
  43998. */
  43999. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44000. /**
  44001. * The callback that returns true if the data can be directly loaded.
  44002. */
  44003. canDirectLoad?: (data: string) => boolean;
  44004. /**
  44005. * The callback that allows custom handling of the root url based on the response url.
  44006. */
  44007. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44008. /**
  44009. * Load into an asset container.
  44010. * @param scene The scene to load into
  44011. * @param data The data to import
  44012. * @param rootUrl The root url for scene and resources
  44013. * @param onProgress The callback when the load progresses
  44014. * @param fileName Defines the name of the file to load
  44015. * @returns The loaded asset container
  44016. */
  44017. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44018. }
  44019. /**
  44020. * Class used to load scene from various file formats using registered plugins
  44021. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44022. */
  44023. export class SceneLoader {
  44024. /**
  44025. * No logging while loading
  44026. */
  44027. static readonly NO_LOGGING: number;
  44028. /**
  44029. * Minimal logging while loading
  44030. */
  44031. static readonly MINIMAL_LOGGING: number;
  44032. /**
  44033. * Summary logging while loading
  44034. */
  44035. static readonly SUMMARY_LOGGING: number;
  44036. /**
  44037. * Detailled logging while loading
  44038. */
  44039. static readonly DETAILED_LOGGING: number;
  44040. /**
  44041. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44042. */
  44043. static ForceFullSceneLoadingForIncremental: boolean;
  44044. /**
  44045. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44046. */
  44047. static ShowLoadingScreen: boolean;
  44048. /**
  44049. * Defines the current logging level (while loading the scene)
  44050. * @ignorenaming
  44051. */
  44052. static loggingLevel: number;
  44053. /**
  44054. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44055. */
  44056. static CleanBoneMatrixWeights: boolean;
  44057. /**
  44058. * Event raised when a plugin is used to load a scene
  44059. */
  44060. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44061. private static _registeredPlugins;
  44062. private static _getDefaultPlugin;
  44063. private static _getPluginForExtension;
  44064. private static _getPluginForDirectLoad;
  44065. private static _getPluginForFilename;
  44066. private static _getDirectLoad;
  44067. private static _loadData;
  44068. private static _getFileInfo;
  44069. /**
  44070. * Gets a plugin that can load the given extension
  44071. * @param extension defines the extension to load
  44072. * @returns a plugin or null if none works
  44073. */
  44074. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44075. /**
  44076. * Gets a boolean indicating that the given extension can be loaded
  44077. * @param extension defines the extension to load
  44078. * @returns true if the extension is supported
  44079. */
  44080. static IsPluginForExtensionAvailable(extension: string): boolean;
  44081. /**
  44082. * Adds a new plugin to the list of registered plugins
  44083. * @param plugin defines the plugin to add
  44084. */
  44085. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44086. /**
  44087. * Import meshes into a scene
  44088. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44089. * @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)
  44090. * @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)
  44091. * @param scene the instance of BABYLON.Scene to append to
  44092. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44093. * @param onProgress a callback with a progress event for each file being loaded
  44094. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44095. * @param pluginExtension the extension used to determine the plugin
  44096. * @returns The loaded plugin
  44097. */
  44098. 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>;
  44099. /**
  44100. * Import meshes into a scene
  44101. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44102. * @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)
  44103. * @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)
  44104. * @param scene the instance of BABYLON.Scene to append to
  44105. * @param onProgress a callback with a progress event for each file being loaded
  44106. * @param pluginExtension the extension used to determine the plugin
  44107. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44108. */
  44109. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44110. meshes: AbstractMesh[];
  44111. particleSystems: IParticleSystem[];
  44112. skeletons: Skeleton[];
  44113. animationGroups: AnimationGroup[];
  44114. }>;
  44115. /**
  44116. * Load a scene
  44117. * @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)
  44118. * @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)
  44119. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44120. * @param onSuccess a callback with the scene when import succeeds
  44121. * @param onProgress a callback with a progress event for each file being loaded
  44122. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44123. * @param pluginExtension the extension used to determine the plugin
  44124. * @returns The loaded plugin
  44125. */
  44126. 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>;
  44127. /**
  44128. * Load a scene
  44129. * @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)
  44130. * @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)
  44131. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44132. * @param onProgress a callback with a progress event for each file being loaded
  44133. * @param pluginExtension the extension used to determine the plugin
  44134. * @returns The loaded scene
  44135. */
  44136. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44137. /**
  44138. * Append a scene
  44139. * @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)
  44140. * @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)
  44141. * @param scene is the instance of BABYLON.Scene to append to
  44142. * @param onSuccess a callback with the scene when import succeeds
  44143. * @param onProgress a callback with a progress event for each file being loaded
  44144. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44145. * @param pluginExtension the extension used to determine the plugin
  44146. * @returns The loaded plugin
  44147. */
  44148. 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>;
  44149. /**
  44150. * Append a scene
  44151. * @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)
  44152. * @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)
  44153. * @param scene is the instance of BABYLON.Scene to append to
  44154. * @param onProgress a callback with a progress event for each file being loaded
  44155. * @param pluginExtension the extension used to determine the plugin
  44156. * @returns The given scene
  44157. */
  44158. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44159. /**
  44160. * Load a scene into an asset container
  44161. * @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)
  44162. * @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)
  44163. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44164. * @param onSuccess a callback with the scene when import succeeds
  44165. * @param onProgress a callback with a progress event for each file being loaded
  44166. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44167. * @param pluginExtension the extension used to determine the plugin
  44168. * @returns The loaded plugin
  44169. */
  44170. 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>;
  44171. /**
  44172. * Load a scene into an asset container
  44173. * @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)
  44174. * @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)
  44175. * @param scene is the instance of Scene to append to
  44176. * @param onProgress a callback with a progress event for each file being loaded
  44177. * @param pluginExtension the extension used to determine the plugin
  44178. * @returns The loaded asset container
  44179. */
  44180. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44181. }
  44182. }
  44183. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44184. import { Scene } from "babylonjs/scene";
  44185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44186. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44187. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44188. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44189. /**
  44190. * Google Daydream controller
  44191. */
  44192. export class DaydreamController extends WebVRController {
  44193. /**
  44194. * Base Url for the controller model.
  44195. */
  44196. static MODEL_BASE_URL: string;
  44197. /**
  44198. * File name for the controller model.
  44199. */
  44200. static MODEL_FILENAME: string;
  44201. /**
  44202. * Gamepad Id prefix used to identify Daydream Controller.
  44203. */
  44204. static readonly GAMEPAD_ID_PREFIX: string;
  44205. /**
  44206. * Creates a new DaydreamController from a gamepad
  44207. * @param vrGamepad the gamepad that the controller should be created from
  44208. */
  44209. constructor(vrGamepad: any);
  44210. /**
  44211. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44212. * @param scene scene in which to add meshes
  44213. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44214. */
  44215. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44216. /**
  44217. * Called once for each button that changed state since the last frame
  44218. * @param buttonIdx Which button index changed
  44219. * @param state New state of the button
  44220. * @param changes Which properties on the state changed since last frame
  44221. */
  44222. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44223. }
  44224. }
  44225. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44226. import { Scene } from "babylonjs/scene";
  44227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44228. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44229. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44230. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44231. /**
  44232. * Gear VR Controller
  44233. */
  44234. export class GearVRController extends WebVRController {
  44235. /**
  44236. * Base Url for the controller model.
  44237. */
  44238. static MODEL_BASE_URL: string;
  44239. /**
  44240. * File name for the controller model.
  44241. */
  44242. static MODEL_FILENAME: string;
  44243. /**
  44244. * Gamepad Id prefix used to identify this controller.
  44245. */
  44246. static readonly GAMEPAD_ID_PREFIX: string;
  44247. private readonly _buttonIndexToObservableNameMap;
  44248. /**
  44249. * Creates a new GearVRController from a gamepad
  44250. * @param vrGamepad the gamepad that the controller should be created from
  44251. */
  44252. constructor(vrGamepad: any);
  44253. /**
  44254. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44255. * @param scene scene in which to add meshes
  44256. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44257. */
  44258. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44259. /**
  44260. * Called once for each button that changed state since the last frame
  44261. * @param buttonIdx Which button index changed
  44262. * @param state New state of the button
  44263. * @param changes Which properties on the state changed since last frame
  44264. */
  44265. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44266. }
  44267. }
  44268. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44269. import { Scene } from "babylonjs/scene";
  44270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44271. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44272. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44273. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44274. /**
  44275. * Generic Controller
  44276. */
  44277. export class GenericController extends WebVRController {
  44278. /**
  44279. * Base Url for the controller model.
  44280. */
  44281. static readonly MODEL_BASE_URL: string;
  44282. /**
  44283. * File name for the controller model.
  44284. */
  44285. static readonly MODEL_FILENAME: string;
  44286. /**
  44287. * Creates a new GenericController from a gamepad
  44288. * @param vrGamepad the gamepad that the controller should be created from
  44289. */
  44290. constructor(vrGamepad: any);
  44291. /**
  44292. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44293. * @param scene scene in which to add meshes
  44294. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44295. */
  44296. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44297. /**
  44298. * Called once for each button that changed state since the last frame
  44299. * @param buttonIdx Which button index changed
  44300. * @param state New state of the button
  44301. * @param changes Which properties on the state changed since last frame
  44302. */
  44303. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44304. }
  44305. }
  44306. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44307. import { Observable } from "babylonjs/Misc/observable";
  44308. import { Scene } from "babylonjs/scene";
  44309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44310. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44311. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44312. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44313. /**
  44314. * Oculus Touch Controller
  44315. */
  44316. export class OculusTouchController extends WebVRController {
  44317. /**
  44318. * Base Url for the controller model.
  44319. */
  44320. static MODEL_BASE_URL: string;
  44321. /**
  44322. * File name for the left controller model.
  44323. */
  44324. static MODEL_LEFT_FILENAME: string;
  44325. /**
  44326. * File name for the right controller model.
  44327. */
  44328. static MODEL_RIGHT_FILENAME: string;
  44329. /**
  44330. * Fired when the secondary trigger on this controller is modified
  44331. */
  44332. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44333. /**
  44334. * Fired when the thumb rest on this controller is modified
  44335. */
  44336. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44337. /**
  44338. * Creates a new OculusTouchController from a gamepad
  44339. * @param vrGamepad the gamepad that the controller should be created from
  44340. */
  44341. constructor(vrGamepad: any);
  44342. /**
  44343. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44344. * @param scene scene in which to add meshes
  44345. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44346. */
  44347. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44348. /**
  44349. * Fired when the A button on this controller is modified
  44350. */
  44351. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44352. /**
  44353. * Fired when the B button on this controller is modified
  44354. */
  44355. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44356. /**
  44357. * Fired when the X button on this controller is modified
  44358. */
  44359. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44360. /**
  44361. * Fired when the Y button on this controller is modified
  44362. */
  44363. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44364. /**
  44365. * Called once for each button that changed state since the last frame
  44366. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44367. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44368. * 2) secondary trigger (same)
  44369. * 3) A (right) X (left), touch, pressed = value
  44370. * 4) B / Y
  44371. * 5) thumb rest
  44372. * @param buttonIdx Which button index changed
  44373. * @param state New state of the button
  44374. * @param changes Which properties on the state changed since last frame
  44375. */
  44376. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44377. }
  44378. }
  44379. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44380. import { Scene } from "babylonjs/scene";
  44381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44382. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44383. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44384. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44385. import { Observable } from "babylonjs/Misc/observable";
  44386. /**
  44387. * Vive Controller
  44388. */
  44389. export class ViveController extends WebVRController {
  44390. /**
  44391. * Base Url for the controller model.
  44392. */
  44393. static MODEL_BASE_URL: string;
  44394. /**
  44395. * File name for the controller model.
  44396. */
  44397. static MODEL_FILENAME: string;
  44398. /**
  44399. * Creates a new ViveController from a gamepad
  44400. * @param vrGamepad the gamepad that the controller should be created from
  44401. */
  44402. constructor(vrGamepad: any);
  44403. /**
  44404. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44405. * @param scene scene in which to add meshes
  44406. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44407. */
  44408. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44409. /**
  44410. * Fired when the left button on this controller is modified
  44411. */
  44412. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44413. /**
  44414. * Fired when the right button on this controller is modified
  44415. */
  44416. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44417. /**
  44418. * Fired when the menu button on this controller is modified
  44419. */
  44420. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44421. /**
  44422. * Called once for each button that changed state since the last frame
  44423. * Vive mapping:
  44424. * 0: touchpad
  44425. * 1: trigger
  44426. * 2: left AND right buttons
  44427. * 3: menu button
  44428. * @param buttonIdx Which button index changed
  44429. * @param state New state of the button
  44430. * @param changes Which properties on the state changed since last frame
  44431. */
  44432. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44433. }
  44434. }
  44435. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44436. import { Observable } from "babylonjs/Misc/observable";
  44437. import { Scene } from "babylonjs/scene";
  44438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44439. import { Ray } from "babylonjs/Culling/ray";
  44440. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44441. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44442. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44443. /**
  44444. * Defines the WindowsMotionController object that the state of the windows motion controller
  44445. */
  44446. export class WindowsMotionController extends WebVRController {
  44447. /**
  44448. * The base url used to load the left and right controller models
  44449. */
  44450. static MODEL_BASE_URL: string;
  44451. /**
  44452. * The name of the left controller model file
  44453. */
  44454. static MODEL_LEFT_FILENAME: string;
  44455. /**
  44456. * The name of the right controller model file
  44457. */
  44458. static MODEL_RIGHT_FILENAME: string;
  44459. /**
  44460. * The controller name prefix for this controller type
  44461. */
  44462. static readonly GAMEPAD_ID_PREFIX: string;
  44463. /**
  44464. * The controller id pattern for this controller type
  44465. */
  44466. private static readonly GAMEPAD_ID_PATTERN;
  44467. private _loadedMeshInfo;
  44468. private readonly _mapping;
  44469. /**
  44470. * Fired when the trackpad on this controller is clicked
  44471. */
  44472. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44473. /**
  44474. * Fired when the trackpad on this controller is modified
  44475. */
  44476. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44477. /**
  44478. * The current x and y values of this controller's trackpad
  44479. */
  44480. trackpad: StickValues;
  44481. /**
  44482. * Creates a new WindowsMotionController from a gamepad
  44483. * @param vrGamepad the gamepad that the controller should be created from
  44484. */
  44485. constructor(vrGamepad: any);
  44486. /**
  44487. * Fired when the trigger on this controller is modified
  44488. */
  44489. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44490. /**
  44491. * Fired when the menu button on this controller is modified
  44492. */
  44493. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44494. /**
  44495. * Fired when the grip button on this controller is modified
  44496. */
  44497. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44498. /**
  44499. * Fired when the thumbstick button on this controller is modified
  44500. */
  44501. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44502. /**
  44503. * Fired when the touchpad button on this controller is modified
  44504. */
  44505. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44506. /**
  44507. * Fired when the touchpad values on this controller are modified
  44508. */
  44509. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44510. private _updateTrackpad;
  44511. /**
  44512. * Called once per frame by the engine.
  44513. */
  44514. update(): void;
  44515. /**
  44516. * Called once for each button that changed state since the last frame
  44517. * @param buttonIdx Which button index changed
  44518. * @param state New state of the button
  44519. * @param changes Which properties on the state changed since last frame
  44520. */
  44521. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44522. /**
  44523. * Moves the buttons on the controller mesh based on their current state
  44524. * @param buttonName the name of the button to move
  44525. * @param buttonValue the value of the button which determines the buttons new position
  44526. */
  44527. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44528. /**
  44529. * Moves the axis on the controller mesh based on its current state
  44530. * @param axis the index of the axis
  44531. * @param axisValue the value of the axis which determines the meshes new position
  44532. * @hidden
  44533. */
  44534. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44535. /**
  44536. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44537. * @param scene scene in which to add meshes
  44538. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44539. */
  44540. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44541. /**
  44542. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44543. * can be transformed by button presses and axes values, based on this._mapping.
  44544. *
  44545. * @param scene scene in which the meshes exist
  44546. * @param meshes list of meshes that make up the controller model to process
  44547. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44548. */
  44549. private processModel;
  44550. private createMeshInfo;
  44551. /**
  44552. * Gets the ray of the controller in the direction the controller is pointing
  44553. * @param length the length the resulting ray should be
  44554. * @returns a ray in the direction the controller is pointing
  44555. */
  44556. getForwardRay(length?: number): Ray;
  44557. /**
  44558. * Disposes of the controller
  44559. */
  44560. dispose(): void;
  44561. }
  44562. }
  44563. declare module "babylonjs/Gamepads/Controllers/index" {
  44564. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44565. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44566. export * from "babylonjs/Gamepads/Controllers/genericController";
  44567. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44568. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44569. export * from "babylonjs/Gamepads/Controllers/viveController";
  44570. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44571. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44572. }
  44573. declare module "babylonjs/Gamepads/index" {
  44574. export * from "babylonjs/Gamepads/Controllers/index";
  44575. export * from "babylonjs/Gamepads/gamepad";
  44576. export * from "babylonjs/Gamepads/gamepadManager";
  44577. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44578. export * from "babylonjs/Gamepads/xboxGamepad";
  44579. }
  44580. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44581. import { Scene } from "babylonjs/scene";
  44582. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44583. import { Mesh } from "babylonjs/Meshes/mesh";
  44584. import { Nullable } from "babylonjs/types";
  44585. /**
  44586. * Class containing static functions to help procedurally build meshes
  44587. */
  44588. export class PolyhedronBuilder {
  44589. /**
  44590. * Creates a polyhedron mesh
  44591. * * 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
  44592. * * The parameter `size` (positive float, default 1) sets the polygon size
  44593. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44594. * * 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`
  44595. * * 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
  44596. * * 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)`)
  44597. * * 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
  44598. * * 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
  44599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44602. * @param name defines the name of the mesh
  44603. * @param options defines the options used to create the mesh
  44604. * @param scene defines the hosting scene
  44605. * @returns the polyhedron mesh
  44606. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44607. */
  44608. static CreatePolyhedron(name: string, options: {
  44609. type?: number;
  44610. size?: number;
  44611. sizeX?: number;
  44612. sizeY?: number;
  44613. sizeZ?: number;
  44614. custom?: any;
  44615. faceUV?: Vector4[];
  44616. faceColors?: Color4[];
  44617. flat?: boolean;
  44618. updatable?: boolean;
  44619. sideOrientation?: number;
  44620. frontUVs?: Vector4;
  44621. backUVs?: Vector4;
  44622. }, scene?: Nullable<Scene>): Mesh;
  44623. }
  44624. }
  44625. declare module "babylonjs/Gizmos/scaleGizmo" {
  44626. import { Observable } from "babylonjs/Misc/observable";
  44627. import { Nullable } from "babylonjs/types";
  44628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44629. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44630. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44631. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44632. /**
  44633. * Gizmo that enables scaling a mesh along 3 axis
  44634. */
  44635. export class ScaleGizmo extends Gizmo {
  44636. /**
  44637. * Internal gizmo used for interactions on the x axis
  44638. */
  44639. xGizmo: AxisScaleGizmo;
  44640. /**
  44641. * Internal gizmo used for interactions on the y axis
  44642. */
  44643. yGizmo: AxisScaleGizmo;
  44644. /**
  44645. * Internal gizmo used for interactions on the z axis
  44646. */
  44647. zGizmo: AxisScaleGizmo;
  44648. /**
  44649. * Internal gizmo used to scale all axis equally
  44650. */
  44651. uniformScaleGizmo: AxisScaleGizmo;
  44652. private _meshAttached;
  44653. private _updateGizmoRotationToMatchAttachedMesh;
  44654. private _snapDistance;
  44655. private _scaleRatio;
  44656. private _uniformScalingMesh;
  44657. private _octahedron;
  44658. /** Fires an event when any of it's sub gizmos are dragged */
  44659. onDragStartObservable: Observable<{}>;
  44660. /** Fires an event when any of it's sub gizmos are released from dragging */
  44661. onDragEndObservable: Observable<{}>;
  44662. attachedMesh: Nullable<AbstractMesh>;
  44663. /**
  44664. * Creates a ScaleGizmo
  44665. * @param gizmoLayer The utility layer the gizmo will be added to
  44666. */
  44667. constructor(gizmoLayer?: UtilityLayerRenderer);
  44668. updateGizmoRotationToMatchAttachedMesh: boolean;
  44669. /**
  44670. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44671. */
  44672. snapDistance: number;
  44673. /**
  44674. * Ratio for the scale of the gizmo (Default: 1)
  44675. */
  44676. scaleRatio: number;
  44677. /**
  44678. * Disposes of the gizmo
  44679. */
  44680. dispose(): void;
  44681. }
  44682. }
  44683. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44684. import { Observable } from "babylonjs/Misc/observable";
  44685. import { Nullable } from "babylonjs/types";
  44686. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44688. import { Mesh } from "babylonjs/Meshes/mesh";
  44689. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44690. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44691. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44692. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44693. /**
  44694. * Single axis scale gizmo
  44695. */
  44696. export class AxisScaleGizmo extends Gizmo {
  44697. /**
  44698. * Drag behavior responsible for the gizmos dragging interactions
  44699. */
  44700. dragBehavior: PointerDragBehavior;
  44701. private _pointerObserver;
  44702. /**
  44703. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44704. */
  44705. snapDistance: number;
  44706. /**
  44707. * Event that fires each time the gizmo snaps to a new location.
  44708. * * snapDistance is the the change in distance
  44709. */
  44710. onSnapObservable: Observable<{
  44711. snapDistance: number;
  44712. }>;
  44713. /**
  44714. * If the scaling operation should be done on all axis (default: false)
  44715. */
  44716. uniformScaling: boolean;
  44717. private _isEnabled;
  44718. private _parent;
  44719. private _arrow;
  44720. private _coloredMaterial;
  44721. private _hoverMaterial;
  44722. /**
  44723. * Creates an AxisScaleGizmo
  44724. * @param gizmoLayer The utility layer the gizmo will be added to
  44725. * @param dragAxis The axis which the gizmo will be able to scale on
  44726. * @param color The color of the gizmo
  44727. */
  44728. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44729. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44730. /**
  44731. * If the gizmo is enabled
  44732. */
  44733. isEnabled: boolean;
  44734. /**
  44735. * Disposes of the gizmo
  44736. */
  44737. dispose(): void;
  44738. /**
  44739. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44740. * @param mesh The mesh to replace the default mesh of the gizmo
  44741. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44742. */
  44743. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44744. }
  44745. }
  44746. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44747. import { Observable } from "babylonjs/Misc/observable";
  44748. import { Nullable } from "babylonjs/types";
  44749. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44751. import { Mesh } from "babylonjs/Meshes/mesh";
  44752. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44753. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44754. import "babylonjs/Meshes/Builders/boxBuilder";
  44755. /**
  44756. * Bounding box gizmo
  44757. */
  44758. export class BoundingBoxGizmo extends Gizmo {
  44759. private _lineBoundingBox;
  44760. private _rotateSpheresParent;
  44761. private _scaleBoxesParent;
  44762. private _boundingDimensions;
  44763. private _renderObserver;
  44764. private _pointerObserver;
  44765. private _scaleDragSpeed;
  44766. private _tmpQuaternion;
  44767. private _tmpVector;
  44768. private _tmpRotationMatrix;
  44769. /**
  44770. * 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)
  44771. */
  44772. ignoreChildren: boolean;
  44773. /**
  44774. * 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)
  44775. */
  44776. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44777. /**
  44778. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44779. */
  44780. rotationSphereSize: number;
  44781. /**
  44782. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44783. */
  44784. scaleBoxSize: number;
  44785. /**
  44786. * 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)
  44787. */
  44788. fixedDragMeshScreenSize: boolean;
  44789. /**
  44790. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44791. */
  44792. fixedDragMeshScreenSizeDistanceFactor: number;
  44793. /**
  44794. * Fired when a rotation sphere or scale box is dragged
  44795. */
  44796. onDragStartObservable: Observable<{}>;
  44797. /**
  44798. * Fired when a scale box is dragged
  44799. */
  44800. onScaleBoxDragObservable: Observable<{}>;
  44801. /**
  44802. * Fired when a scale box drag is ended
  44803. */
  44804. onScaleBoxDragEndObservable: Observable<{}>;
  44805. /**
  44806. * Fired when a rotation sphere is dragged
  44807. */
  44808. onRotationSphereDragObservable: Observable<{}>;
  44809. /**
  44810. * Fired when a rotation sphere drag is ended
  44811. */
  44812. onRotationSphereDragEndObservable: Observable<{}>;
  44813. /**
  44814. * 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)
  44815. */
  44816. scalePivot: Nullable<Vector3>;
  44817. /**
  44818. * Mesh used as a pivot to rotate the attached mesh
  44819. */
  44820. private _anchorMesh;
  44821. private _existingMeshScale;
  44822. private _dragMesh;
  44823. private pointerDragBehavior;
  44824. private coloredMaterial;
  44825. private hoverColoredMaterial;
  44826. /**
  44827. * Sets the color of the bounding box gizmo
  44828. * @param color the color to set
  44829. */
  44830. setColor(color: Color3): void;
  44831. /**
  44832. * Creates an BoundingBoxGizmo
  44833. * @param gizmoLayer The utility layer the gizmo will be added to
  44834. * @param color The color of the gizmo
  44835. */
  44836. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44837. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44838. private _selectNode;
  44839. /**
  44840. * Updates the bounding box information for the Gizmo
  44841. */
  44842. updateBoundingBox(): void;
  44843. private _updateRotationSpheres;
  44844. private _updateScaleBoxes;
  44845. /**
  44846. * Enables rotation on the specified axis and disables rotation on the others
  44847. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44848. */
  44849. setEnabledRotationAxis(axis: string): void;
  44850. /**
  44851. * Enables/disables scaling
  44852. * @param enable if scaling should be enabled
  44853. */
  44854. setEnabledScaling(enable: boolean): void;
  44855. private _updateDummy;
  44856. /**
  44857. * Enables a pointer drag behavior on the bounding box of the gizmo
  44858. */
  44859. enableDragBehavior(): void;
  44860. /**
  44861. * Disposes of the gizmo
  44862. */
  44863. dispose(): void;
  44864. /**
  44865. * 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)
  44866. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44867. * @returns the bounding box mesh with the passed in mesh as a child
  44868. */
  44869. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44870. /**
  44871. * CustomMeshes are not supported by this gizmo
  44872. * @param mesh The mesh to replace the default mesh of the gizmo
  44873. */
  44874. setCustomMesh(mesh: Mesh): void;
  44875. }
  44876. }
  44877. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44878. import { Observable } from "babylonjs/Misc/observable";
  44879. import { Nullable } from "babylonjs/types";
  44880. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44882. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44883. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44884. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44885. import "babylonjs/Meshes/Builders/linesBuilder";
  44886. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44887. /**
  44888. * Single plane rotation gizmo
  44889. */
  44890. export class PlaneRotationGizmo extends Gizmo {
  44891. /**
  44892. * Drag behavior responsible for the gizmos dragging interactions
  44893. */
  44894. dragBehavior: PointerDragBehavior;
  44895. private _pointerObserver;
  44896. /**
  44897. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44898. */
  44899. snapDistance: number;
  44900. /**
  44901. * Event that fires each time the gizmo snaps to a new location.
  44902. * * snapDistance is the the change in distance
  44903. */
  44904. onSnapObservable: Observable<{
  44905. snapDistance: number;
  44906. }>;
  44907. private _isEnabled;
  44908. private _parent;
  44909. /**
  44910. * Creates a PlaneRotationGizmo
  44911. * @param gizmoLayer The utility layer the gizmo will be added to
  44912. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44913. * @param color The color of the gizmo
  44914. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44915. */
  44916. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  44917. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44918. /**
  44919. * If the gizmo is enabled
  44920. */
  44921. isEnabled: boolean;
  44922. /**
  44923. * Disposes of the gizmo
  44924. */
  44925. dispose(): void;
  44926. }
  44927. }
  44928. declare module "babylonjs/Gizmos/rotationGizmo" {
  44929. import { Observable } from "babylonjs/Misc/observable";
  44930. import { Nullable } from "babylonjs/types";
  44931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44932. import { Mesh } from "babylonjs/Meshes/mesh";
  44933. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44934. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44935. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44936. /**
  44937. * Gizmo that enables rotating a mesh along 3 axis
  44938. */
  44939. export class RotationGizmo extends Gizmo {
  44940. /**
  44941. * Internal gizmo used for interactions on the x axis
  44942. */
  44943. xGizmo: PlaneRotationGizmo;
  44944. /**
  44945. * Internal gizmo used for interactions on the y axis
  44946. */
  44947. yGizmo: PlaneRotationGizmo;
  44948. /**
  44949. * Internal gizmo used for interactions on the z axis
  44950. */
  44951. zGizmo: PlaneRotationGizmo;
  44952. /** Fires an event when any of it's sub gizmos are dragged */
  44953. onDragStartObservable: Observable<{}>;
  44954. /** Fires an event when any of it's sub gizmos are released from dragging */
  44955. onDragEndObservable: Observable<{}>;
  44956. private _meshAttached;
  44957. attachedMesh: Nullable<AbstractMesh>;
  44958. /**
  44959. * Creates a RotationGizmo
  44960. * @param gizmoLayer The utility layer the gizmo will be added to
  44961. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44962. */
  44963. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44964. updateGizmoRotationToMatchAttachedMesh: boolean;
  44965. /**
  44966. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44967. */
  44968. snapDistance: number;
  44969. /**
  44970. * Ratio for the scale of the gizmo (Default: 1)
  44971. */
  44972. scaleRatio: number;
  44973. /**
  44974. * Disposes of the gizmo
  44975. */
  44976. dispose(): void;
  44977. /**
  44978. * CustomMeshes are not supported by this gizmo
  44979. * @param mesh The mesh to replace the default mesh of the gizmo
  44980. */
  44981. setCustomMesh(mesh: Mesh): void;
  44982. }
  44983. }
  44984. declare module "babylonjs/Gizmos/gizmoManager" {
  44985. import { Observable } from "babylonjs/Misc/observable";
  44986. import { Nullable } from "babylonjs/types";
  44987. import { Scene, IDisposable } from "babylonjs/scene";
  44988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44989. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44990. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44991. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44992. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44993. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44994. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44995. /**
  44996. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44997. */
  44998. export class GizmoManager implements IDisposable {
  44999. private scene;
  45000. /**
  45001. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45002. */
  45003. gizmos: {
  45004. positionGizmo: Nullable<PositionGizmo>;
  45005. rotationGizmo: Nullable<RotationGizmo>;
  45006. scaleGizmo: Nullable<ScaleGizmo>;
  45007. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45008. };
  45009. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45010. clearGizmoOnEmptyPointerEvent: boolean;
  45011. /** Fires an event when the manager is attached to a mesh */
  45012. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45013. private _gizmosEnabled;
  45014. private _pointerObserver;
  45015. private _attachedMesh;
  45016. private _boundingBoxColor;
  45017. private _defaultUtilityLayer;
  45018. private _defaultKeepDepthUtilityLayer;
  45019. /**
  45020. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45021. */
  45022. boundingBoxDragBehavior: SixDofDragBehavior;
  45023. /**
  45024. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45025. */
  45026. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45027. /**
  45028. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45029. */
  45030. usePointerToAttachGizmos: boolean;
  45031. /**
  45032. * Utility layer that the bounding box gizmo belongs to
  45033. */
  45034. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45035. /**
  45036. * Utility layer that all gizmos besides bounding box belong to
  45037. */
  45038. readonly utilityLayer: UtilityLayerRenderer;
  45039. /**
  45040. * Instatiates a gizmo manager
  45041. * @param scene the scene to overlay the gizmos on top of
  45042. */
  45043. constructor(scene: Scene);
  45044. /**
  45045. * Attaches a set of gizmos to the specified mesh
  45046. * @param mesh The mesh the gizmo's should be attached to
  45047. */
  45048. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45049. /**
  45050. * If the position gizmo is enabled
  45051. */
  45052. positionGizmoEnabled: boolean;
  45053. /**
  45054. * If the rotation gizmo is enabled
  45055. */
  45056. rotationGizmoEnabled: boolean;
  45057. /**
  45058. * If the scale gizmo is enabled
  45059. */
  45060. scaleGizmoEnabled: boolean;
  45061. /**
  45062. * If the boundingBox gizmo is enabled
  45063. */
  45064. boundingBoxGizmoEnabled: boolean;
  45065. /**
  45066. * Disposes of the gizmo manager
  45067. */
  45068. dispose(): void;
  45069. }
  45070. }
  45071. declare module "babylonjs/Lights/directionalLight" {
  45072. import { Camera } from "babylonjs/Cameras/camera";
  45073. import { Scene } from "babylonjs/scene";
  45074. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45076. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45077. import { Effect } from "babylonjs/Materials/effect";
  45078. /**
  45079. * A directional light is defined by a direction (what a surprise!).
  45080. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45081. * 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.
  45082. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45083. */
  45084. export class DirectionalLight extends ShadowLight {
  45085. private _shadowFrustumSize;
  45086. /**
  45087. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45088. */
  45089. /**
  45090. * Specifies a fix frustum size for the shadow generation.
  45091. */
  45092. shadowFrustumSize: number;
  45093. private _shadowOrthoScale;
  45094. /**
  45095. * Gets the shadow projection scale against the optimal computed one.
  45096. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45097. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45098. */
  45099. /**
  45100. * Sets the shadow projection scale against the optimal computed one.
  45101. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45102. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45103. */
  45104. shadowOrthoScale: number;
  45105. /**
  45106. * Automatically compute the projection matrix to best fit (including all the casters)
  45107. * on each frame.
  45108. */
  45109. autoUpdateExtends: boolean;
  45110. private _orthoLeft;
  45111. private _orthoRight;
  45112. private _orthoTop;
  45113. private _orthoBottom;
  45114. /**
  45115. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45116. * The directional light is emitted from everywhere in the given direction.
  45117. * It can cast shadows.
  45118. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45119. * @param name The friendly name of the light
  45120. * @param direction The direction of the light
  45121. * @param scene The scene the light belongs to
  45122. */
  45123. constructor(name: string, direction: Vector3, scene: Scene);
  45124. /**
  45125. * Returns the string "DirectionalLight".
  45126. * @return The class name
  45127. */
  45128. getClassName(): string;
  45129. /**
  45130. * Returns the integer 1.
  45131. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45132. */
  45133. getTypeID(): number;
  45134. /**
  45135. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45136. * Returns the DirectionalLight Shadow projection matrix.
  45137. */
  45138. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45139. /**
  45140. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45141. * Returns the DirectionalLight Shadow projection matrix.
  45142. */
  45143. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45144. /**
  45145. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45146. * Returns the DirectionalLight Shadow projection matrix.
  45147. */
  45148. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45149. protected _buildUniformLayout(): void;
  45150. /**
  45151. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45152. * @param effect The effect to update
  45153. * @param lightIndex The index of the light in the effect to update
  45154. * @returns The directional light
  45155. */
  45156. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45157. /**
  45158. * Gets the minZ used for shadow according to both the scene and the light.
  45159. *
  45160. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45161. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45162. * @param activeCamera The camera we are returning the min for
  45163. * @returns the depth min z
  45164. */
  45165. getDepthMinZ(activeCamera: Camera): number;
  45166. /**
  45167. * Gets the maxZ used for shadow according to both the scene and the light.
  45168. *
  45169. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45170. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45171. * @param activeCamera The camera we are returning the max for
  45172. * @returns the depth max z
  45173. */
  45174. getDepthMaxZ(activeCamera: Camera): number;
  45175. /**
  45176. * Prepares the list of defines specific to the light type.
  45177. * @param defines the list of defines
  45178. * @param lightIndex defines the index of the light for the effect
  45179. */
  45180. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45181. }
  45182. }
  45183. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45184. import { Mesh } from "babylonjs/Meshes/mesh";
  45185. /**
  45186. * Class containing static functions to help procedurally build meshes
  45187. */
  45188. export class HemisphereBuilder {
  45189. /**
  45190. * Creates a hemisphere mesh
  45191. * @param name defines the name of the mesh
  45192. * @param options defines the options used to create the mesh
  45193. * @param scene defines the hosting scene
  45194. * @returns the hemisphere mesh
  45195. */
  45196. static CreateHemisphere(name: string, options: {
  45197. segments?: number;
  45198. diameter?: number;
  45199. sideOrientation?: number;
  45200. }, scene: any): Mesh;
  45201. }
  45202. }
  45203. declare module "babylonjs/Lights/spotLight" {
  45204. import { Nullable } from "babylonjs/types";
  45205. import { Scene } from "babylonjs/scene";
  45206. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45208. import { Effect } from "babylonjs/Materials/effect";
  45209. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45210. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45211. /**
  45212. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45213. * These values define a cone of light starting from the position, emitting toward the direction.
  45214. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45215. * and the exponent defines the speed of the decay of the light with distance (reach).
  45216. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45217. */
  45218. export class SpotLight extends ShadowLight {
  45219. private _angle;
  45220. private _innerAngle;
  45221. private _cosHalfAngle;
  45222. private _lightAngleScale;
  45223. private _lightAngleOffset;
  45224. /**
  45225. * Gets the cone angle of the spot light in Radians.
  45226. */
  45227. /**
  45228. * Sets the cone angle of the spot light in Radians.
  45229. */
  45230. angle: number;
  45231. /**
  45232. * Only used in gltf falloff mode, this defines the angle where
  45233. * the directional falloff will start before cutting at angle which could be seen
  45234. * as outer angle.
  45235. */
  45236. /**
  45237. * Only used in gltf falloff mode, this defines the angle where
  45238. * the directional falloff will start before cutting at angle which could be seen
  45239. * as outer angle.
  45240. */
  45241. innerAngle: number;
  45242. private _shadowAngleScale;
  45243. /**
  45244. * Allows scaling the angle of the light for shadow generation only.
  45245. */
  45246. /**
  45247. * Allows scaling the angle of the light for shadow generation only.
  45248. */
  45249. shadowAngleScale: number;
  45250. /**
  45251. * The light decay speed with the distance from the emission spot.
  45252. */
  45253. exponent: number;
  45254. private _projectionTextureMatrix;
  45255. /**
  45256. * Allows reading the projecton texture
  45257. */
  45258. readonly projectionTextureMatrix: Matrix;
  45259. protected _projectionTextureLightNear: number;
  45260. /**
  45261. * Gets the near clip of the Spotlight for texture projection.
  45262. */
  45263. /**
  45264. * Sets the near clip of the Spotlight for texture projection.
  45265. */
  45266. projectionTextureLightNear: number;
  45267. protected _projectionTextureLightFar: number;
  45268. /**
  45269. * Gets the far clip of the Spotlight for texture projection.
  45270. */
  45271. /**
  45272. * Sets the far clip of the Spotlight for texture projection.
  45273. */
  45274. projectionTextureLightFar: number;
  45275. protected _projectionTextureUpDirection: Vector3;
  45276. /**
  45277. * Gets the Up vector of the Spotlight for texture projection.
  45278. */
  45279. /**
  45280. * Sets the Up vector of the Spotlight for texture projection.
  45281. */
  45282. projectionTextureUpDirection: Vector3;
  45283. private _projectionTexture;
  45284. /**
  45285. * Gets the projection texture of the light.
  45286. */
  45287. /**
  45288. * Sets the projection texture of the light.
  45289. */
  45290. projectionTexture: Nullable<BaseTexture>;
  45291. private _projectionTextureViewLightDirty;
  45292. private _projectionTextureProjectionLightDirty;
  45293. private _projectionTextureDirty;
  45294. private _projectionTextureViewTargetVector;
  45295. private _projectionTextureViewLightMatrix;
  45296. private _projectionTextureProjectionLightMatrix;
  45297. private _projectionTextureScalingMatrix;
  45298. /**
  45299. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45300. * It can cast shadows.
  45301. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45302. * @param name The light friendly name
  45303. * @param position The position of the spot light in the scene
  45304. * @param direction The direction of the light in the scene
  45305. * @param angle The cone angle of the light in Radians
  45306. * @param exponent The light decay speed with the distance from the emission spot
  45307. * @param scene The scene the lights belongs to
  45308. */
  45309. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45310. /**
  45311. * Returns the string "SpotLight".
  45312. * @returns the class name
  45313. */
  45314. getClassName(): string;
  45315. /**
  45316. * Returns the integer 2.
  45317. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45318. */
  45319. getTypeID(): number;
  45320. /**
  45321. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45322. */
  45323. protected _setDirection(value: Vector3): void;
  45324. /**
  45325. * Overrides the position setter to recompute the projection texture view light Matrix.
  45326. */
  45327. protected _setPosition(value: Vector3): void;
  45328. /**
  45329. * 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.
  45330. * Returns the SpotLight.
  45331. */
  45332. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45333. protected _computeProjectionTextureViewLightMatrix(): void;
  45334. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45335. /**
  45336. * Main function for light texture projection matrix computing.
  45337. */
  45338. protected _computeProjectionTextureMatrix(): void;
  45339. protected _buildUniformLayout(): void;
  45340. private _computeAngleValues;
  45341. /**
  45342. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45343. * @param effect The effect to update
  45344. * @param lightIndex The index of the light in the effect to update
  45345. * @returns The spot light
  45346. */
  45347. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45348. /**
  45349. * Disposes the light and the associated resources.
  45350. */
  45351. dispose(): void;
  45352. /**
  45353. * Prepares the list of defines specific to the light type.
  45354. * @param defines the list of defines
  45355. * @param lightIndex defines the index of the light for the effect
  45356. */
  45357. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45358. }
  45359. }
  45360. declare module "babylonjs/Gizmos/lightGizmo" {
  45361. import { Nullable } from "babylonjs/types";
  45362. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45363. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45364. import { Light } from "babylonjs/Lights/light";
  45365. /**
  45366. * Gizmo that enables viewing a light
  45367. */
  45368. export class LightGizmo extends Gizmo {
  45369. private _lightMesh;
  45370. private _material;
  45371. private cachedPosition;
  45372. private cachedForward;
  45373. /**
  45374. * Creates a LightGizmo
  45375. * @param gizmoLayer The utility layer the gizmo will be added to
  45376. */
  45377. constructor(gizmoLayer?: UtilityLayerRenderer);
  45378. private _light;
  45379. /**
  45380. * The light that the gizmo is attached to
  45381. */
  45382. light: Nullable<Light>;
  45383. /**
  45384. * @hidden
  45385. * Updates the gizmo to match the attached mesh's position/rotation
  45386. */
  45387. protected _update(): void;
  45388. private static _Scale;
  45389. /**
  45390. * Creates the lines for a light mesh
  45391. */
  45392. private static _createLightLines;
  45393. /**
  45394. * Disposes of the light gizmo
  45395. */
  45396. dispose(): void;
  45397. private static _CreateHemisphericLightMesh;
  45398. private static _CreatePointLightMesh;
  45399. private static _CreateSpotLightMesh;
  45400. private static _CreateDirectionalLightMesh;
  45401. }
  45402. }
  45403. declare module "babylonjs/Gizmos/index" {
  45404. export * from "babylonjs/Gizmos/axisDragGizmo";
  45405. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45406. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45407. export * from "babylonjs/Gizmos/gizmo";
  45408. export * from "babylonjs/Gizmos/gizmoManager";
  45409. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45410. export * from "babylonjs/Gizmos/positionGizmo";
  45411. export * from "babylonjs/Gizmos/rotationGizmo";
  45412. export * from "babylonjs/Gizmos/scaleGizmo";
  45413. export * from "babylonjs/Gizmos/lightGizmo";
  45414. }
  45415. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45416. /** @hidden */
  45417. export var backgroundFragmentDeclaration: {
  45418. name: string;
  45419. shader: string;
  45420. };
  45421. }
  45422. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45423. /** @hidden */
  45424. export var backgroundUboDeclaration: {
  45425. name: string;
  45426. shader: string;
  45427. };
  45428. }
  45429. declare module "babylonjs/Shaders/background.fragment" {
  45430. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45431. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45432. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45433. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45434. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45435. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45436. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45437. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45438. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45439. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45440. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45441. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45442. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45443. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45444. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45445. /** @hidden */
  45446. export var backgroundPixelShader: {
  45447. name: string;
  45448. shader: string;
  45449. };
  45450. }
  45451. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45452. /** @hidden */
  45453. export var backgroundVertexDeclaration: {
  45454. name: string;
  45455. shader: string;
  45456. };
  45457. }
  45458. declare module "babylonjs/Shaders/background.vertex" {
  45459. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45460. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45461. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45462. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45463. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45465. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45466. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45467. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45468. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45469. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45471. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45472. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45473. /** @hidden */
  45474. export var backgroundVertexShader: {
  45475. name: string;
  45476. shader: string;
  45477. };
  45478. }
  45479. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45480. import { Nullable, int, float } from "babylonjs/types";
  45481. import { Scene } from "babylonjs/scene";
  45482. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45483. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45485. import { Mesh } from "babylonjs/Meshes/mesh";
  45486. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45487. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45488. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45490. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45491. import "babylonjs/Shaders/background.fragment";
  45492. import "babylonjs/Shaders/background.vertex";
  45493. /**
  45494. * Background material used to create an efficient environement around your scene.
  45495. */
  45496. export class BackgroundMaterial extends PushMaterial {
  45497. /**
  45498. * Standard reflectance value at parallel view angle.
  45499. */
  45500. static StandardReflectance0: number;
  45501. /**
  45502. * Standard reflectance value at grazing angle.
  45503. */
  45504. static StandardReflectance90: number;
  45505. protected _primaryColor: Color3;
  45506. /**
  45507. * Key light Color (multiply against the environement texture)
  45508. */
  45509. primaryColor: Color3;
  45510. protected __perceptualColor: Nullable<Color3>;
  45511. /**
  45512. * Experimental Internal Use Only.
  45513. *
  45514. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45515. * This acts as a helper to set the primary color to a more "human friendly" value.
  45516. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45517. * output color as close as possible from the chosen value.
  45518. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45519. * part of lighting setup.)
  45520. */
  45521. _perceptualColor: Nullable<Color3>;
  45522. protected _primaryColorShadowLevel: float;
  45523. /**
  45524. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45525. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45526. */
  45527. primaryColorShadowLevel: float;
  45528. protected _primaryColorHighlightLevel: float;
  45529. /**
  45530. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45531. * The primary color is used at the level chosen to define what the white area would look.
  45532. */
  45533. primaryColorHighlightLevel: float;
  45534. protected _reflectionTexture: Nullable<BaseTexture>;
  45535. /**
  45536. * Reflection Texture used in the material.
  45537. * Should be author in a specific way for the best result (refer to the documentation).
  45538. */
  45539. reflectionTexture: Nullable<BaseTexture>;
  45540. protected _reflectionBlur: float;
  45541. /**
  45542. * Reflection Texture level of blur.
  45543. *
  45544. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45545. * texture twice.
  45546. */
  45547. reflectionBlur: float;
  45548. protected _diffuseTexture: Nullable<BaseTexture>;
  45549. /**
  45550. * Diffuse Texture used in the material.
  45551. * Should be author in a specific way for the best result (refer to the documentation).
  45552. */
  45553. diffuseTexture: Nullable<BaseTexture>;
  45554. protected _shadowLights: Nullable<IShadowLight[]>;
  45555. /**
  45556. * Specify the list of lights casting shadow on the material.
  45557. * All scene shadow lights will be included if null.
  45558. */
  45559. shadowLights: Nullable<IShadowLight[]>;
  45560. protected _shadowLevel: float;
  45561. /**
  45562. * Helps adjusting the shadow to a softer level if required.
  45563. * 0 means black shadows and 1 means no shadows.
  45564. */
  45565. shadowLevel: float;
  45566. protected _sceneCenter: Vector3;
  45567. /**
  45568. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45569. * It is usually zero but might be interesting to modify according to your setup.
  45570. */
  45571. sceneCenter: Vector3;
  45572. protected _opacityFresnel: boolean;
  45573. /**
  45574. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45575. * This helps ensuring a nice transition when the camera goes under the ground.
  45576. */
  45577. opacityFresnel: boolean;
  45578. protected _reflectionFresnel: boolean;
  45579. /**
  45580. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45581. * This helps adding a mirror texture on the ground.
  45582. */
  45583. reflectionFresnel: boolean;
  45584. protected _reflectionFalloffDistance: number;
  45585. /**
  45586. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45587. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45588. */
  45589. reflectionFalloffDistance: number;
  45590. protected _reflectionAmount: number;
  45591. /**
  45592. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45593. */
  45594. reflectionAmount: number;
  45595. protected _reflectionReflectance0: number;
  45596. /**
  45597. * This specifies the weight of the reflection at grazing angle.
  45598. */
  45599. reflectionReflectance0: number;
  45600. protected _reflectionReflectance90: number;
  45601. /**
  45602. * This specifies the weight of the reflection at a perpendicular point of view.
  45603. */
  45604. reflectionReflectance90: number;
  45605. /**
  45606. * Sets the reflection reflectance fresnel values according to the default standard
  45607. * empirically know to work well :-)
  45608. */
  45609. reflectionStandardFresnelWeight: number;
  45610. protected _useRGBColor: boolean;
  45611. /**
  45612. * Helps to directly use the maps channels instead of their level.
  45613. */
  45614. useRGBColor: boolean;
  45615. protected _enableNoise: boolean;
  45616. /**
  45617. * This helps reducing the banding effect that could occur on the background.
  45618. */
  45619. enableNoise: boolean;
  45620. /**
  45621. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45622. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45623. * Recommended to be keep at 1.0 except for special cases.
  45624. */
  45625. fovMultiplier: number;
  45626. private _fovMultiplier;
  45627. /**
  45628. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45629. */
  45630. useEquirectangularFOV: boolean;
  45631. private _maxSimultaneousLights;
  45632. /**
  45633. * Number of Simultaneous lights allowed on the material.
  45634. */
  45635. maxSimultaneousLights: int;
  45636. /**
  45637. * Default configuration related to image processing available in the Background Material.
  45638. */
  45639. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45640. /**
  45641. * Keep track of the image processing observer to allow dispose and replace.
  45642. */
  45643. private _imageProcessingObserver;
  45644. /**
  45645. * Attaches a new image processing configuration to the PBR Material.
  45646. * @param configuration (if null the scene configuration will be use)
  45647. */
  45648. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45649. /**
  45650. * Gets the image processing configuration used either in this material.
  45651. */
  45652. /**
  45653. * Sets the Default image processing configuration used either in the this material.
  45654. *
  45655. * If sets to null, the scene one is in use.
  45656. */
  45657. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45658. /**
  45659. * Gets wether the color curves effect is enabled.
  45660. */
  45661. /**
  45662. * Sets wether the color curves effect is enabled.
  45663. */
  45664. cameraColorCurvesEnabled: boolean;
  45665. /**
  45666. * Gets wether the color grading effect is enabled.
  45667. */
  45668. /**
  45669. * Gets wether the color grading effect is enabled.
  45670. */
  45671. cameraColorGradingEnabled: boolean;
  45672. /**
  45673. * Gets wether tonemapping is enabled or not.
  45674. */
  45675. /**
  45676. * Sets wether tonemapping is enabled or not
  45677. */
  45678. cameraToneMappingEnabled: boolean;
  45679. /**
  45680. * The camera exposure used on this material.
  45681. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45682. * This corresponds to a photographic exposure.
  45683. */
  45684. /**
  45685. * The camera exposure used on this material.
  45686. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45687. * This corresponds to a photographic exposure.
  45688. */
  45689. cameraExposure: float;
  45690. /**
  45691. * Gets The camera contrast used on this material.
  45692. */
  45693. /**
  45694. * Sets The camera contrast used on this material.
  45695. */
  45696. cameraContrast: float;
  45697. /**
  45698. * Gets the Color Grading 2D Lookup Texture.
  45699. */
  45700. /**
  45701. * Sets the Color Grading 2D Lookup Texture.
  45702. */
  45703. cameraColorGradingTexture: Nullable<BaseTexture>;
  45704. /**
  45705. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45706. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45707. * 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;
  45708. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45709. */
  45710. /**
  45711. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45712. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45713. * 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;
  45714. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45715. */
  45716. cameraColorCurves: Nullable<ColorCurves>;
  45717. /**
  45718. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45719. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45720. */
  45721. switchToBGR: boolean;
  45722. private _renderTargets;
  45723. private _reflectionControls;
  45724. private _white;
  45725. private _primaryShadowColor;
  45726. private _primaryHighlightColor;
  45727. /**
  45728. * Instantiates a Background Material in the given scene
  45729. * @param name The friendly name of the material
  45730. * @param scene The scene to add the material to
  45731. */
  45732. constructor(name: string, scene: Scene);
  45733. /**
  45734. * Gets a boolean indicating that current material needs to register RTT
  45735. */
  45736. readonly hasRenderTargetTextures: boolean;
  45737. /**
  45738. * The entire material has been created in order to prevent overdraw.
  45739. * @returns false
  45740. */
  45741. needAlphaTesting(): boolean;
  45742. /**
  45743. * The entire material has been created in order to prevent overdraw.
  45744. * @returns true if blending is enable
  45745. */
  45746. needAlphaBlending(): boolean;
  45747. /**
  45748. * Checks wether the material is ready to be rendered for a given mesh.
  45749. * @param mesh The mesh to render
  45750. * @param subMesh The submesh to check against
  45751. * @param useInstances Specify wether or not the material is used with instances
  45752. * @returns true if all the dependencies are ready (Textures, Effects...)
  45753. */
  45754. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45755. /**
  45756. * Compute the primary color according to the chosen perceptual color.
  45757. */
  45758. private _computePrimaryColorFromPerceptualColor;
  45759. /**
  45760. * Compute the highlights and shadow colors according to their chosen levels.
  45761. */
  45762. private _computePrimaryColors;
  45763. /**
  45764. * Build the uniform buffer used in the material.
  45765. */
  45766. buildUniformLayout(): void;
  45767. /**
  45768. * Unbind the material.
  45769. */
  45770. unbind(): void;
  45771. /**
  45772. * Bind only the world matrix to the material.
  45773. * @param world The world matrix to bind.
  45774. */
  45775. bindOnlyWorldMatrix(world: Matrix): void;
  45776. /**
  45777. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45778. * @param world The world matrix to bind.
  45779. * @param subMesh The submesh to bind for.
  45780. */
  45781. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45782. /**
  45783. * Dispose the material.
  45784. * @param forceDisposeEffect Force disposal of the associated effect.
  45785. * @param forceDisposeTextures Force disposal of the associated textures.
  45786. */
  45787. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45788. /**
  45789. * Clones the material.
  45790. * @param name The cloned name.
  45791. * @returns The cloned material.
  45792. */
  45793. clone(name: string): BackgroundMaterial;
  45794. /**
  45795. * Serializes the current material to its JSON representation.
  45796. * @returns The JSON representation.
  45797. */
  45798. serialize(): any;
  45799. /**
  45800. * Gets the class name of the material
  45801. * @returns "BackgroundMaterial"
  45802. */
  45803. getClassName(): string;
  45804. /**
  45805. * Parse a JSON input to create back a background material.
  45806. * @param source The JSON data to parse
  45807. * @param scene The scene to create the parsed material in
  45808. * @param rootUrl The root url of the assets the material depends upon
  45809. * @returns the instantiated BackgroundMaterial.
  45810. */
  45811. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45812. }
  45813. }
  45814. declare module "babylonjs/Helpers/environmentHelper" {
  45815. import { Observable } from "babylonjs/Misc/observable";
  45816. import { Nullable } from "babylonjs/types";
  45817. import { Scene } from "babylonjs/scene";
  45818. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45820. import { Mesh } from "babylonjs/Meshes/mesh";
  45821. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45822. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45823. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45824. import "babylonjs/Meshes/Builders/planeBuilder";
  45825. import "babylonjs/Meshes/Builders/boxBuilder";
  45826. /**
  45827. * Represents the different options available during the creation of
  45828. * a Environment helper.
  45829. *
  45830. * This can control the default ground, skybox and image processing setup of your scene.
  45831. */
  45832. export interface IEnvironmentHelperOptions {
  45833. /**
  45834. * Specifies wether or not to create a ground.
  45835. * True by default.
  45836. */
  45837. createGround: boolean;
  45838. /**
  45839. * Specifies the ground size.
  45840. * 15 by default.
  45841. */
  45842. groundSize: number;
  45843. /**
  45844. * The texture used on the ground for the main color.
  45845. * Comes from the BabylonJS CDN by default.
  45846. *
  45847. * Remarks: Can be either a texture or a url.
  45848. */
  45849. groundTexture: string | BaseTexture;
  45850. /**
  45851. * The color mixed in the ground texture by default.
  45852. * BabylonJS clearColor by default.
  45853. */
  45854. groundColor: Color3;
  45855. /**
  45856. * Specifies the ground opacity.
  45857. * 1 by default.
  45858. */
  45859. groundOpacity: number;
  45860. /**
  45861. * Enables the ground to receive shadows.
  45862. * True by default.
  45863. */
  45864. enableGroundShadow: boolean;
  45865. /**
  45866. * Helps preventing the shadow to be fully black on the ground.
  45867. * 0.5 by default.
  45868. */
  45869. groundShadowLevel: number;
  45870. /**
  45871. * Creates a mirror texture attach to the ground.
  45872. * false by default.
  45873. */
  45874. enableGroundMirror: boolean;
  45875. /**
  45876. * Specifies the ground mirror size ratio.
  45877. * 0.3 by default as the default kernel is 64.
  45878. */
  45879. groundMirrorSizeRatio: number;
  45880. /**
  45881. * Specifies the ground mirror blur kernel size.
  45882. * 64 by default.
  45883. */
  45884. groundMirrorBlurKernel: number;
  45885. /**
  45886. * Specifies the ground mirror visibility amount.
  45887. * 1 by default
  45888. */
  45889. groundMirrorAmount: number;
  45890. /**
  45891. * Specifies the ground mirror reflectance weight.
  45892. * This uses the standard weight of the background material to setup the fresnel effect
  45893. * of the mirror.
  45894. * 1 by default.
  45895. */
  45896. groundMirrorFresnelWeight: number;
  45897. /**
  45898. * Specifies the ground mirror Falloff distance.
  45899. * This can helps reducing the size of the reflection.
  45900. * 0 by Default.
  45901. */
  45902. groundMirrorFallOffDistance: number;
  45903. /**
  45904. * Specifies the ground mirror texture type.
  45905. * Unsigned Int by Default.
  45906. */
  45907. groundMirrorTextureType: number;
  45908. /**
  45909. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45910. * the shown objects.
  45911. */
  45912. groundYBias: number;
  45913. /**
  45914. * Specifies wether or not to create a skybox.
  45915. * True by default.
  45916. */
  45917. createSkybox: boolean;
  45918. /**
  45919. * Specifies the skybox size.
  45920. * 20 by default.
  45921. */
  45922. skyboxSize: number;
  45923. /**
  45924. * The texture used on the skybox for the main color.
  45925. * Comes from the BabylonJS CDN by default.
  45926. *
  45927. * Remarks: Can be either a texture or a url.
  45928. */
  45929. skyboxTexture: string | BaseTexture;
  45930. /**
  45931. * The color mixed in the skybox texture by default.
  45932. * BabylonJS clearColor by default.
  45933. */
  45934. skyboxColor: Color3;
  45935. /**
  45936. * The background rotation around the Y axis of the scene.
  45937. * This helps aligning the key lights of your scene with the background.
  45938. * 0 by default.
  45939. */
  45940. backgroundYRotation: number;
  45941. /**
  45942. * Compute automatically the size of the elements to best fit with the scene.
  45943. */
  45944. sizeAuto: boolean;
  45945. /**
  45946. * Default position of the rootMesh if autoSize is not true.
  45947. */
  45948. rootPosition: Vector3;
  45949. /**
  45950. * Sets up the image processing in the scene.
  45951. * true by default.
  45952. */
  45953. setupImageProcessing: boolean;
  45954. /**
  45955. * The texture used as your environment texture in the scene.
  45956. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45957. *
  45958. * Remarks: Can be either a texture or a url.
  45959. */
  45960. environmentTexture: string | BaseTexture;
  45961. /**
  45962. * The value of the exposure to apply to the scene.
  45963. * 0.6 by default if setupImageProcessing is true.
  45964. */
  45965. cameraExposure: number;
  45966. /**
  45967. * The value of the contrast to apply to the scene.
  45968. * 1.6 by default if setupImageProcessing is true.
  45969. */
  45970. cameraContrast: number;
  45971. /**
  45972. * Specifies wether or not tonemapping should be enabled in the scene.
  45973. * true by default if setupImageProcessing is true.
  45974. */
  45975. toneMappingEnabled: boolean;
  45976. }
  45977. /**
  45978. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45979. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45980. * It also helps with the default setup of your imageProcessing configuration.
  45981. */
  45982. export class EnvironmentHelper {
  45983. /**
  45984. * Default ground texture URL.
  45985. */
  45986. private static _groundTextureCDNUrl;
  45987. /**
  45988. * Default skybox texture URL.
  45989. */
  45990. private static _skyboxTextureCDNUrl;
  45991. /**
  45992. * Default environment texture URL.
  45993. */
  45994. private static _environmentTextureCDNUrl;
  45995. /**
  45996. * Creates the default options for the helper.
  45997. */
  45998. private static _getDefaultOptions;
  45999. private _rootMesh;
  46000. /**
  46001. * Gets the root mesh created by the helper.
  46002. */
  46003. readonly rootMesh: Mesh;
  46004. private _skybox;
  46005. /**
  46006. * Gets the skybox created by the helper.
  46007. */
  46008. readonly skybox: Nullable<Mesh>;
  46009. private _skyboxTexture;
  46010. /**
  46011. * Gets the skybox texture created by the helper.
  46012. */
  46013. readonly skyboxTexture: Nullable<BaseTexture>;
  46014. private _skyboxMaterial;
  46015. /**
  46016. * Gets the skybox material created by the helper.
  46017. */
  46018. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46019. private _ground;
  46020. /**
  46021. * Gets the ground mesh created by the helper.
  46022. */
  46023. readonly ground: Nullable<Mesh>;
  46024. private _groundTexture;
  46025. /**
  46026. * Gets the ground texture created by the helper.
  46027. */
  46028. readonly groundTexture: Nullable<BaseTexture>;
  46029. private _groundMirror;
  46030. /**
  46031. * Gets the ground mirror created by the helper.
  46032. */
  46033. readonly groundMirror: Nullable<MirrorTexture>;
  46034. /**
  46035. * Gets the ground mirror render list to helps pushing the meshes
  46036. * you wish in the ground reflection.
  46037. */
  46038. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46039. private _groundMaterial;
  46040. /**
  46041. * Gets the ground material created by the helper.
  46042. */
  46043. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46044. /**
  46045. * Stores the creation options.
  46046. */
  46047. private readonly _scene;
  46048. private _options;
  46049. /**
  46050. * This observable will be notified with any error during the creation of the environment,
  46051. * mainly texture creation errors.
  46052. */
  46053. onErrorObservable: Observable<{
  46054. message?: string;
  46055. exception?: any;
  46056. }>;
  46057. /**
  46058. * constructor
  46059. * @param options Defines the options we want to customize the helper
  46060. * @param scene The scene to add the material to
  46061. */
  46062. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46063. /**
  46064. * Updates the background according to the new options
  46065. * @param options
  46066. */
  46067. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46068. /**
  46069. * Sets the primary color of all the available elements.
  46070. * @param color the main color to affect to the ground and the background
  46071. */
  46072. setMainColor(color: Color3): void;
  46073. /**
  46074. * Setup the image processing according to the specified options.
  46075. */
  46076. private _setupImageProcessing;
  46077. /**
  46078. * Setup the environment texture according to the specified options.
  46079. */
  46080. private _setupEnvironmentTexture;
  46081. /**
  46082. * Setup the background according to the specified options.
  46083. */
  46084. private _setupBackground;
  46085. /**
  46086. * Get the scene sizes according to the setup.
  46087. */
  46088. private _getSceneSize;
  46089. /**
  46090. * Setup the ground according to the specified options.
  46091. */
  46092. private _setupGround;
  46093. /**
  46094. * Setup the ground material according to the specified options.
  46095. */
  46096. private _setupGroundMaterial;
  46097. /**
  46098. * Setup the ground diffuse texture according to the specified options.
  46099. */
  46100. private _setupGroundDiffuseTexture;
  46101. /**
  46102. * Setup the ground mirror texture according to the specified options.
  46103. */
  46104. private _setupGroundMirrorTexture;
  46105. /**
  46106. * Setup the ground to receive the mirror texture.
  46107. */
  46108. private _setupMirrorInGroundMaterial;
  46109. /**
  46110. * Setup the skybox according to the specified options.
  46111. */
  46112. private _setupSkybox;
  46113. /**
  46114. * Setup the skybox material according to the specified options.
  46115. */
  46116. private _setupSkyboxMaterial;
  46117. /**
  46118. * Setup the skybox reflection texture according to the specified options.
  46119. */
  46120. private _setupSkyboxReflectionTexture;
  46121. private _errorHandler;
  46122. /**
  46123. * Dispose all the elements created by the Helper.
  46124. */
  46125. dispose(): void;
  46126. }
  46127. }
  46128. declare module "babylonjs/Helpers/photoDome" {
  46129. import { Observable } from "babylonjs/Misc/observable";
  46130. import { Nullable } from "babylonjs/types";
  46131. import { Scene } from "babylonjs/scene";
  46132. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46133. import { Mesh } from "babylonjs/Meshes/mesh";
  46134. import { Texture } from "babylonjs/Materials/Textures/texture";
  46135. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46136. import "babylonjs/Meshes/Builders/sphereBuilder";
  46137. /**
  46138. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46139. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46140. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46141. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46142. */
  46143. export class PhotoDome extends TransformNode {
  46144. /**
  46145. * Define the image as a Monoscopic panoramic 360 image.
  46146. */
  46147. static readonly MODE_MONOSCOPIC: number;
  46148. /**
  46149. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46150. */
  46151. static readonly MODE_TOPBOTTOM: number;
  46152. /**
  46153. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46154. */
  46155. static readonly MODE_SIDEBYSIDE: number;
  46156. private _useDirectMapping;
  46157. /**
  46158. * The texture being displayed on the sphere
  46159. */
  46160. protected _photoTexture: Texture;
  46161. /**
  46162. * Gets or sets the texture being displayed on the sphere
  46163. */
  46164. photoTexture: Texture;
  46165. /**
  46166. * Observable raised when an error occured while loading the 360 image
  46167. */
  46168. onLoadErrorObservable: Observable<string>;
  46169. /**
  46170. * The skybox material
  46171. */
  46172. protected _material: BackgroundMaterial;
  46173. /**
  46174. * The surface used for the skybox
  46175. */
  46176. protected _mesh: Mesh;
  46177. /**
  46178. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46179. * Also see the options.resolution property.
  46180. */
  46181. fovMultiplier: number;
  46182. private _imageMode;
  46183. /**
  46184. * Gets or set the current video mode for the video. It can be:
  46185. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46186. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46187. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46188. */
  46189. imageMode: number;
  46190. /**
  46191. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46192. * @param name Element's name, child elements will append suffixes for their own names.
  46193. * @param urlsOfPhoto defines the url of the photo to display
  46194. * @param options defines an object containing optional or exposed sub element properties
  46195. * @param onError defines a callback called when an error occured while loading the texture
  46196. */
  46197. constructor(name: string, urlOfPhoto: string, options: {
  46198. resolution?: number;
  46199. size?: number;
  46200. useDirectMapping?: boolean;
  46201. faceForward?: boolean;
  46202. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46203. private _onBeforeCameraRenderObserver;
  46204. private _changeImageMode;
  46205. /**
  46206. * Releases resources associated with this node.
  46207. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46208. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46209. */
  46210. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46211. }
  46212. }
  46213. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46214. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46215. /** @hidden */
  46216. export var rgbdDecodePixelShader: {
  46217. name: string;
  46218. shader: string;
  46219. };
  46220. }
  46221. declare module "babylonjs/Misc/brdfTextureTools" {
  46222. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46223. import { Scene } from "babylonjs/scene";
  46224. import "babylonjs/Shaders/rgbdDecode.fragment";
  46225. /**
  46226. * Class used to host texture specific utilities
  46227. */
  46228. export class BRDFTextureTools {
  46229. /**
  46230. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46231. * @param texture the texture to expand.
  46232. */
  46233. private static _ExpandDefaultBRDFTexture;
  46234. /**
  46235. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46236. * @param scene defines the hosting scene
  46237. * @returns the environment BRDF texture
  46238. */
  46239. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46240. private static _environmentBRDFBase64Texture;
  46241. }
  46242. }
  46243. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46244. import { Nullable } from "babylonjs/types";
  46245. import { IAnimatable } from "babylonjs/Misc/tools";
  46246. import { Color3 } from "babylonjs/Maths/math";
  46247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46248. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46249. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46250. import { Engine } from "babylonjs/Engines/engine";
  46251. import { Scene } from "babylonjs/scene";
  46252. /**
  46253. * @hidden
  46254. */
  46255. export interface IMaterialClearCoatDefines {
  46256. CLEARCOAT: boolean;
  46257. CLEARCOAT_DEFAULTIOR: boolean;
  46258. CLEARCOAT_TEXTURE: boolean;
  46259. CLEARCOAT_TEXTUREDIRECTUV: number;
  46260. CLEARCOAT_BUMP: boolean;
  46261. CLEARCOAT_BUMPDIRECTUV: number;
  46262. CLEARCOAT_TINT: boolean;
  46263. CLEARCOAT_TINT_TEXTURE: boolean;
  46264. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46265. /** @hidden */
  46266. _areTexturesDirty: boolean;
  46267. }
  46268. /**
  46269. * Define the code related to the clear coat parameters of the pbr material.
  46270. */
  46271. export class PBRClearCoatConfiguration {
  46272. /**
  46273. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46274. * The default fits with a polyurethane material.
  46275. */
  46276. private static readonly _DefaultIndexOfRefraction;
  46277. private _isEnabled;
  46278. /**
  46279. * Defines if the clear coat is enabled in the material.
  46280. */
  46281. isEnabled: boolean;
  46282. /**
  46283. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46284. */
  46285. intensity: number;
  46286. /**
  46287. * Defines the clear coat layer roughness.
  46288. */
  46289. roughness: number;
  46290. private _indexOfRefraction;
  46291. /**
  46292. * Defines the index of refraction of the clear coat.
  46293. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46294. * The default fits with a polyurethane material.
  46295. * Changing the default value is more performance intensive.
  46296. */
  46297. indexOfRefraction: number;
  46298. private _texture;
  46299. /**
  46300. * Stores the clear coat values in a texture.
  46301. */
  46302. texture: Nullable<BaseTexture>;
  46303. private _bumpTexture;
  46304. /**
  46305. * Define the clear coat specific bump texture.
  46306. */
  46307. bumpTexture: Nullable<BaseTexture>;
  46308. private _isTintEnabled;
  46309. /**
  46310. * Defines if the clear coat tint is enabled in the material.
  46311. */
  46312. isTintEnabled: boolean;
  46313. /**
  46314. * Defines the clear coat tint of the material.
  46315. * This is only use if tint is enabled
  46316. */
  46317. tintColor: Color3;
  46318. /**
  46319. * Defines the distance at which the tint color should be found in the
  46320. * clear coat media.
  46321. * This is only use if tint is enabled
  46322. */
  46323. tintColorAtDistance: number;
  46324. /**
  46325. * Defines the clear coat layer thickness.
  46326. * This is only use if tint is enabled
  46327. */
  46328. tintThickness: number;
  46329. private _tintTexture;
  46330. /**
  46331. * Stores the clear tint values in a texture.
  46332. * rgb is tint
  46333. * a is a thickness factor
  46334. */
  46335. tintTexture: Nullable<BaseTexture>;
  46336. /** @hidden */
  46337. private _internalMarkAllSubMeshesAsTexturesDirty;
  46338. /** @hidden */
  46339. _markAllSubMeshesAsTexturesDirty(): void;
  46340. /**
  46341. * Instantiate a new istance of clear coat configuration.
  46342. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46343. */
  46344. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46345. /**
  46346. * Gets wehter the submesh is ready to be used or not.
  46347. * @param defines the list of "defines" to update.
  46348. * @param scene defines the scene the material belongs to.
  46349. * @param engine defines the engine the material belongs to.
  46350. * @param disableBumpMap defines wether the material disables bump or not.
  46351. * @returns - boolean indicating that the submesh is ready or not.
  46352. */
  46353. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46354. /**
  46355. * Checks to see if a texture is used in the material.
  46356. * @param defines the list of "defines" to update.
  46357. * @param scene defines the scene to the material belongs to.
  46358. */
  46359. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46360. /**
  46361. * Binds the material data.
  46362. * @param uniformBuffer defines the Uniform buffer to fill in.
  46363. * @param scene defines the scene the material belongs to.
  46364. * @param engine defines the engine the material belongs to.
  46365. * @param disableBumpMap defines wether the material disables bump or not.
  46366. * @param isFrozen defines wether the material is frozen or not.
  46367. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46368. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46369. */
  46370. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46371. /**
  46372. * Checks to see if a texture is used in the material.
  46373. * @param texture - Base texture to use.
  46374. * @returns - Boolean specifying if a texture is used in the material.
  46375. */
  46376. hasTexture(texture: BaseTexture): boolean;
  46377. /**
  46378. * Returns an array of the actively used textures.
  46379. * @param activeTextures Array of BaseTextures
  46380. */
  46381. getActiveTextures(activeTextures: BaseTexture[]): void;
  46382. /**
  46383. * Returns the animatable textures.
  46384. * @param animatables Array of animatable textures.
  46385. */
  46386. getAnimatables(animatables: IAnimatable[]): void;
  46387. /**
  46388. * Disposes the resources of the material.
  46389. * @param forceDisposeTextures - Forces the disposal of all textures.
  46390. */
  46391. dispose(forceDisposeTextures?: boolean): void;
  46392. /**
  46393. * Get the current class name of the texture useful for serialization or dynamic coding.
  46394. * @returns "PBRClearCoatConfiguration"
  46395. */
  46396. getClassName(): string;
  46397. /**
  46398. * Add fallbacks to the effect fallbacks list.
  46399. * @param defines defines the Base texture to use.
  46400. * @param fallbacks defines the current fallback list.
  46401. * @param currentRank defines the current fallback rank.
  46402. * @returns the new fallback rank.
  46403. */
  46404. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46405. /**
  46406. * Add the required uniforms to the current list.
  46407. * @param uniforms defines the current uniform list.
  46408. */
  46409. static AddUniforms(uniforms: string[]): void;
  46410. /**
  46411. * Add the required samplers to the current list.
  46412. * @param samplers defines the current sampler list.
  46413. */
  46414. static AddSamplers(samplers: string[]): void;
  46415. /**
  46416. * Add the required uniforms to the current buffer.
  46417. * @param uniformBuffer defines the current uniform buffer.
  46418. */
  46419. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46420. /**
  46421. * Makes a duplicate of the current configuration into another one.
  46422. * @param clearCoatConfiguration define the config where to copy the info
  46423. */
  46424. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46425. /**
  46426. * Serializes this clear coat configuration.
  46427. * @returns - An object with the serialized config.
  46428. */
  46429. serialize(): any;
  46430. /**
  46431. * Parses a Clear Coat Configuration from a serialized object.
  46432. * @param source - Serialized object.
  46433. */
  46434. parse(source: any): void;
  46435. }
  46436. }
  46437. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46438. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46439. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46441. import { Vector2 } from "babylonjs/Maths/math";
  46442. import { Scene } from "babylonjs/scene";
  46443. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46444. import { IAnimatable } from "babylonjs/Misc/tools";
  46445. import { Nullable } from "babylonjs/types";
  46446. /**
  46447. * @hidden
  46448. */
  46449. export interface IMaterialAnisotropicDefines {
  46450. ANISOTROPIC: boolean;
  46451. ANISOTROPIC_TEXTURE: boolean;
  46452. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46453. MAINUV1: boolean;
  46454. _areTexturesDirty: boolean;
  46455. _needUVs: boolean;
  46456. }
  46457. /**
  46458. * Define the code related to the anisotropic parameters of the pbr material.
  46459. */
  46460. export class PBRAnisotropicConfiguration {
  46461. private _isEnabled;
  46462. /**
  46463. * Defines if the anisotropy is enabled in the material.
  46464. */
  46465. isEnabled: boolean;
  46466. /**
  46467. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46468. */
  46469. intensity: number;
  46470. /**
  46471. * Defines if the effect is along the tangents, bitangents or in between.
  46472. * By default, the effect is "strectching" the highlights along the tangents.
  46473. */
  46474. direction: Vector2;
  46475. private _texture;
  46476. /**
  46477. * Stores the anisotropy values in a texture.
  46478. * rg is direction (like normal from -1 to 1)
  46479. * b is a intensity
  46480. */
  46481. texture: Nullable<BaseTexture>;
  46482. /** @hidden */
  46483. private _internalMarkAllSubMeshesAsTexturesDirty;
  46484. /** @hidden */
  46485. _markAllSubMeshesAsTexturesDirty(): void;
  46486. /**
  46487. * Instantiate a new istance of anisotropy configuration.
  46488. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46489. */
  46490. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46491. /**
  46492. * Specifies that the submesh is ready to be used.
  46493. * @param defines the list of "defines" to update.
  46494. * @param scene defines the scene the material belongs to.
  46495. * @returns - boolean indicating that the submesh is ready or not.
  46496. */
  46497. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46498. /**
  46499. * Checks to see if a texture is used in the material.
  46500. * @param defines the list of "defines" to update.
  46501. * @param mesh the mesh we are preparing the defines for.
  46502. * @param scene defines the scene the material belongs to.
  46503. */
  46504. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46505. /**
  46506. * Binds the material data.
  46507. * @param uniformBuffer defines the Uniform buffer to fill in.
  46508. * @param scene defines the scene the material belongs to.
  46509. * @param isFrozen defines wether the material is frozen or not.
  46510. */
  46511. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46512. /**
  46513. * Checks to see if a texture is used in the material.
  46514. * @param texture - Base texture to use.
  46515. * @returns - Boolean specifying if a texture is used in the material.
  46516. */
  46517. hasTexture(texture: BaseTexture): boolean;
  46518. /**
  46519. * Returns an array of the actively used textures.
  46520. * @param activeTextures Array of BaseTextures
  46521. */
  46522. getActiveTextures(activeTextures: BaseTexture[]): void;
  46523. /**
  46524. * Returns the animatable textures.
  46525. * @param animatables Array of animatable textures.
  46526. */
  46527. getAnimatables(animatables: IAnimatable[]): void;
  46528. /**
  46529. * Disposes the resources of the material.
  46530. * @param forceDisposeTextures - Forces the disposal of all textures.
  46531. */
  46532. dispose(forceDisposeTextures?: boolean): void;
  46533. /**
  46534. * Get the current class name of the texture useful for serialization or dynamic coding.
  46535. * @returns "PBRAnisotropicConfiguration"
  46536. */
  46537. getClassName(): string;
  46538. /**
  46539. * Add fallbacks to the effect fallbacks list.
  46540. * @param defines defines the Base texture to use.
  46541. * @param fallbacks defines the current fallback list.
  46542. * @param currentRank defines the current fallback rank.
  46543. * @returns the new fallback rank.
  46544. */
  46545. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46546. /**
  46547. * Add the required uniforms to the current list.
  46548. * @param uniforms defines the current uniform list.
  46549. */
  46550. static AddUniforms(uniforms: string[]): void;
  46551. /**
  46552. * Add the required uniforms to the current buffer.
  46553. * @param uniformBuffer defines the current uniform buffer.
  46554. */
  46555. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46556. /**
  46557. * Add the required samplers to the current list.
  46558. * @param samplers defines the current sampler list.
  46559. */
  46560. static AddSamplers(samplers: string[]): void;
  46561. /**
  46562. * Makes a duplicate of the current configuration into another one.
  46563. * @param anisotropicConfiguration define the config where to copy the info
  46564. */
  46565. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46566. /**
  46567. * Serializes this anisotropy configuration.
  46568. * @returns - An object with the serialized config.
  46569. */
  46570. serialize(): any;
  46571. /**
  46572. * Parses a anisotropy Configuration from a serialized object.
  46573. * @param source - Serialized object.
  46574. */
  46575. parse(source: any): void;
  46576. }
  46577. }
  46578. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46579. /**
  46580. * @hidden
  46581. */
  46582. export interface IMaterialBRDFDefines {
  46583. BRDF_V_HEIGHT_CORRELATED: boolean;
  46584. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46585. SPHERICAL_HARMONICS: boolean;
  46586. /** @hidden */
  46587. _areMiscDirty: boolean;
  46588. }
  46589. /**
  46590. * Define the code related to the BRDF parameters of the pbr material.
  46591. */
  46592. export class PBRBRDFConfiguration {
  46593. /**
  46594. * Default value used for the energy conservation.
  46595. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46596. */
  46597. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46598. /**
  46599. * Default value used for the Smith Visibility Height Correlated mode.
  46600. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46601. */
  46602. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46603. /**
  46604. * Default value used for the IBL diffuse part.
  46605. * This can help switching back to the polynomials mode globally which is a tiny bit
  46606. * less GPU intensive at the drawback of a lower quality.
  46607. */
  46608. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46609. private _useEnergyConservation;
  46610. /**
  46611. * Defines if the material uses energy conservation.
  46612. */
  46613. useEnergyConservation: boolean;
  46614. private _useSmithVisibilityHeightCorrelated;
  46615. /**
  46616. * LEGACY Mode set to false
  46617. * Defines if the material uses height smith correlated visibility term.
  46618. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46619. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46620. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46621. * Not relying on height correlated will also disable energy conservation.
  46622. */
  46623. useSmithVisibilityHeightCorrelated: boolean;
  46624. private _useSphericalHarmonics;
  46625. /**
  46626. * LEGACY Mode set to false
  46627. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46628. * diffuse part of the IBL.
  46629. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46630. * to the ground truth.
  46631. */
  46632. useSphericalHarmonics: boolean;
  46633. /** @hidden */
  46634. private _internalMarkAllSubMeshesAsMiscDirty;
  46635. /** @hidden */
  46636. _markAllSubMeshesAsMiscDirty(): void;
  46637. /**
  46638. * Instantiate a new istance of clear coat configuration.
  46639. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46640. */
  46641. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46642. /**
  46643. * Checks to see if a texture is used in the material.
  46644. * @param defines the list of "defines" to update.
  46645. */
  46646. prepareDefines(defines: IMaterialBRDFDefines): void;
  46647. /**
  46648. * Get the current class name of the texture useful for serialization or dynamic coding.
  46649. * @returns "PBRClearCoatConfiguration"
  46650. */
  46651. getClassName(): string;
  46652. /**
  46653. * Makes a duplicate of the current configuration into another one.
  46654. * @param brdfConfiguration define the config where to copy the info
  46655. */
  46656. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46657. /**
  46658. * Serializes this BRDF configuration.
  46659. * @returns - An object with the serialized config.
  46660. */
  46661. serialize(): any;
  46662. /**
  46663. * Parses a BRDF Configuration from a serialized object.
  46664. * @param source - Serialized object.
  46665. */
  46666. parse(source: any): void;
  46667. }
  46668. }
  46669. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46670. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46671. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46672. import { Color3 } from "babylonjs/Maths/math";
  46673. import { Scene } from "babylonjs/scene";
  46674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46675. import { IAnimatable } from "babylonjs/Misc/tools";
  46676. import { Nullable } from "babylonjs/types";
  46677. /**
  46678. * @hidden
  46679. */
  46680. export interface IMaterialSheenDefines {
  46681. SHEEN: boolean;
  46682. SHEEN_TEXTURE: boolean;
  46683. SHEEN_TEXTUREDIRECTUV: number;
  46684. SHEEN_LINKWITHALBEDO: boolean;
  46685. /** @hidden */
  46686. _areTexturesDirty: boolean;
  46687. }
  46688. /**
  46689. * Define the code related to the Sheen parameters of the pbr material.
  46690. */
  46691. export class PBRSheenConfiguration {
  46692. private _isEnabled;
  46693. /**
  46694. * Defines if the material uses sheen.
  46695. */
  46696. isEnabled: boolean;
  46697. private _linkSheenWithAlbedo;
  46698. /**
  46699. * Defines if the sheen is linked to the sheen color.
  46700. */
  46701. linkSheenWithAlbedo: boolean;
  46702. /**
  46703. * Defines the sheen intensity.
  46704. */
  46705. intensity: number;
  46706. /**
  46707. * Defines the sheen color.
  46708. */
  46709. color: Color3;
  46710. private _texture;
  46711. /**
  46712. * Stores the sheen tint values in a texture.
  46713. * rgb is tint
  46714. * a is a intensity
  46715. */
  46716. texture: Nullable<BaseTexture>;
  46717. /** @hidden */
  46718. private _internalMarkAllSubMeshesAsTexturesDirty;
  46719. /** @hidden */
  46720. _markAllSubMeshesAsTexturesDirty(): void;
  46721. /**
  46722. * Instantiate a new istance of clear coat configuration.
  46723. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46724. */
  46725. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46726. /**
  46727. * Specifies that the submesh is ready to be used.
  46728. * @param defines the list of "defines" to update.
  46729. * @param scene defines the scene the material belongs to.
  46730. * @returns - boolean indicating that the submesh is ready or not.
  46731. */
  46732. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46733. /**
  46734. * Checks to see if a texture is used in the material.
  46735. * @param defines the list of "defines" to update.
  46736. * @param scene defines the scene the material belongs to.
  46737. */
  46738. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46739. /**
  46740. * Binds the material data.
  46741. * @param uniformBuffer defines the Uniform buffer to fill in.
  46742. * @param scene defines the scene the material belongs to.
  46743. * @param isFrozen defines wether the material is frozen or not.
  46744. */
  46745. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46746. /**
  46747. * Checks to see if a texture is used in the material.
  46748. * @param texture - Base texture to use.
  46749. * @returns - Boolean specifying if a texture is used in the material.
  46750. */
  46751. hasTexture(texture: BaseTexture): boolean;
  46752. /**
  46753. * Returns an array of the actively used textures.
  46754. * @param activeTextures Array of BaseTextures
  46755. */
  46756. getActiveTextures(activeTextures: BaseTexture[]): void;
  46757. /**
  46758. * Returns the animatable textures.
  46759. * @param animatables Array of animatable textures.
  46760. */
  46761. getAnimatables(animatables: IAnimatable[]): void;
  46762. /**
  46763. * Disposes the resources of the material.
  46764. * @param forceDisposeTextures - Forces the disposal of all textures.
  46765. */
  46766. dispose(forceDisposeTextures?: boolean): void;
  46767. /**
  46768. * Get the current class name of the texture useful for serialization or dynamic coding.
  46769. * @returns "PBRSheenConfiguration"
  46770. */
  46771. getClassName(): string;
  46772. /**
  46773. * Add fallbacks to the effect fallbacks list.
  46774. * @param defines defines the Base texture to use.
  46775. * @param fallbacks defines the current fallback list.
  46776. * @param currentRank defines the current fallback rank.
  46777. * @returns the new fallback rank.
  46778. */
  46779. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46780. /**
  46781. * Add the required uniforms to the current list.
  46782. * @param uniforms defines the current uniform list.
  46783. */
  46784. static AddUniforms(uniforms: string[]): void;
  46785. /**
  46786. * Add the required uniforms to the current buffer.
  46787. * @param uniformBuffer defines the current uniform buffer.
  46788. */
  46789. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46790. /**
  46791. * Add the required samplers to the current list.
  46792. * @param samplers defines the current sampler list.
  46793. */
  46794. static AddSamplers(samplers: string[]): void;
  46795. /**
  46796. * Makes a duplicate of the current configuration into another one.
  46797. * @param sheenConfiguration define the config where to copy the info
  46798. */
  46799. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46800. /**
  46801. * Serializes this BRDF configuration.
  46802. * @returns - An object with the serialized config.
  46803. */
  46804. serialize(): any;
  46805. /**
  46806. * Parses a Sheen Configuration from a serialized object.
  46807. * @param source - Serialized object.
  46808. */
  46809. parse(source: any): void;
  46810. }
  46811. }
  46812. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46813. import { Nullable } from "babylonjs/types";
  46814. import { IAnimatable } from "babylonjs/Misc/tools";
  46815. import { Color3 } from "babylonjs/Maths/math";
  46816. import { SmartArray } from "babylonjs/Misc/smartArray";
  46817. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46818. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46819. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46820. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46821. import { Engine } from "babylonjs/Engines/engine";
  46822. import { Scene } from "babylonjs/scene";
  46823. /**
  46824. * @hidden
  46825. */
  46826. export interface IMaterialSubSurfaceDefines {
  46827. SUBSURFACE: boolean;
  46828. SS_REFRACTION: boolean;
  46829. SS_TRANSLUCENCY: boolean;
  46830. SS_SCATERRING: boolean;
  46831. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46832. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46833. SS_REFRACTIONMAP_3D: boolean;
  46834. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46835. SS_LODINREFRACTIONALPHA: boolean;
  46836. SS_GAMMAREFRACTION: boolean;
  46837. SS_RGBDREFRACTION: boolean;
  46838. SS_LINEARSPECULARREFRACTION: boolean;
  46839. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46840. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46841. /** @hidden */
  46842. _areTexturesDirty: boolean;
  46843. }
  46844. /**
  46845. * Define the code related to the sub surface parameters of the pbr material.
  46846. */
  46847. export class PBRSubSurfaceConfiguration {
  46848. private _isRefractionEnabled;
  46849. /**
  46850. * Defines if the refraction is enabled in the material.
  46851. */
  46852. isRefractionEnabled: boolean;
  46853. private _isTranslucencyEnabled;
  46854. /**
  46855. * Defines if the translucency is enabled in the material.
  46856. */
  46857. isTranslucencyEnabled: boolean;
  46858. private _isScatteringEnabled;
  46859. /**
  46860. * Defines the refraction intensity of the material.
  46861. * The refraction when enabled replaces the Diffuse part of the material.
  46862. * The intensity helps transitionning between diffuse and refraction.
  46863. */
  46864. refractionIntensity: number;
  46865. /**
  46866. * Defines the translucency intensity of the material.
  46867. * When translucency has been enabled, this defines how much of the "translucency"
  46868. * is addded to the diffuse part of the material.
  46869. */
  46870. translucencyIntensity: number;
  46871. /**
  46872. * Defines the scattering intensity of the material.
  46873. * When scattering has been enabled, this defines how much of the "scattered light"
  46874. * is addded to the diffuse part of the material.
  46875. */
  46876. scatteringIntensity: number;
  46877. private _thicknessTexture;
  46878. /**
  46879. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46880. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46881. * 0 would mean minimumThickness
  46882. * 1 would mean maximumThickness
  46883. * The other channels might be use as a mask to vary the different effects intensity.
  46884. */
  46885. thicknessTexture: Nullable<BaseTexture>;
  46886. private _refractionTexture;
  46887. /**
  46888. * Defines the texture to use for refraction.
  46889. */
  46890. refractionTexture: Nullable<BaseTexture>;
  46891. private _indexOfRefraction;
  46892. /**
  46893. * Defines the index of refraction used in the material.
  46894. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46895. */
  46896. indexOfRefraction: number;
  46897. private _invertRefractionY;
  46898. /**
  46899. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46900. */
  46901. invertRefractionY: boolean;
  46902. private _linkRefractionWithTransparency;
  46903. /**
  46904. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46905. * Materials half opaque for instance using refraction could benefit from this control.
  46906. */
  46907. linkRefractionWithTransparency: boolean;
  46908. /**
  46909. * Defines the minimum thickness stored in the thickness map.
  46910. * If no thickness map is defined, this value will be used to simulate thickness.
  46911. */
  46912. minimumThickness: number;
  46913. /**
  46914. * Defines the maximum thickness stored in the thickness map.
  46915. */
  46916. maximumThickness: number;
  46917. /**
  46918. * Defines the volume tint of the material.
  46919. * This is used for both translucency and scattering.
  46920. */
  46921. tintColor: Color3;
  46922. /**
  46923. * Defines the distance at which the tint color should be found in the media.
  46924. * This is used for refraction only.
  46925. */
  46926. tintColorAtDistance: number;
  46927. /**
  46928. * Defines how far each channel transmit through the media.
  46929. * It is defined as a color to simplify it selection.
  46930. */
  46931. diffusionDistance: Color3;
  46932. private _useMaskFromThicknessTexture;
  46933. /**
  46934. * Stores the intensity of the different subsurface effects in the thickness texture.
  46935. * * the green channel is the translucency intensity.
  46936. * * the blue channel is the scattering intensity.
  46937. * * the alpha channel is the refraction intensity.
  46938. */
  46939. useMaskFromThicknessTexture: boolean;
  46940. /** @hidden */
  46941. private _internalMarkAllSubMeshesAsTexturesDirty;
  46942. /** @hidden */
  46943. _markAllSubMeshesAsTexturesDirty(): void;
  46944. /**
  46945. * Instantiate a new istance of sub surface configuration.
  46946. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46947. */
  46948. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46949. /**
  46950. * Gets wehter the submesh is ready to be used or not.
  46951. * @param defines the list of "defines" to update.
  46952. * @param scene defines the scene the material belongs to.
  46953. * @returns - boolean indicating that the submesh is ready or not.
  46954. */
  46955. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46956. /**
  46957. * Checks to see if a texture is used in the material.
  46958. * @param defines the list of "defines" to update.
  46959. * @param scene defines the scene to the material belongs to.
  46960. */
  46961. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46962. /**
  46963. * Binds the material data.
  46964. * @param uniformBuffer defines the Uniform buffer to fill in.
  46965. * @param scene defines the scene the material belongs to.
  46966. * @param engine defines the engine the material belongs to.
  46967. * @param isFrozen defines wether the material is frozen or not.
  46968. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46969. */
  46970. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46971. /**
  46972. * Unbinds the material from the mesh.
  46973. * @param activeEffect defines the effect that should be unbound from.
  46974. * @returns true if unbound, otherwise false
  46975. */
  46976. unbind(activeEffect: Effect): boolean;
  46977. /**
  46978. * Returns the texture used for refraction or null if none is used.
  46979. * @param scene defines the scene the material belongs to.
  46980. * @returns - Refraction texture if present. If no refraction texture and refraction
  46981. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46982. */
  46983. private _getRefractionTexture;
  46984. /**
  46985. * Returns true if alpha blending should be disabled.
  46986. */
  46987. readonly disableAlphaBlending: boolean;
  46988. /**
  46989. * Fills the list of render target textures.
  46990. * @param renderTargets the list of render targets to update
  46991. */
  46992. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46993. /**
  46994. * Checks to see if a texture is used in the material.
  46995. * @param texture - Base texture to use.
  46996. * @returns - Boolean specifying if a texture is used in the material.
  46997. */
  46998. hasTexture(texture: BaseTexture): boolean;
  46999. /**
  47000. * Gets a boolean indicating that current material needs to register RTT
  47001. * @returns true if this uses a render target otherwise false.
  47002. */
  47003. hasRenderTargetTextures(): boolean;
  47004. /**
  47005. * Returns an array of the actively used textures.
  47006. * @param activeTextures Array of BaseTextures
  47007. */
  47008. getActiveTextures(activeTextures: BaseTexture[]): void;
  47009. /**
  47010. * Returns the animatable textures.
  47011. * @param animatables Array of animatable textures.
  47012. */
  47013. getAnimatables(animatables: IAnimatable[]): void;
  47014. /**
  47015. * Disposes the resources of the material.
  47016. * @param forceDisposeTextures - Forces the disposal of all textures.
  47017. */
  47018. dispose(forceDisposeTextures?: boolean): void;
  47019. /**
  47020. * Get the current class name of the texture useful for serialization or dynamic coding.
  47021. * @returns "PBRSubSurfaceConfiguration"
  47022. */
  47023. getClassName(): string;
  47024. /**
  47025. * Add fallbacks to the effect fallbacks list.
  47026. * @param defines defines the Base texture to use.
  47027. * @param fallbacks defines the current fallback list.
  47028. * @param currentRank defines the current fallback rank.
  47029. * @returns the new fallback rank.
  47030. */
  47031. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47032. /**
  47033. * Add the required uniforms to the current list.
  47034. * @param uniforms defines the current uniform list.
  47035. */
  47036. static AddUniforms(uniforms: string[]): void;
  47037. /**
  47038. * Add the required samplers to the current list.
  47039. * @param samplers defines the current sampler list.
  47040. */
  47041. static AddSamplers(samplers: string[]): void;
  47042. /**
  47043. * Add the required uniforms to the current buffer.
  47044. * @param uniformBuffer defines the current uniform buffer.
  47045. */
  47046. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47047. /**
  47048. * Makes a duplicate of the current configuration into another one.
  47049. * @param configuration define the config where to copy the info
  47050. */
  47051. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47052. /**
  47053. * Serializes this Sub Surface configuration.
  47054. * @returns - An object with the serialized config.
  47055. */
  47056. serialize(): any;
  47057. /**
  47058. * Parses a Sub Surface Configuration from a serialized object.
  47059. * @param source - Serialized object.
  47060. */
  47061. parse(source: any): void;
  47062. }
  47063. }
  47064. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47065. /** @hidden */
  47066. export var pbrFragmentDeclaration: {
  47067. name: string;
  47068. shader: string;
  47069. };
  47070. }
  47071. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47072. /** @hidden */
  47073. export var pbrUboDeclaration: {
  47074. name: string;
  47075. shader: string;
  47076. };
  47077. }
  47078. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47079. /** @hidden */
  47080. export var pbrFragmentExtraDeclaration: {
  47081. name: string;
  47082. shader: string;
  47083. };
  47084. }
  47085. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47086. /** @hidden */
  47087. export var pbrFragmentSamplersDeclaration: {
  47088. name: string;
  47089. shader: string;
  47090. };
  47091. }
  47092. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47093. /** @hidden */
  47094. export var pbrHelperFunctions: {
  47095. name: string;
  47096. shader: string;
  47097. };
  47098. }
  47099. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47100. /** @hidden */
  47101. export var harmonicsFunctions: {
  47102. name: string;
  47103. shader: string;
  47104. };
  47105. }
  47106. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47107. /** @hidden */
  47108. export var pbrDirectLightingSetupFunctions: {
  47109. name: string;
  47110. shader: string;
  47111. };
  47112. }
  47113. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47114. /** @hidden */
  47115. export var pbrDirectLightingFalloffFunctions: {
  47116. name: string;
  47117. shader: string;
  47118. };
  47119. }
  47120. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47121. /** @hidden */
  47122. export var pbrBRDFFunctions: {
  47123. name: string;
  47124. shader: string;
  47125. };
  47126. }
  47127. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47128. /** @hidden */
  47129. export var pbrDirectLightingFunctions: {
  47130. name: string;
  47131. shader: string;
  47132. };
  47133. }
  47134. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47135. /** @hidden */
  47136. export var pbrIBLFunctions: {
  47137. name: string;
  47138. shader: string;
  47139. };
  47140. }
  47141. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47142. /** @hidden */
  47143. export var pbrDebug: {
  47144. name: string;
  47145. shader: string;
  47146. };
  47147. }
  47148. declare module "babylonjs/Shaders/pbr.fragment" {
  47149. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47150. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47151. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47152. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47153. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47154. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47155. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47156. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47157. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47158. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47159. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47160. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47161. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47162. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47163. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47164. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47165. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47166. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47167. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47168. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47169. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47170. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47171. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47172. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47173. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47174. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47175. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47176. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47177. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47178. /** @hidden */
  47179. export var pbrPixelShader: {
  47180. name: string;
  47181. shader: string;
  47182. };
  47183. }
  47184. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47185. /** @hidden */
  47186. export var pbrVertexDeclaration: {
  47187. name: string;
  47188. shader: string;
  47189. };
  47190. }
  47191. declare module "babylonjs/Shaders/pbr.vertex" {
  47192. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47193. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47194. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47195. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47196. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47197. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47198. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47199. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47200. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47201. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47202. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47203. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47204. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47205. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47206. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47207. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47208. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47209. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47210. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47211. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47212. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47213. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47214. /** @hidden */
  47215. export var pbrVertexShader: {
  47216. name: string;
  47217. shader: string;
  47218. };
  47219. }
  47220. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47221. import { IAnimatable } from "babylonjs/Misc/tools";
  47222. import { Nullable } from "babylonjs/types";
  47223. import { Scene } from "babylonjs/scene";
  47224. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47225. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47227. import { Mesh } from "babylonjs/Meshes/mesh";
  47228. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47229. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47230. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47231. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47232. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47233. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47234. import { Material } from "babylonjs/Materials/material";
  47235. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47236. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47238. import "babylonjs/Shaders/pbr.fragment";
  47239. import "babylonjs/Shaders/pbr.vertex";
  47240. /**
  47241. * Manages the defines for the PBR Material.
  47242. * @hidden
  47243. */
  47244. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47245. PBR: boolean;
  47246. MAINUV1: boolean;
  47247. MAINUV2: boolean;
  47248. UV1: boolean;
  47249. UV2: boolean;
  47250. ALBEDO: boolean;
  47251. ALBEDODIRECTUV: number;
  47252. VERTEXCOLOR: boolean;
  47253. AMBIENT: boolean;
  47254. AMBIENTDIRECTUV: number;
  47255. AMBIENTINGRAYSCALE: boolean;
  47256. OPACITY: boolean;
  47257. VERTEXALPHA: boolean;
  47258. OPACITYDIRECTUV: number;
  47259. OPACITYRGB: boolean;
  47260. ALPHATEST: boolean;
  47261. DEPTHPREPASS: boolean;
  47262. ALPHABLEND: boolean;
  47263. ALPHAFROMALBEDO: boolean;
  47264. ALPHATESTVALUE: string;
  47265. SPECULAROVERALPHA: boolean;
  47266. RADIANCEOVERALPHA: boolean;
  47267. ALPHAFRESNEL: boolean;
  47268. LINEARALPHAFRESNEL: boolean;
  47269. PREMULTIPLYALPHA: boolean;
  47270. EMISSIVE: boolean;
  47271. EMISSIVEDIRECTUV: number;
  47272. REFLECTIVITY: boolean;
  47273. REFLECTIVITYDIRECTUV: number;
  47274. SPECULARTERM: boolean;
  47275. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47276. MICROSURFACEAUTOMATIC: boolean;
  47277. LODBASEDMICROSFURACE: boolean;
  47278. MICROSURFACEMAP: boolean;
  47279. MICROSURFACEMAPDIRECTUV: number;
  47280. METALLICWORKFLOW: boolean;
  47281. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47282. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47283. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47284. AOSTOREINMETALMAPRED: boolean;
  47285. ENVIRONMENTBRDF: boolean;
  47286. ENVIRONMENTBRDF_RGBD: boolean;
  47287. NORMAL: boolean;
  47288. TANGENT: boolean;
  47289. BUMP: boolean;
  47290. BUMPDIRECTUV: number;
  47291. OBJECTSPACE_NORMALMAP: boolean;
  47292. PARALLAX: boolean;
  47293. PARALLAXOCCLUSION: boolean;
  47294. NORMALXYSCALE: boolean;
  47295. LIGHTMAP: boolean;
  47296. LIGHTMAPDIRECTUV: number;
  47297. USELIGHTMAPASSHADOWMAP: boolean;
  47298. GAMMALIGHTMAP: boolean;
  47299. REFLECTION: boolean;
  47300. REFLECTIONMAP_3D: boolean;
  47301. REFLECTIONMAP_SPHERICAL: boolean;
  47302. REFLECTIONMAP_PLANAR: boolean;
  47303. REFLECTIONMAP_CUBIC: boolean;
  47304. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47305. REFLECTIONMAP_PROJECTION: boolean;
  47306. REFLECTIONMAP_SKYBOX: boolean;
  47307. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47308. REFLECTIONMAP_EXPLICIT: boolean;
  47309. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47310. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47311. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47312. INVERTCUBICMAP: boolean;
  47313. USESPHERICALFROMREFLECTIONMAP: boolean;
  47314. USEIRRADIANCEMAP: boolean;
  47315. SPHERICAL_HARMONICS: boolean;
  47316. USESPHERICALINVERTEX: boolean;
  47317. REFLECTIONMAP_OPPOSITEZ: boolean;
  47318. LODINREFLECTIONALPHA: boolean;
  47319. GAMMAREFLECTION: boolean;
  47320. RGBDREFLECTION: boolean;
  47321. LINEARSPECULARREFLECTION: boolean;
  47322. RADIANCEOCCLUSION: boolean;
  47323. HORIZONOCCLUSION: boolean;
  47324. INSTANCES: boolean;
  47325. NUM_BONE_INFLUENCERS: number;
  47326. BonesPerMesh: number;
  47327. BONETEXTURE: boolean;
  47328. NONUNIFORMSCALING: boolean;
  47329. MORPHTARGETS: boolean;
  47330. MORPHTARGETS_NORMAL: boolean;
  47331. MORPHTARGETS_TANGENT: boolean;
  47332. NUM_MORPH_INFLUENCERS: number;
  47333. IMAGEPROCESSING: boolean;
  47334. VIGNETTE: boolean;
  47335. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47336. VIGNETTEBLENDMODEOPAQUE: boolean;
  47337. TONEMAPPING: boolean;
  47338. TONEMAPPING_ACES: boolean;
  47339. CONTRAST: boolean;
  47340. COLORCURVES: boolean;
  47341. COLORGRADING: boolean;
  47342. COLORGRADING3D: boolean;
  47343. SAMPLER3DGREENDEPTH: boolean;
  47344. SAMPLER3DBGRMAP: boolean;
  47345. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47346. EXPOSURE: boolean;
  47347. MULTIVIEW: boolean;
  47348. USEPHYSICALLIGHTFALLOFF: boolean;
  47349. USEGLTFLIGHTFALLOFF: boolean;
  47350. TWOSIDEDLIGHTING: boolean;
  47351. SHADOWFLOAT: boolean;
  47352. CLIPPLANE: boolean;
  47353. CLIPPLANE2: boolean;
  47354. CLIPPLANE3: boolean;
  47355. CLIPPLANE4: boolean;
  47356. POINTSIZE: boolean;
  47357. FOG: boolean;
  47358. LOGARITHMICDEPTH: boolean;
  47359. FORCENORMALFORWARD: boolean;
  47360. SPECULARAA: boolean;
  47361. CLEARCOAT: boolean;
  47362. CLEARCOAT_DEFAULTIOR: boolean;
  47363. CLEARCOAT_TEXTURE: boolean;
  47364. CLEARCOAT_TEXTUREDIRECTUV: number;
  47365. CLEARCOAT_BUMP: boolean;
  47366. CLEARCOAT_BUMPDIRECTUV: number;
  47367. CLEARCOAT_TINT: boolean;
  47368. CLEARCOAT_TINT_TEXTURE: boolean;
  47369. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47370. ANISOTROPIC: boolean;
  47371. ANISOTROPIC_TEXTURE: boolean;
  47372. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47373. BRDF_V_HEIGHT_CORRELATED: boolean;
  47374. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47375. SHEEN: boolean;
  47376. SHEEN_TEXTURE: boolean;
  47377. SHEEN_TEXTUREDIRECTUV: number;
  47378. SHEEN_LINKWITHALBEDO: boolean;
  47379. SUBSURFACE: boolean;
  47380. SS_REFRACTION: boolean;
  47381. SS_TRANSLUCENCY: boolean;
  47382. SS_SCATERRING: boolean;
  47383. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47384. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47385. SS_REFRACTIONMAP_3D: boolean;
  47386. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47387. SS_LODINREFRACTIONALPHA: boolean;
  47388. SS_GAMMAREFRACTION: boolean;
  47389. SS_RGBDREFRACTION: boolean;
  47390. SS_LINEARSPECULARREFRACTION: boolean;
  47391. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47392. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47393. UNLIT: boolean;
  47394. DEBUGMODE: number;
  47395. /**
  47396. * Initializes the PBR Material defines.
  47397. */
  47398. constructor();
  47399. /**
  47400. * Resets the PBR Material defines.
  47401. */
  47402. reset(): void;
  47403. }
  47404. /**
  47405. * The Physically based material base class of BJS.
  47406. *
  47407. * This offers the main features of a standard PBR material.
  47408. * For more information, please refer to the documentation :
  47409. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47410. */
  47411. export abstract class PBRBaseMaterial extends PushMaterial {
  47412. /**
  47413. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47414. */
  47415. static readonly PBRMATERIAL_OPAQUE: number;
  47416. /**
  47417. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47418. */
  47419. static readonly PBRMATERIAL_ALPHATEST: number;
  47420. /**
  47421. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47422. */
  47423. static readonly PBRMATERIAL_ALPHABLEND: number;
  47424. /**
  47425. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47426. * They are also discarded below the alpha cutoff threshold to improve performances.
  47427. */
  47428. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47429. /**
  47430. * Defines the default value of how much AO map is occluding the analytical lights
  47431. * (point spot...).
  47432. */
  47433. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47434. /**
  47435. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47436. */
  47437. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47438. /**
  47439. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47440. * to enhance interoperability with other engines.
  47441. */
  47442. static readonly LIGHTFALLOFF_GLTF: number;
  47443. /**
  47444. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47445. * to enhance interoperability with other materials.
  47446. */
  47447. static readonly LIGHTFALLOFF_STANDARD: number;
  47448. /**
  47449. * Intensity of the direct lights e.g. the four lights available in your scene.
  47450. * This impacts both the direct diffuse and specular highlights.
  47451. */
  47452. protected _directIntensity: number;
  47453. /**
  47454. * Intensity of the emissive part of the material.
  47455. * This helps controlling the emissive effect without modifying the emissive color.
  47456. */
  47457. protected _emissiveIntensity: number;
  47458. /**
  47459. * Intensity of the environment e.g. how much the environment will light the object
  47460. * either through harmonics for rough material or through the refelction for shiny ones.
  47461. */
  47462. protected _environmentIntensity: number;
  47463. /**
  47464. * This is a special control allowing the reduction of the specular highlights coming from the
  47465. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47466. */
  47467. protected _specularIntensity: number;
  47468. /**
  47469. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47470. */
  47471. private _lightingInfos;
  47472. /**
  47473. * Debug Control allowing disabling the bump map on this material.
  47474. */
  47475. protected _disableBumpMap: boolean;
  47476. /**
  47477. * AKA Diffuse Texture in standard nomenclature.
  47478. */
  47479. protected _albedoTexture: Nullable<BaseTexture>;
  47480. /**
  47481. * AKA Occlusion Texture in other nomenclature.
  47482. */
  47483. protected _ambientTexture: Nullable<BaseTexture>;
  47484. /**
  47485. * AKA Occlusion Texture Intensity in other nomenclature.
  47486. */
  47487. protected _ambientTextureStrength: number;
  47488. /**
  47489. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47490. * 1 means it completely occludes it
  47491. * 0 mean it has no impact
  47492. */
  47493. protected _ambientTextureImpactOnAnalyticalLights: number;
  47494. /**
  47495. * Stores the alpha values in a texture.
  47496. */
  47497. protected _opacityTexture: Nullable<BaseTexture>;
  47498. /**
  47499. * Stores the reflection values in a texture.
  47500. */
  47501. protected _reflectionTexture: Nullable<BaseTexture>;
  47502. /**
  47503. * Stores the emissive values in a texture.
  47504. */
  47505. protected _emissiveTexture: Nullable<BaseTexture>;
  47506. /**
  47507. * AKA Specular texture in other nomenclature.
  47508. */
  47509. protected _reflectivityTexture: Nullable<BaseTexture>;
  47510. /**
  47511. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47512. */
  47513. protected _metallicTexture: Nullable<BaseTexture>;
  47514. /**
  47515. * Specifies the metallic scalar of the metallic/roughness workflow.
  47516. * Can also be used to scale the metalness values of the metallic texture.
  47517. */
  47518. protected _metallic: Nullable<number>;
  47519. /**
  47520. * Specifies the roughness scalar of the metallic/roughness workflow.
  47521. * Can also be used to scale the roughness values of the metallic texture.
  47522. */
  47523. protected _roughness: Nullable<number>;
  47524. /**
  47525. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47526. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47527. */
  47528. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47529. /**
  47530. * Stores surface normal data used to displace a mesh in a texture.
  47531. */
  47532. protected _bumpTexture: Nullable<BaseTexture>;
  47533. /**
  47534. * Stores the pre-calculated light information of a mesh in a texture.
  47535. */
  47536. protected _lightmapTexture: Nullable<BaseTexture>;
  47537. /**
  47538. * The color of a material in ambient lighting.
  47539. */
  47540. protected _ambientColor: Color3;
  47541. /**
  47542. * AKA Diffuse Color in other nomenclature.
  47543. */
  47544. protected _albedoColor: Color3;
  47545. /**
  47546. * AKA Specular Color in other nomenclature.
  47547. */
  47548. protected _reflectivityColor: Color3;
  47549. /**
  47550. * The color applied when light is reflected from a material.
  47551. */
  47552. protected _reflectionColor: Color3;
  47553. /**
  47554. * The color applied when light is emitted from a material.
  47555. */
  47556. protected _emissiveColor: Color3;
  47557. /**
  47558. * AKA Glossiness in other nomenclature.
  47559. */
  47560. protected _microSurface: number;
  47561. /**
  47562. * Specifies that the material will use the light map as a show map.
  47563. */
  47564. protected _useLightmapAsShadowmap: boolean;
  47565. /**
  47566. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47567. * makes the reflect vector face the model (under horizon).
  47568. */
  47569. protected _useHorizonOcclusion: boolean;
  47570. /**
  47571. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47572. * too much the area relying on ambient texture to define their ambient occlusion.
  47573. */
  47574. protected _useRadianceOcclusion: boolean;
  47575. /**
  47576. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47577. */
  47578. protected _useAlphaFromAlbedoTexture: boolean;
  47579. /**
  47580. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47581. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47582. */
  47583. protected _useSpecularOverAlpha: boolean;
  47584. /**
  47585. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47586. */
  47587. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47588. /**
  47589. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47590. */
  47591. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47592. /**
  47593. * Specifies if the metallic texture contains the roughness information in its green channel.
  47594. */
  47595. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47596. /**
  47597. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47598. */
  47599. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47600. /**
  47601. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47602. */
  47603. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47604. /**
  47605. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47606. */
  47607. protected _useAmbientInGrayScale: boolean;
  47608. /**
  47609. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47610. * The material will try to infer what glossiness each pixel should be.
  47611. */
  47612. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47613. /**
  47614. * Defines the falloff type used in this material.
  47615. * It by default is Physical.
  47616. */
  47617. protected _lightFalloff: number;
  47618. /**
  47619. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47620. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47621. */
  47622. protected _useRadianceOverAlpha: boolean;
  47623. /**
  47624. * Allows using an object space normal map (instead of tangent space).
  47625. */
  47626. protected _useObjectSpaceNormalMap: boolean;
  47627. /**
  47628. * Allows using the bump map in parallax mode.
  47629. */
  47630. protected _useParallax: boolean;
  47631. /**
  47632. * Allows using the bump map in parallax occlusion mode.
  47633. */
  47634. protected _useParallaxOcclusion: boolean;
  47635. /**
  47636. * Controls the scale bias of the parallax mode.
  47637. */
  47638. protected _parallaxScaleBias: number;
  47639. /**
  47640. * If sets to true, disables all the lights affecting the material.
  47641. */
  47642. protected _disableLighting: boolean;
  47643. /**
  47644. * Number of Simultaneous lights allowed on the material.
  47645. */
  47646. protected _maxSimultaneousLights: number;
  47647. /**
  47648. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47649. */
  47650. protected _invertNormalMapX: boolean;
  47651. /**
  47652. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47653. */
  47654. protected _invertNormalMapY: boolean;
  47655. /**
  47656. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47657. */
  47658. protected _twoSidedLighting: boolean;
  47659. /**
  47660. * Defines the alpha limits in alpha test mode.
  47661. */
  47662. protected _alphaCutOff: number;
  47663. /**
  47664. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47665. */
  47666. protected _forceAlphaTest: boolean;
  47667. /**
  47668. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47669. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47670. */
  47671. protected _useAlphaFresnel: boolean;
  47672. /**
  47673. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47674. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47675. */
  47676. protected _useLinearAlphaFresnel: boolean;
  47677. /**
  47678. * The transparency mode of the material.
  47679. */
  47680. protected _transparencyMode: Nullable<number>;
  47681. /**
  47682. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47683. * from cos thetav and roughness:
  47684. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47685. */
  47686. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47687. /**
  47688. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47689. */
  47690. protected _forceIrradianceInFragment: boolean;
  47691. /**
  47692. * Force normal to face away from face.
  47693. */
  47694. protected _forceNormalForward: boolean;
  47695. /**
  47696. * Enables specular anti aliasing in the PBR shader.
  47697. * It will both interacts on the Geometry for analytical and IBL lighting.
  47698. * It also prefilter the roughness map based on the bump values.
  47699. */
  47700. protected _enableSpecularAntiAliasing: boolean;
  47701. /**
  47702. * Default configuration related to image processing available in the PBR Material.
  47703. */
  47704. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47705. /**
  47706. * Keep track of the image processing observer to allow dispose and replace.
  47707. */
  47708. private _imageProcessingObserver;
  47709. /**
  47710. * Attaches a new image processing configuration to the PBR Material.
  47711. * @param configuration
  47712. */
  47713. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47714. /**
  47715. * Stores the available render targets.
  47716. */
  47717. private _renderTargets;
  47718. /**
  47719. * Sets the global ambient color for the material used in lighting calculations.
  47720. */
  47721. private _globalAmbientColor;
  47722. /**
  47723. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47724. */
  47725. private _useLogarithmicDepth;
  47726. /**
  47727. * If set to true, no lighting calculations will be applied.
  47728. */
  47729. private _unlit;
  47730. private _debugMode;
  47731. /**
  47732. * @hidden
  47733. * This is reserved for the inspector.
  47734. * Defines the material debug mode.
  47735. * It helps seeing only some components of the material while troubleshooting.
  47736. */
  47737. debugMode: number;
  47738. /**
  47739. * @hidden
  47740. * This is reserved for the inspector.
  47741. * Specify from where on screen the debug mode should start.
  47742. * The value goes from -1 (full screen) to 1 (not visible)
  47743. * It helps with side by side comparison against the final render
  47744. * This defaults to -1
  47745. */
  47746. private debugLimit;
  47747. /**
  47748. * @hidden
  47749. * This is reserved for the inspector.
  47750. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47751. * You can use the factor to better multiply the final value.
  47752. */
  47753. private debugFactor;
  47754. /**
  47755. * Defines the clear coat layer parameters for the material.
  47756. */
  47757. readonly clearCoat: PBRClearCoatConfiguration;
  47758. /**
  47759. * Defines the anisotropic parameters for the material.
  47760. */
  47761. readonly anisotropy: PBRAnisotropicConfiguration;
  47762. /**
  47763. * Defines the BRDF parameters for the material.
  47764. */
  47765. readonly brdf: PBRBRDFConfiguration;
  47766. /**
  47767. * Defines the Sheen parameters for the material.
  47768. */
  47769. readonly sheen: PBRSheenConfiguration;
  47770. /**
  47771. * Defines the SubSurface parameters for the material.
  47772. */
  47773. readonly subSurface: PBRSubSurfaceConfiguration;
  47774. /**
  47775. * Custom callback helping to override the default shader used in the material.
  47776. */
  47777. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47778. /**
  47779. * Instantiates a new PBRMaterial instance.
  47780. *
  47781. * @param name The material name
  47782. * @param scene The scene the material will be use in.
  47783. */
  47784. constructor(name: string, scene: Scene);
  47785. /**
  47786. * Gets a boolean indicating that current material needs to register RTT
  47787. */
  47788. readonly hasRenderTargetTextures: boolean;
  47789. /**
  47790. * Gets the name of the material class.
  47791. */
  47792. getClassName(): string;
  47793. /**
  47794. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47795. */
  47796. /**
  47797. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47798. */
  47799. useLogarithmicDepth: boolean;
  47800. /**
  47801. * Gets the current transparency mode.
  47802. */
  47803. /**
  47804. * Sets the transparency mode of the material.
  47805. *
  47806. * | Value | Type | Description |
  47807. * | ----- | ----------------------------------- | ----------- |
  47808. * | 0 | OPAQUE | |
  47809. * | 1 | ALPHATEST | |
  47810. * | 2 | ALPHABLEND | |
  47811. * | 3 | ALPHATESTANDBLEND | |
  47812. *
  47813. */
  47814. transparencyMode: Nullable<number>;
  47815. /**
  47816. * Returns true if alpha blending should be disabled.
  47817. */
  47818. private readonly _disableAlphaBlending;
  47819. /**
  47820. * Specifies whether or not this material should be rendered in alpha blend mode.
  47821. */
  47822. needAlphaBlending(): boolean;
  47823. /**
  47824. * Specifies if the mesh will require alpha blending.
  47825. * @param mesh - BJS mesh.
  47826. */
  47827. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47828. /**
  47829. * Specifies whether or not this material should be rendered in alpha test mode.
  47830. */
  47831. needAlphaTesting(): boolean;
  47832. /**
  47833. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47834. */
  47835. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47836. /**
  47837. * Gets the texture used for the alpha test.
  47838. */
  47839. getAlphaTestTexture(): Nullable<BaseTexture>;
  47840. /**
  47841. * Specifies that the submesh is ready to be used.
  47842. * @param mesh - BJS mesh.
  47843. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47844. * @param useInstances - Specifies that instances should be used.
  47845. * @returns - boolean indicating that the submesh is ready or not.
  47846. */
  47847. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47848. /**
  47849. * Specifies if the material uses metallic roughness workflow.
  47850. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47851. */
  47852. isMetallicWorkflow(): boolean;
  47853. private _prepareEffect;
  47854. private _prepareDefines;
  47855. /**
  47856. * Force shader compilation
  47857. */
  47858. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47859. clipPlane: boolean;
  47860. }>): void;
  47861. /**
  47862. * Initializes the uniform buffer layout for the shader.
  47863. */
  47864. buildUniformLayout(): void;
  47865. /**
  47866. * Unbinds the material from the mesh
  47867. */
  47868. unbind(): void;
  47869. /**
  47870. * Binds the submesh data.
  47871. * @param world - The world matrix.
  47872. * @param mesh - The BJS mesh.
  47873. * @param subMesh - A submesh of the BJS mesh.
  47874. */
  47875. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47876. /**
  47877. * Returns the animatable textures.
  47878. * @returns - Array of animatable textures.
  47879. */
  47880. getAnimatables(): IAnimatable[];
  47881. /**
  47882. * Returns the texture used for reflections.
  47883. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47884. */
  47885. private _getReflectionTexture;
  47886. /**
  47887. * Returns an array of the actively used textures.
  47888. * @returns - Array of BaseTextures
  47889. */
  47890. getActiveTextures(): BaseTexture[];
  47891. /**
  47892. * Checks to see if a texture is used in the material.
  47893. * @param texture - Base texture to use.
  47894. * @returns - Boolean specifying if a texture is used in the material.
  47895. */
  47896. hasTexture(texture: BaseTexture): boolean;
  47897. /**
  47898. * Disposes the resources of the material.
  47899. * @param forceDisposeEffect - Forces the disposal of effects.
  47900. * @param forceDisposeTextures - Forces the disposal of all textures.
  47901. */
  47902. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47903. }
  47904. }
  47905. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47906. import { Nullable } from "babylonjs/types";
  47907. import { Scene } from "babylonjs/scene";
  47908. import { Color3 } from "babylonjs/Maths/math";
  47909. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47910. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47912. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47913. /**
  47914. * The Physically based material of BJS.
  47915. *
  47916. * This offers the main features of a standard PBR material.
  47917. * For more information, please refer to the documentation :
  47918. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47919. */
  47920. export class PBRMaterial extends PBRBaseMaterial {
  47921. /**
  47922. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47923. */
  47924. static readonly PBRMATERIAL_OPAQUE: number;
  47925. /**
  47926. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47927. */
  47928. static readonly PBRMATERIAL_ALPHATEST: number;
  47929. /**
  47930. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47931. */
  47932. static readonly PBRMATERIAL_ALPHABLEND: number;
  47933. /**
  47934. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47935. * They are also discarded below the alpha cutoff threshold to improve performances.
  47936. */
  47937. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47938. /**
  47939. * Defines the default value of how much AO map is occluding the analytical lights
  47940. * (point spot...).
  47941. */
  47942. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47943. /**
  47944. * Intensity of the direct lights e.g. the four lights available in your scene.
  47945. * This impacts both the direct diffuse and specular highlights.
  47946. */
  47947. directIntensity: number;
  47948. /**
  47949. * Intensity of the emissive part of the material.
  47950. * This helps controlling the emissive effect without modifying the emissive color.
  47951. */
  47952. emissiveIntensity: number;
  47953. /**
  47954. * Intensity of the environment e.g. how much the environment will light the object
  47955. * either through harmonics for rough material or through the refelction for shiny ones.
  47956. */
  47957. environmentIntensity: number;
  47958. /**
  47959. * This is a special control allowing the reduction of the specular highlights coming from the
  47960. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47961. */
  47962. specularIntensity: number;
  47963. /**
  47964. * Debug Control allowing disabling the bump map on this material.
  47965. */
  47966. disableBumpMap: boolean;
  47967. /**
  47968. * AKA Diffuse Texture in standard nomenclature.
  47969. */
  47970. albedoTexture: BaseTexture;
  47971. /**
  47972. * AKA Occlusion Texture in other nomenclature.
  47973. */
  47974. ambientTexture: BaseTexture;
  47975. /**
  47976. * AKA Occlusion Texture Intensity in other nomenclature.
  47977. */
  47978. ambientTextureStrength: number;
  47979. /**
  47980. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47981. * 1 means it completely occludes it
  47982. * 0 mean it has no impact
  47983. */
  47984. ambientTextureImpactOnAnalyticalLights: number;
  47985. /**
  47986. * Stores the alpha values in a texture.
  47987. */
  47988. opacityTexture: BaseTexture;
  47989. /**
  47990. * Stores the reflection values in a texture.
  47991. */
  47992. reflectionTexture: Nullable<BaseTexture>;
  47993. /**
  47994. * Stores the emissive values in a texture.
  47995. */
  47996. emissiveTexture: BaseTexture;
  47997. /**
  47998. * AKA Specular texture in other nomenclature.
  47999. */
  48000. reflectivityTexture: BaseTexture;
  48001. /**
  48002. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48003. */
  48004. metallicTexture: BaseTexture;
  48005. /**
  48006. * Specifies the metallic scalar of the metallic/roughness workflow.
  48007. * Can also be used to scale the metalness values of the metallic texture.
  48008. */
  48009. metallic: Nullable<number>;
  48010. /**
  48011. * Specifies the roughness scalar of the metallic/roughness workflow.
  48012. * Can also be used to scale the roughness values of the metallic texture.
  48013. */
  48014. roughness: Nullable<number>;
  48015. /**
  48016. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48017. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48018. */
  48019. microSurfaceTexture: BaseTexture;
  48020. /**
  48021. * Stores surface normal data used to displace a mesh in a texture.
  48022. */
  48023. bumpTexture: BaseTexture;
  48024. /**
  48025. * Stores the pre-calculated light information of a mesh in a texture.
  48026. */
  48027. lightmapTexture: BaseTexture;
  48028. /**
  48029. * Stores the refracted light information in a texture.
  48030. */
  48031. refractionTexture: Nullable<BaseTexture>;
  48032. /**
  48033. * The color of a material in ambient lighting.
  48034. */
  48035. ambientColor: Color3;
  48036. /**
  48037. * AKA Diffuse Color in other nomenclature.
  48038. */
  48039. albedoColor: Color3;
  48040. /**
  48041. * AKA Specular Color in other nomenclature.
  48042. */
  48043. reflectivityColor: Color3;
  48044. /**
  48045. * The color reflected from the material.
  48046. */
  48047. reflectionColor: Color3;
  48048. /**
  48049. * The color emitted from the material.
  48050. */
  48051. emissiveColor: Color3;
  48052. /**
  48053. * AKA Glossiness in other nomenclature.
  48054. */
  48055. microSurface: number;
  48056. /**
  48057. * source material index of refraction (IOR)' / 'destination material IOR.
  48058. */
  48059. indexOfRefraction: number;
  48060. /**
  48061. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48062. */
  48063. invertRefractionY: boolean;
  48064. /**
  48065. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48066. * Materials half opaque for instance using refraction could benefit from this control.
  48067. */
  48068. linkRefractionWithTransparency: boolean;
  48069. /**
  48070. * If true, the light map contains occlusion information instead of lighting info.
  48071. */
  48072. useLightmapAsShadowmap: boolean;
  48073. /**
  48074. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48075. */
  48076. useAlphaFromAlbedoTexture: boolean;
  48077. /**
  48078. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48079. */
  48080. forceAlphaTest: boolean;
  48081. /**
  48082. * Defines the alpha limits in alpha test mode.
  48083. */
  48084. alphaCutOff: number;
  48085. /**
  48086. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48087. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48088. */
  48089. useSpecularOverAlpha: boolean;
  48090. /**
  48091. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48092. */
  48093. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48094. /**
  48095. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48096. */
  48097. useRoughnessFromMetallicTextureAlpha: boolean;
  48098. /**
  48099. * Specifies if the metallic texture contains the roughness information in its green channel.
  48100. */
  48101. useRoughnessFromMetallicTextureGreen: boolean;
  48102. /**
  48103. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48104. */
  48105. useMetallnessFromMetallicTextureBlue: boolean;
  48106. /**
  48107. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48108. */
  48109. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48110. /**
  48111. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48112. */
  48113. useAmbientInGrayScale: boolean;
  48114. /**
  48115. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48116. * The material will try to infer what glossiness each pixel should be.
  48117. */
  48118. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48119. /**
  48120. * BJS is using an harcoded light falloff based on a manually sets up range.
  48121. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48122. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48123. */
  48124. /**
  48125. * BJS is using an harcoded light falloff based on a manually sets up range.
  48126. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48127. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48128. */
  48129. usePhysicalLightFalloff: boolean;
  48130. /**
  48131. * In order to support the falloff compatibility with gltf, a special mode has been added
  48132. * to reproduce the gltf light falloff.
  48133. */
  48134. /**
  48135. * In order to support the falloff compatibility with gltf, a special mode has been added
  48136. * to reproduce the gltf light falloff.
  48137. */
  48138. useGLTFLightFalloff: boolean;
  48139. /**
  48140. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48141. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48142. */
  48143. useRadianceOverAlpha: boolean;
  48144. /**
  48145. * Allows using an object space normal map (instead of tangent space).
  48146. */
  48147. useObjectSpaceNormalMap: boolean;
  48148. /**
  48149. * Allows using the bump map in parallax mode.
  48150. */
  48151. useParallax: boolean;
  48152. /**
  48153. * Allows using the bump map in parallax occlusion mode.
  48154. */
  48155. useParallaxOcclusion: boolean;
  48156. /**
  48157. * Controls the scale bias of the parallax mode.
  48158. */
  48159. parallaxScaleBias: number;
  48160. /**
  48161. * If sets to true, disables all the lights affecting the material.
  48162. */
  48163. disableLighting: boolean;
  48164. /**
  48165. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48166. */
  48167. forceIrradianceInFragment: boolean;
  48168. /**
  48169. * Number of Simultaneous lights allowed on the material.
  48170. */
  48171. maxSimultaneousLights: number;
  48172. /**
  48173. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48174. */
  48175. invertNormalMapX: boolean;
  48176. /**
  48177. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48178. */
  48179. invertNormalMapY: boolean;
  48180. /**
  48181. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48182. */
  48183. twoSidedLighting: boolean;
  48184. /**
  48185. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48186. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48187. */
  48188. useAlphaFresnel: boolean;
  48189. /**
  48190. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48191. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48192. */
  48193. useLinearAlphaFresnel: boolean;
  48194. /**
  48195. * Let user defines the brdf lookup texture used for IBL.
  48196. * A default 8bit version is embedded but you could point at :
  48197. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  48198. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48199. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48200. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48201. */
  48202. environmentBRDFTexture: Nullable<BaseTexture>;
  48203. /**
  48204. * Force normal to face away from face.
  48205. */
  48206. forceNormalForward: boolean;
  48207. /**
  48208. * Enables specular anti aliasing in the PBR shader.
  48209. * It will both interacts on the Geometry for analytical and IBL lighting.
  48210. * It also prefilter the roughness map based on the bump values.
  48211. */
  48212. enableSpecularAntiAliasing: boolean;
  48213. /**
  48214. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48215. * makes the reflect vector face the model (under horizon).
  48216. */
  48217. useHorizonOcclusion: boolean;
  48218. /**
  48219. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48220. * too much the area relying on ambient texture to define their ambient occlusion.
  48221. */
  48222. useRadianceOcclusion: boolean;
  48223. /**
  48224. * If set to true, no lighting calculations will be applied.
  48225. */
  48226. unlit: boolean;
  48227. /**
  48228. * Gets the image processing configuration used either in this material.
  48229. */
  48230. /**
  48231. * Sets the Default image processing configuration used either in the this material.
  48232. *
  48233. * If sets to null, the scene one is in use.
  48234. */
  48235. imageProcessingConfiguration: ImageProcessingConfiguration;
  48236. /**
  48237. * Gets wether the color curves effect is enabled.
  48238. */
  48239. /**
  48240. * Sets wether the color curves effect is enabled.
  48241. */
  48242. cameraColorCurvesEnabled: boolean;
  48243. /**
  48244. * Gets wether the color grading effect is enabled.
  48245. */
  48246. /**
  48247. * Gets wether the color grading effect is enabled.
  48248. */
  48249. cameraColorGradingEnabled: boolean;
  48250. /**
  48251. * Gets wether tonemapping is enabled or not.
  48252. */
  48253. /**
  48254. * Sets wether tonemapping is enabled or not
  48255. */
  48256. cameraToneMappingEnabled: boolean;
  48257. /**
  48258. * The camera exposure used on this material.
  48259. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48260. * This corresponds to a photographic exposure.
  48261. */
  48262. /**
  48263. * The camera exposure used on this material.
  48264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48265. * This corresponds to a photographic exposure.
  48266. */
  48267. cameraExposure: number;
  48268. /**
  48269. * Gets The camera contrast used on this material.
  48270. */
  48271. /**
  48272. * Sets The camera contrast used on this material.
  48273. */
  48274. cameraContrast: number;
  48275. /**
  48276. * Gets the Color Grading 2D Lookup Texture.
  48277. */
  48278. /**
  48279. * Sets the Color Grading 2D Lookup Texture.
  48280. */
  48281. cameraColorGradingTexture: Nullable<BaseTexture>;
  48282. /**
  48283. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48284. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48285. * 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;
  48286. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48287. */
  48288. /**
  48289. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48290. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48291. * 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;
  48292. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48293. */
  48294. cameraColorCurves: Nullable<ColorCurves>;
  48295. /**
  48296. * Instantiates a new PBRMaterial instance.
  48297. *
  48298. * @param name The material name
  48299. * @param scene The scene the material will be use in.
  48300. */
  48301. constructor(name: string, scene: Scene);
  48302. /**
  48303. * Returns the name of this material class.
  48304. */
  48305. getClassName(): string;
  48306. /**
  48307. * Makes a duplicate of the current material.
  48308. * @param name - name to use for the new material.
  48309. */
  48310. clone(name: string): PBRMaterial;
  48311. /**
  48312. * Serializes this PBR Material.
  48313. * @returns - An object with the serialized material.
  48314. */
  48315. serialize(): any;
  48316. /**
  48317. * Parses a PBR Material from a serialized object.
  48318. * @param source - Serialized object.
  48319. * @param scene - BJS scene instance.
  48320. * @param rootUrl - url for the scene object
  48321. * @returns - PBRMaterial
  48322. */
  48323. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48324. }
  48325. }
  48326. declare module "babylonjs/Misc/dds" {
  48327. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48328. import { Engine } from "babylonjs/Engines/engine";
  48329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48330. import { Nullable } from "babylonjs/types";
  48331. import { Scene } from "babylonjs/scene";
  48332. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48333. /**
  48334. * Direct draw surface info
  48335. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48336. */
  48337. export interface DDSInfo {
  48338. /**
  48339. * Width of the texture
  48340. */
  48341. width: number;
  48342. /**
  48343. * Width of the texture
  48344. */
  48345. height: number;
  48346. /**
  48347. * Number of Mipmaps for the texture
  48348. * @see https://en.wikipedia.org/wiki/Mipmap
  48349. */
  48350. mipmapCount: number;
  48351. /**
  48352. * If the textures format is a known fourCC format
  48353. * @see https://www.fourcc.org/
  48354. */
  48355. isFourCC: boolean;
  48356. /**
  48357. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48358. */
  48359. isRGB: boolean;
  48360. /**
  48361. * If the texture is a lumincance format
  48362. */
  48363. isLuminance: boolean;
  48364. /**
  48365. * If this is a cube texture
  48366. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48367. */
  48368. isCube: boolean;
  48369. /**
  48370. * If the texture is a compressed format eg. FOURCC_DXT1
  48371. */
  48372. isCompressed: boolean;
  48373. /**
  48374. * The dxgiFormat of the texture
  48375. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48376. */
  48377. dxgiFormat: number;
  48378. /**
  48379. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48380. */
  48381. textureType: number;
  48382. /**
  48383. * Sphericle polynomial created for the dds texture
  48384. */
  48385. sphericalPolynomial?: SphericalPolynomial;
  48386. }
  48387. /**
  48388. * Class used to provide DDS decompression tools
  48389. */
  48390. export class DDSTools {
  48391. /**
  48392. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48393. */
  48394. static StoreLODInAlphaChannel: boolean;
  48395. /**
  48396. * Gets DDS information from an array buffer
  48397. * @param arrayBuffer defines the array buffer to read data from
  48398. * @returns the DDS information
  48399. */
  48400. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48401. private static _FloatView;
  48402. private static _Int32View;
  48403. private static _ToHalfFloat;
  48404. private static _FromHalfFloat;
  48405. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48406. private static _GetHalfFloatRGBAArrayBuffer;
  48407. private static _GetFloatRGBAArrayBuffer;
  48408. private static _GetFloatAsUIntRGBAArrayBuffer;
  48409. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48410. private static _GetRGBAArrayBuffer;
  48411. private static _ExtractLongWordOrder;
  48412. private static _GetRGBArrayBuffer;
  48413. private static _GetLuminanceArrayBuffer;
  48414. /**
  48415. * Uploads DDS Levels to a Babylon Texture
  48416. * @hidden
  48417. */
  48418. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48419. }
  48420. module "babylonjs/Engines/engine" {
  48421. interface Engine {
  48422. /**
  48423. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48424. * @param rootUrl defines the url where the file to load is located
  48425. * @param scene defines the current scene
  48426. * @param lodScale defines scale to apply to the mip map selection
  48427. * @param lodOffset defines offset to apply to the mip map selection
  48428. * @param onLoad defines an optional callback raised when the texture is loaded
  48429. * @param onError defines an optional callback raised if there is an issue to load the texture
  48430. * @param format defines the format of the data
  48431. * @param forcedExtension defines the extension to use to pick the right loader
  48432. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48433. * @returns the cube texture as an InternalTexture
  48434. */
  48435. 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;
  48436. }
  48437. }
  48438. }
  48439. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48440. import { Nullable } from "babylonjs/types";
  48441. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48442. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48443. /**
  48444. * Implementation of the DDS Texture Loader.
  48445. * @hidden
  48446. */
  48447. export class _DDSTextureLoader implements IInternalTextureLoader {
  48448. /**
  48449. * Defines wether the loader supports cascade loading the different faces.
  48450. */
  48451. readonly supportCascades: boolean;
  48452. /**
  48453. * This returns if the loader support the current file information.
  48454. * @param extension defines the file extension of the file being loaded
  48455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48456. * @param fallback defines the fallback internal texture if any
  48457. * @param isBase64 defines whether the texture is encoded as a base64
  48458. * @param isBuffer defines whether the texture data are stored as a buffer
  48459. * @returns true if the loader can load the specified file
  48460. */
  48461. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48462. /**
  48463. * Transform the url before loading if required.
  48464. * @param rootUrl the url of the texture
  48465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48466. * @returns the transformed texture
  48467. */
  48468. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48469. /**
  48470. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48471. * @param rootUrl the url of the texture
  48472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48473. * @returns the fallback texture
  48474. */
  48475. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48476. /**
  48477. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48478. * @param data contains the texture data
  48479. * @param texture defines the BabylonJS internal texture
  48480. * @param createPolynomials will be true if polynomials have been requested
  48481. * @param onLoad defines the callback to trigger once the texture is ready
  48482. * @param onError defines the callback to trigger in case of error
  48483. */
  48484. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48485. /**
  48486. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48487. * @param data contains the texture data
  48488. * @param texture defines the BabylonJS internal texture
  48489. * @param callback defines the method to call once ready to upload
  48490. */
  48491. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48492. }
  48493. }
  48494. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48495. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48496. /** @hidden */
  48497. export var rgbdEncodePixelShader: {
  48498. name: string;
  48499. shader: string;
  48500. };
  48501. }
  48502. declare module "babylonjs/Misc/environmentTextureTools" {
  48503. import { Nullable } from "babylonjs/types";
  48504. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48505. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48506. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48507. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48508. import "babylonjs/Shaders/rgbdEncode.fragment";
  48509. import "babylonjs/Shaders/rgbdDecode.fragment";
  48510. /**
  48511. * Raw texture data and descriptor sufficient for WebGL texture upload
  48512. */
  48513. export interface EnvironmentTextureInfo {
  48514. /**
  48515. * Version of the environment map
  48516. */
  48517. version: number;
  48518. /**
  48519. * Width of image
  48520. */
  48521. width: number;
  48522. /**
  48523. * Irradiance information stored in the file.
  48524. */
  48525. irradiance: any;
  48526. /**
  48527. * Specular information stored in the file.
  48528. */
  48529. specular: any;
  48530. }
  48531. /**
  48532. * Sets of helpers addressing the serialization and deserialization of environment texture
  48533. * stored in a BabylonJS env file.
  48534. * Those files are usually stored as .env files.
  48535. */
  48536. export class EnvironmentTextureTools {
  48537. /**
  48538. * Magic number identifying the env file.
  48539. */
  48540. private static _MagicBytes;
  48541. /**
  48542. * Gets the environment info from an env file.
  48543. * @param data The array buffer containing the .env bytes.
  48544. * @returns the environment file info (the json header) if successfully parsed.
  48545. */
  48546. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48547. /**
  48548. * Creates an environment texture from a loaded cube texture.
  48549. * @param texture defines the cube texture to convert in env file
  48550. * @return a promise containing the environment data if succesfull.
  48551. */
  48552. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48553. /**
  48554. * Creates a JSON representation of the spherical data.
  48555. * @param texture defines the texture containing the polynomials
  48556. * @return the JSON representation of the spherical info
  48557. */
  48558. private static _CreateEnvTextureIrradiance;
  48559. /**
  48560. * Uploads the texture info contained in the env file to the GPU.
  48561. * @param texture defines the internal texture to upload to
  48562. * @param arrayBuffer defines the buffer cotaining the data to load
  48563. * @param info defines the texture info retrieved through the GetEnvInfo method
  48564. * @returns a promise
  48565. */
  48566. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48567. /**
  48568. * Uploads the levels of image data to the GPU.
  48569. * @param texture defines the internal texture to upload to
  48570. * @param imageData defines the array buffer views of image data [mipmap][face]
  48571. * @returns a promise
  48572. */
  48573. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48574. /**
  48575. * Uploads spherical polynomials information to the texture.
  48576. * @param texture defines the texture we are trying to upload the information to
  48577. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48578. */
  48579. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48580. /** @hidden */
  48581. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48582. }
  48583. }
  48584. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48585. import { Nullable } from "babylonjs/types";
  48586. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48587. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48588. /**
  48589. * Implementation of the ENV Texture Loader.
  48590. * @hidden
  48591. */
  48592. export class _ENVTextureLoader implements IInternalTextureLoader {
  48593. /**
  48594. * Defines wether the loader supports cascade loading the different faces.
  48595. */
  48596. readonly supportCascades: boolean;
  48597. /**
  48598. * This returns if the loader support the current file information.
  48599. * @param extension defines the file extension of the file being loaded
  48600. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48601. * @param fallback defines the fallback internal texture if any
  48602. * @param isBase64 defines whether the texture is encoded as a base64
  48603. * @param isBuffer defines whether the texture data are stored as a buffer
  48604. * @returns true if the loader can load the specified file
  48605. */
  48606. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48607. /**
  48608. * Transform the url before loading if required.
  48609. * @param rootUrl the url of the texture
  48610. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48611. * @returns the transformed texture
  48612. */
  48613. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48614. /**
  48615. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48616. * @param rootUrl the url of the texture
  48617. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48618. * @returns the fallback texture
  48619. */
  48620. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48621. /**
  48622. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48623. * @param data contains the texture data
  48624. * @param texture defines the BabylonJS internal texture
  48625. * @param createPolynomials will be true if polynomials have been requested
  48626. * @param onLoad defines the callback to trigger once the texture is ready
  48627. * @param onError defines the callback to trigger in case of error
  48628. */
  48629. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48630. /**
  48631. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48632. * @param data contains the texture data
  48633. * @param texture defines the BabylonJS internal texture
  48634. * @param callback defines the method to call once ready to upload
  48635. */
  48636. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48637. }
  48638. }
  48639. declare module "babylonjs/Misc/khronosTextureContainer" {
  48640. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48641. /**
  48642. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48643. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48644. */
  48645. export class KhronosTextureContainer {
  48646. /** contents of the KTX container file */
  48647. arrayBuffer: any;
  48648. private static HEADER_LEN;
  48649. private static COMPRESSED_2D;
  48650. private static COMPRESSED_3D;
  48651. private static TEX_2D;
  48652. private static TEX_3D;
  48653. /**
  48654. * Gets the openGL type
  48655. */
  48656. glType: number;
  48657. /**
  48658. * Gets the openGL type size
  48659. */
  48660. glTypeSize: number;
  48661. /**
  48662. * Gets the openGL format
  48663. */
  48664. glFormat: number;
  48665. /**
  48666. * Gets the openGL internal format
  48667. */
  48668. glInternalFormat: number;
  48669. /**
  48670. * Gets the base internal format
  48671. */
  48672. glBaseInternalFormat: number;
  48673. /**
  48674. * Gets image width in pixel
  48675. */
  48676. pixelWidth: number;
  48677. /**
  48678. * Gets image height in pixel
  48679. */
  48680. pixelHeight: number;
  48681. /**
  48682. * Gets image depth in pixels
  48683. */
  48684. pixelDepth: number;
  48685. /**
  48686. * Gets the number of array elements
  48687. */
  48688. numberOfArrayElements: number;
  48689. /**
  48690. * Gets the number of faces
  48691. */
  48692. numberOfFaces: number;
  48693. /**
  48694. * Gets the number of mipmap levels
  48695. */
  48696. numberOfMipmapLevels: number;
  48697. /**
  48698. * Gets the bytes of key value data
  48699. */
  48700. bytesOfKeyValueData: number;
  48701. /**
  48702. * Gets the load type
  48703. */
  48704. loadType: number;
  48705. /**
  48706. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48707. */
  48708. isInvalid: boolean;
  48709. /**
  48710. * Creates a new KhronosTextureContainer
  48711. * @param arrayBuffer contents of the KTX container file
  48712. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48713. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48714. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48715. */
  48716. constructor(
  48717. /** contents of the KTX container file */
  48718. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48719. /**
  48720. * Uploads KTX content to a Babylon Texture.
  48721. * It is assumed that the texture has already been created & is currently bound
  48722. * @hidden
  48723. */
  48724. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48725. private _upload2DCompressedLevels;
  48726. }
  48727. }
  48728. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48729. import { Nullable } from "babylonjs/types";
  48730. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48731. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48732. /**
  48733. * Implementation of the KTX Texture Loader.
  48734. * @hidden
  48735. */
  48736. export class _KTXTextureLoader implements IInternalTextureLoader {
  48737. /**
  48738. * Defines wether the loader supports cascade loading the different faces.
  48739. */
  48740. readonly supportCascades: boolean;
  48741. /**
  48742. * This returns if the loader support the current file information.
  48743. * @param extension defines the file extension of the file being loaded
  48744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48745. * @param fallback defines the fallback internal texture if any
  48746. * @param isBase64 defines whether the texture is encoded as a base64
  48747. * @param isBuffer defines whether the texture data are stored as a buffer
  48748. * @returns true if the loader can load the specified file
  48749. */
  48750. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48751. /**
  48752. * Transform the url before loading if required.
  48753. * @param rootUrl the url of the texture
  48754. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48755. * @returns the transformed texture
  48756. */
  48757. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48758. /**
  48759. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48760. * @param rootUrl the url of the texture
  48761. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48762. * @returns the fallback texture
  48763. */
  48764. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48765. /**
  48766. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48767. * @param data contains the texture data
  48768. * @param texture defines the BabylonJS internal texture
  48769. * @param createPolynomials will be true if polynomials have been requested
  48770. * @param onLoad defines the callback to trigger once the texture is ready
  48771. * @param onError defines the callback to trigger in case of error
  48772. */
  48773. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48774. /**
  48775. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48776. * @param data contains the texture data
  48777. * @param texture defines the BabylonJS internal texture
  48778. * @param callback defines the method to call once ready to upload
  48779. */
  48780. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48781. }
  48782. }
  48783. declare module "babylonjs/Helpers/sceneHelpers" {
  48784. import { Nullable } from "babylonjs/types";
  48785. import { Mesh } from "babylonjs/Meshes/mesh";
  48786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48787. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48788. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48789. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48790. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48791. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48792. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48793. import "babylonjs/Meshes/Builders/boxBuilder";
  48794. /** @hidden */
  48795. export var _forceSceneHelpersToBundle: boolean;
  48796. module "babylonjs/scene" {
  48797. interface Scene {
  48798. /**
  48799. * Creates a default light for the scene.
  48800. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48801. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48802. */
  48803. createDefaultLight(replace?: boolean): void;
  48804. /**
  48805. * Creates a default camera for the scene.
  48806. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48807. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48808. * @param replace has default false, when true replaces the active camera in the scene
  48809. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48810. */
  48811. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48812. /**
  48813. * Creates a default camera and a default light.
  48814. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48815. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48816. * @param replace has the default false, when true replaces the active camera/light in the scene
  48817. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48818. */
  48819. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48820. /**
  48821. * Creates a new sky box
  48822. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48823. * @param environmentTexture defines the texture to use as environment texture
  48824. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48825. * @param scale defines the overall scale of the skybox
  48826. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48827. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48828. * @returns a new mesh holding the sky box
  48829. */
  48830. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48831. /**
  48832. * Creates a new environment
  48833. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48834. * @param options defines the options you can use to configure the environment
  48835. * @returns the new EnvironmentHelper
  48836. */
  48837. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48838. /**
  48839. * Creates a new VREXperienceHelper
  48840. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48841. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48842. * @returns a new VREXperienceHelper
  48843. */
  48844. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48845. /**
  48846. * Creates a new XREXperienceHelper
  48847. * @see http://doc.babylonjs.com/how_to/webxr
  48848. * @returns a promise for a new XREXperienceHelper
  48849. */
  48850. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48851. }
  48852. }
  48853. }
  48854. declare module "babylonjs/Helpers/videoDome" {
  48855. import { Scene } from "babylonjs/scene";
  48856. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48857. import { Mesh } from "babylonjs/Meshes/mesh";
  48858. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48859. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48860. import "babylonjs/Meshes/Builders/sphereBuilder";
  48861. /**
  48862. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48863. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48864. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48865. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48866. */
  48867. export class VideoDome extends TransformNode {
  48868. /**
  48869. * Define the video source as a Monoscopic panoramic 360 video.
  48870. */
  48871. static readonly MODE_MONOSCOPIC: number;
  48872. /**
  48873. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48874. */
  48875. static readonly MODE_TOPBOTTOM: number;
  48876. /**
  48877. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48878. */
  48879. static readonly MODE_SIDEBYSIDE: number;
  48880. private _useDirectMapping;
  48881. /**
  48882. * The video texture being displayed on the sphere
  48883. */
  48884. protected _videoTexture: VideoTexture;
  48885. /**
  48886. * Gets the video texture being displayed on the sphere
  48887. */
  48888. readonly videoTexture: VideoTexture;
  48889. /**
  48890. * The skybox material
  48891. */
  48892. protected _material: BackgroundMaterial;
  48893. /**
  48894. * The surface used for the skybox
  48895. */
  48896. protected _mesh: Mesh;
  48897. /**
  48898. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48899. * Also see the options.resolution property.
  48900. */
  48901. fovMultiplier: number;
  48902. private _videoMode;
  48903. /**
  48904. * Gets or set the current video mode for the video. It can be:
  48905. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48906. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48907. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48908. */
  48909. videoMode: number;
  48910. /**
  48911. * Oberserver used in Stereoscopic VR Mode.
  48912. */
  48913. private _onBeforeCameraRenderObserver;
  48914. /**
  48915. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48916. * @param name Element's name, child elements will append suffixes for their own names.
  48917. * @param urlsOrVideo defines the url(s) or the video element to use
  48918. * @param options An object containing optional or exposed sub element properties
  48919. */
  48920. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48921. resolution?: number;
  48922. clickToPlay?: boolean;
  48923. autoPlay?: boolean;
  48924. loop?: boolean;
  48925. size?: number;
  48926. poster?: string;
  48927. faceForward?: boolean;
  48928. useDirectMapping?: boolean;
  48929. }, scene: Scene);
  48930. private _changeVideoMode;
  48931. /**
  48932. * Releases resources associated with this node.
  48933. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48934. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48935. */
  48936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48937. }
  48938. }
  48939. declare module "babylonjs/Helpers/index" {
  48940. export * from "babylonjs/Helpers/environmentHelper";
  48941. export * from "babylonjs/Helpers/photoDome";
  48942. export * from "babylonjs/Helpers/sceneHelpers";
  48943. export * from "babylonjs/Helpers/videoDome";
  48944. }
  48945. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48946. import { PerfCounter } from "babylonjs/Misc/tools";
  48947. import { IDisposable } from "babylonjs/scene";
  48948. import { Engine } from "babylonjs/Engines/engine";
  48949. /**
  48950. * This class can be used to get instrumentation data from a Babylon engine
  48951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48952. */
  48953. export class EngineInstrumentation implements IDisposable {
  48954. /**
  48955. * Define the instrumented engine.
  48956. */
  48957. engine: Engine;
  48958. private _captureGPUFrameTime;
  48959. private _gpuFrameTimeToken;
  48960. private _gpuFrameTime;
  48961. private _captureShaderCompilationTime;
  48962. private _shaderCompilationTime;
  48963. private _onBeginFrameObserver;
  48964. private _onEndFrameObserver;
  48965. private _onBeforeShaderCompilationObserver;
  48966. private _onAfterShaderCompilationObserver;
  48967. /**
  48968. * Gets the perf counter used for GPU frame time
  48969. */
  48970. readonly gpuFrameTimeCounter: PerfCounter;
  48971. /**
  48972. * Gets the GPU frame time capture status
  48973. */
  48974. /**
  48975. * Enable or disable the GPU frame time capture
  48976. */
  48977. captureGPUFrameTime: boolean;
  48978. /**
  48979. * Gets the perf counter used for shader compilation time
  48980. */
  48981. readonly shaderCompilationTimeCounter: PerfCounter;
  48982. /**
  48983. * Gets the shader compilation time capture status
  48984. */
  48985. /**
  48986. * Enable or disable the shader compilation time capture
  48987. */
  48988. captureShaderCompilationTime: boolean;
  48989. /**
  48990. * Instantiates a new engine instrumentation.
  48991. * This class can be used to get instrumentation data from a Babylon engine
  48992. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48993. * @param engine Defines the engine to instrument
  48994. */
  48995. constructor(
  48996. /**
  48997. * Define the instrumented engine.
  48998. */
  48999. engine: Engine);
  49000. /**
  49001. * Dispose and release associated resources.
  49002. */
  49003. dispose(): void;
  49004. }
  49005. }
  49006. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49007. import { PerfCounter } from "babylonjs/Misc/tools";
  49008. import { Scene, IDisposable } from "babylonjs/scene";
  49009. /**
  49010. * This class can be used to get instrumentation data from a Babylon engine
  49011. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49012. */
  49013. export class SceneInstrumentation implements IDisposable {
  49014. /**
  49015. * Defines the scene to instrument
  49016. */
  49017. scene: Scene;
  49018. private _captureActiveMeshesEvaluationTime;
  49019. private _activeMeshesEvaluationTime;
  49020. private _captureRenderTargetsRenderTime;
  49021. private _renderTargetsRenderTime;
  49022. private _captureFrameTime;
  49023. private _frameTime;
  49024. private _captureRenderTime;
  49025. private _renderTime;
  49026. private _captureInterFrameTime;
  49027. private _interFrameTime;
  49028. private _captureParticlesRenderTime;
  49029. private _particlesRenderTime;
  49030. private _captureSpritesRenderTime;
  49031. private _spritesRenderTime;
  49032. private _capturePhysicsTime;
  49033. private _physicsTime;
  49034. private _captureAnimationsTime;
  49035. private _animationsTime;
  49036. private _captureCameraRenderTime;
  49037. private _cameraRenderTime;
  49038. private _onBeforeActiveMeshesEvaluationObserver;
  49039. private _onAfterActiveMeshesEvaluationObserver;
  49040. private _onBeforeRenderTargetsRenderObserver;
  49041. private _onAfterRenderTargetsRenderObserver;
  49042. private _onAfterRenderObserver;
  49043. private _onBeforeDrawPhaseObserver;
  49044. private _onAfterDrawPhaseObserver;
  49045. private _onBeforeAnimationsObserver;
  49046. private _onBeforeParticlesRenderingObserver;
  49047. private _onAfterParticlesRenderingObserver;
  49048. private _onBeforeSpritesRenderingObserver;
  49049. private _onAfterSpritesRenderingObserver;
  49050. private _onBeforePhysicsObserver;
  49051. private _onAfterPhysicsObserver;
  49052. private _onAfterAnimationsObserver;
  49053. private _onBeforeCameraRenderObserver;
  49054. private _onAfterCameraRenderObserver;
  49055. /**
  49056. * Gets the perf counter used for active meshes evaluation time
  49057. */
  49058. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49059. /**
  49060. * Gets the active meshes evaluation time capture status
  49061. */
  49062. /**
  49063. * Enable or disable the active meshes evaluation time capture
  49064. */
  49065. captureActiveMeshesEvaluationTime: boolean;
  49066. /**
  49067. * Gets the perf counter used for render targets render time
  49068. */
  49069. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49070. /**
  49071. * Gets the render targets render time capture status
  49072. */
  49073. /**
  49074. * Enable or disable the render targets render time capture
  49075. */
  49076. captureRenderTargetsRenderTime: boolean;
  49077. /**
  49078. * Gets the perf counter used for particles render time
  49079. */
  49080. readonly particlesRenderTimeCounter: PerfCounter;
  49081. /**
  49082. * Gets the particles render time capture status
  49083. */
  49084. /**
  49085. * Enable or disable the particles render time capture
  49086. */
  49087. captureParticlesRenderTime: boolean;
  49088. /**
  49089. * Gets the perf counter used for sprites render time
  49090. */
  49091. readonly spritesRenderTimeCounter: PerfCounter;
  49092. /**
  49093. * Gets the sprites render time capture status
  49094. */
  49095. /**
  49096. * Enable or disable the sprites render time capture
  49097. */
  49098. captureSpritesRenderTime: boolean;
  49099. /**
  49100. * Gets the perf counter used for physics time
  49101. */
  49102. readonly physicsTimeCounter: PerfCounter;
  49103. /**
  49104. * Gets the physics time capture status
  49105. */
  49106. /**
  49107. * Enable or disable the physics time capture
  49108. */
  49109. capturePhysicsTime: boolean;
  49110. /**
  49111. * Gets the perf counter used for animations time
  49112. */
  49113. readonly animationsTimeCounter: PerfCounter;
  49114. /**
  49115. * Gets the animations time capture status
  49116. */
  49117. /**
  49118. * Enable or disable the animations time capture
  49119. */
  49120. captureAnimationsTime: boolean;
  49121. /**
  49122. * Gets the perf counter used for frame time capture
  49123. */
  49124. readonly frameTimeCounter: PerfCounter;
  49125. /**
  49126. * Gets the frame time capture status
  49127. */
  49128. /**
  49129. * Enable or disable the frame time capture
  49130. */
  49131. captureFrameTime: boolean;
  49132. /**
  49133. * Gets the perf counter used for inter-frames time capture
  49134. */
  49135. readonly interFrameTimeCounter: PerfCounter;
  49136. /**
  49137. * Gets the inter-frames time capture status
  49138. */
  49139. /**
  49140. * Enable or disable the inter-frames time capture
  49141. */
  49142. captureInterFrameTime: boolean;
  49143. /**
  49144. * Gets the perf counter used for render time capture
  49145. */
  49146. readonly renderTimeCounter: PerfCounter;
  49147. /**
  49148. * Gets the render time capture status
  49149. */
  49150. /**
  49151. * Enable or disable the render time capture
  49152. */
  49153. captureRenderTime: boolean;
  49154. /**
  49155. * Gets the perf counter used for camera render time capture
  49156. */
  49157. readonly cameraRenderTimeCounter: PerfCounter;
  49158. /**
  49159. * Gets the camera render time capture status
  49160. */
  49161. /**
  49162. * Enable or disable the camera render time capture
  49163. */
  49164. captureCameraRenderTime: boolean;
  49165. /**
  49166. * Gets the perf counter used for draw calls
  49167. */
  49168. readonly drawCallsCounter: PerfCounter;
  49169. /**
  49170. * Instantiates a new scene instrumentation.
  49171. * This class can be used to get instrumentation data from a Babylon engine
  49172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49173. * @param scene Defines the scene to instrument
  49174. */
  49175. constructor(
  49176. /**
  49177. * Defines the scene to instrument
  49178. */
  49179. scene: Scene);
  49180. /**
  49181. * Dispose and release associated resources.
  49182. */
  49183. dispose(): void;
  49184. }
  49185. }
  49186. declare module "babylonjs/Instrumentation/index" {
  49187. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49188. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49189. export * from "babylonjs/Instrumentation/timeToken";
  49190. }
  49191. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49192. /** @hidden */
  49193. export var glowMapGenerationPixelShader: {
  49194. name: string;
  49195. shader: string;
  49196. };
  49197. }
  49198. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49199. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49200. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49202. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49203. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49204. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49205. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49206. /** @hidden */
  49207. export var glowMapGenerationVertexShader: {
  49208. name: string;
  49209. shader: string;
  49210. };
  49211. }
  49212. declare module "babylonjs/Layers/effectLayer" {
  49213. import { Observable } from "babylonjs/Misc/observable";
  49214. import { Nullable } from "babylonjs/types";
  49215. import { Camera } from "babylonjs/Cameras/camera";
  49216. import { Scene } from "babylonjs/scene";
  49217. import { Color4, ISize } from "babylonjs/Maths/math";
  49218. import { Engine } from "babylonjs/Engines/engine";
  49219. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49221. import { Mesh } from "babylonjs/Meshes/mesh";
  49222. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49224. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49225. import { Effect } from "babylonjs/Materials/effect";
  49226. import { Material } from "babylonjs/Materials/material";
  49227. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49228. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49229. /**
  49230. * Effect layer options. This helps customizing the behaviour
  49231. * of the effect layer.
  49232. */
  49233. export interface IEffectLayerOptions {
  49234. /**
  49235. * Multiplication factor apply to the canvas size to compute the render target size
  49236. * used to generated the objects (the smaller the faster).
  49237. */
  49238. mainTextureRatio: number;
  49239. /**
  49240. * Enforces a fixed size texture to ensure effect stability across devices.
  49241. */
  49242. mainTextureFixedSize?: number;
  49243. /**
  49244. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49245. */
  49246. alphaBlendingMode: number;
  49247. /**
  49248. * The camera attached to the layer.
  49249. */
  49250. camera: Nullable<Camera>;
  49251. /**
  49252. * The rendering group to draw the layer in.
  49253. */
  49254. renderingGroupId: number;
  49255. }
  49256. /**
  49257. * The effect layer Helps adding post process effect blended with the main pass.
  49258. *
  49259. * This can be for instance use to generate glow or higlight effects on the scene.
  49260. *
  49261. * The effect layer class can not be used directly and is intented to inherited from to be
  49262. * customized per effects.
  49263. */
  49264. export abstract class EffectLayer {
  49265. private _vertexBuffers;
  49266. private _indexBuffer;
  49267. private _cachedDefines;
  49268. private _effectLayerMapGenerationEffect;
  49269. private _effectLayerOptions;
  49270. private _mergeEffect;
  49271. protected _scene: Scene;
  49272. protected _engine: Engine;
  49273. protected _maxSize: number;
  49274. protected _mainTextureDesiredSize: ISize;
  49275. protected _mainTexture: RenderTargetTexture;
  49276. protected _shouldRender: boolean;
  49277. protected _postProcesses: PostProcess[];
  49278. protected _textures: BaseTexture[];
  49279. protected _emissiveTextureAndColor: {
  49280. texture: Nullable<BaseTexture>;
  49281. color: Color4;
  49282. };
  49283. /**
  49284. * The name of the layer
  49285. */
  49286. name: string;
  49287. /**
  49288. * The clear color of the texture used to generate the glow map.
  49289. */
  49290. neutralColor: Color4;
  49291. /**
  49292. * Specifies wether the highlight layer is enabled or not.
  49293. */
  49294. isEnabled: boolean;
  49295. /**
  49296. * Gets the camera attached to the layer.
  49297. */
  49298. readonly camera: Nullable<Camera>;
  49299. /**
  49300. * Gets the rendering group id the layer should render in.
  49301. */
  49302. readonly renderingGroupId: number;
  49303. /**
  49304. * An event triggered when the effect layer has been disposed.
  49305. */
  49306. onDisposeObservable: Observable<EffectLayer>;
  49307. /**
  49308. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49309. */
  49310. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49311. /**
  49312. * An event triggered when the generated texture is being merged in the scene.
  49313. */
  49314. onBeforeComposeObservable: Observable<EffectLayer>;
  49315. /**
  49316. * An event triggered when the generated texture has been merged in the scene.
  49317. */
  49318. onAfterComposeObservable: Observable<EffectLayer>;
  49319. /**
  49320. * An event triggered when the efffect layer changes its size.
  49321. */
  49322. onSizeChangedObservable: Observable<EffectLayer>;
  49323. /** @hidden */
  49324. static _SceneComponentInitialization: (scene: Scene) => void;
  49325. /**
  49326. * Instantiates a new effect Layer and references it in the scene.
  49327. * @param name The name of the layer
  49328. * @param scene The scene to use the layer in
  49329. */
  49330. constructor(
  49331. /** The Friendly of the effect in the scene */
  49332. name: string, scene: Scene);
  49333. /**
  49334. * Get the effect name of the layer.
  49335. * @return The effect name
  49336. */
  49337. abstract getEffectName(): string;
  49338. /**
  49339. * Checks for the readiness of the element composing the layer.
  49340. * @param subMesh the mesh to check for
  49341. * @param useInstances specify wether or not to use instances to render the mesh
  49342. * @return true if ready otherwise, false
  49343. */
  49344. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49345. /**
  49346. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49347. * @returns true if the effect requires stencil during the main canvas render pass.
  49348. */
  49349. abstract needStencil(): boolean;
  49350. /**
  49351. * Create the merge effect. This is the shader use to blit the information back
  49352. * to the main canvas at the end of the scene rendering.
  49353. * @returns The effect containing the shader used to merge the effect on the main canvas
  49354. */
  49355. protected abstract _createMergeEffect(): Effect;
  49356. /**
  49357. * Creates the render target textures and post processes used in the effect layer.
  49358. */
  49359. protected abstract _createTextureAndPostProcesses(): void;
  49360. /**
  49361. * Implementation specific of rendering the generating effect on the main canvas.
  49362. * @param effect The effect used to render through
  49363. */
  49364. protected abstract _internalRender(effect: Effect): void;
  49365. /**
  49366. * Sets the required values for both the emissive texture and and the main color.
  49367. */
  49368. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49369. /**
  49370. * Free any resources and references associated to a mesh.
  49371. * Internal use
  49372. * @param mesh The mesh to free.
  49373. */
  49374. abstract _disposeMesh(mesh: Mesh): void;
  49375. /**
  49376. * Serializes this layer (Glow or Highlight for example)
  49377. * @returns a serialized layer object
  49378. */
  49379. abstract serialize?(): any;
  49380. /**
  49381. * Initializes the effect layer with the required options.
  49382. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49383. */
  49384. protected _init(options: Partial<IEffectLayerOptions>): void;
  49385. /**
  49386. * Generates the index buffer of the full screen quad blending to the main canvas.
  49387. */
  49388. private _generateIndexBuffer;
  49389. /**
  49390. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49391. */
  49392. private _generateVertexBuffer;
  49393. /**
  49394. * Sets the main texture desired size which is the closest power of two
  49395. * of the engine canvas size.
  49396. */
  49397. private _setMainTextureSize;
  49398. /**
  49399. * Creates the main texture for the effect layer.
  49400. */
  49401. protected _createMainTexture(): void;
  49402. /**
  49403. * Adds specific effects defines.
  49404. * @param defines The defines to add specifics to.
  49405. */
  49406. protected _addCustomEffectDefines(defines: string[]): void;
  49407. /**
  49408. * Checks for the readiness of the element composing the layer.
  49409. * @param subMesh the mesh to check for
  49410. * @param useInstances specify wether or not to use instances to render the mesh
  49411. * @param emissiveTexture the associated emissive texture used to generate the glow
  49412. * @return true if ready otherwise, false
  49413. */
  49414. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49415. /**
  49416. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49417. */
  49418. render(): void;
  49419. /**
  49420. * Determine if a given mesh will be used in the current effect.
  49421. * @param mesh mesh to test
  49422. * @returns true if the mesh will be used
  49423. */
  49424. hasMesh(mesh: AbstractMesh): boolean;
  49425. /**
  49426. * Returns true if the layer contains information to display, otherwise false.
  49427. * @returns true if the glow layer should be rendered
  49428. */
  49429. shouldRender(): boolean;
  49430. /**
  49431. * Returns true if the mesh should render, otherwise false.
  49432. * @param mesh The mesh to render
  49433. * @returns true if it should render otherwise false
  49434. */
  49435. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49436. /**
  49437. * Returns true if the mesh can be rendered, otherwise false.
  49438. * @param mesh The mesh to render
  49439. * @param material The material used on the mesh
  49440. * @returns true if it can be rendered otherwise false
  49441. */
  49442. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49443. /**
  49444. * Returns true if the mesh should render, otherwise false.
  49445. * @param mesh The mesh to render
  49446. * @returns true if it should render otherwise false
  49447. */
  49448. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49449. /**
  49450. * Renders the submesh passed in parameter to the generation map.
  49451. */
  49452. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49453. /**
  49454. * Rebuild the required buffers.
  49455. * @hidden Internal use only.
  49456. */
  49457. _rebuild(): void;
  49458. /**
  49459. * Dispose only the render target textures and post process.
  49460. */
  49461. private _disposeTextureAndPostProcesses;
  49462. /**
  49463. * Dispose the highlight layer and free resources.
  49464. */
  49465. dispose(): void;
  49466. /**
  49467. * Gets the class name of the effect layer
  49468. * @returns the string with the class name of the effect layer
  49469. */
  49470. getClassName(): string;
  49471. /**
  49472. * Creates an effect layer from parsed effect layer data
  49473. * @param parsedEffectLayer defines effect layer data
  49474. * @param scene defines the current scene
  49475. * @param rootUrl defines the root URL containing the effect layer information
  49476. * @returns a parsed effect Layer
  49477. */
  49478. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49479. }
  49480. }
  49481. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49482. import { Scene } from "babylonjs/scene";
  49483. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49484. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49485. import { AbstractScene } from "babylonjs/abstractScene";
  49486. module "babylonjs/abstractScene" {
  49487. interface AbstractScene {
  49488. /**
  49489. * The list of effect layers (highlights/glow) added to the scene
  49490. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49491. * @see http://doc.babylonjs.com/how_to/glow_layer
  49492. */
  49493. effectLayers: Array<EffectLayer>;
  49494. /**
  49495. * Removes the given effect layer from this scene.
  49496. * @param toRemove defines the effect layer to remove
  49497. * @returns the index of the removed effect layer
  49498. */
  49499. removeEffectLayer(toRemove: EffectLayer): number;
  49500. /**
  49501. * Adds the given effect layer to this scene
  49502. * @param newEffectLayer defines the effect layer to add
  49503. */
  49504. addEffectLayer(newEffectLayer: EffectLayer): void;
  49505. }
  49506. }
  49507. /**
  49508. * Defines the layer scene component responsible to manage any effect layers
  49509. * in a given scene.
  49510. */
  49511. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49512. /**
  49513. * The component name helpfull to identify the component in the list of scene components.
  49514. */
  49515. readonly name: string;
  49516. /**
  49517. * The scene the component belongs to.
  49518. */
  49519. scene: Scene;
  49520. private _engine;
  49521. private _renderEffects;
  49522. private _needStencil;
  49523. private _previousStencilState;
  49524. /**
  49525. * Creates a new instance of the component for the given scene
  49526. * @param scene Defines the scene to register the component in
  49527. */
  49528. constructor(scene: Scene);
  49529. /**
  49530. * Registers the component in a given scene
  49531. */
  49532. register(): void;
  49533. /**
  49534. * Rebuilds the elements related to this component in case of
  49535. * context lost for instance.
  49536. */
  49537. rebuild(): void;
  49538. /**
  49539. * Serializes the component data to the specified json object
  49540. * @param serializationObject The object to serialize to
  49541. */
  49542. serialize(serializationObject: any): void;
  49543. /**
  49544. * Adds all the elements from the container to the scene
  49545. * @param container the container holding the elements
  49546. */
  49547. addFromContainer(container: AbstractScene): void;
  49548. /**
  49549. * Removes all the elements in the container from the scene
  49550. * @param container contains the elements to remove
  49551. * @param dispose if the removed element should be disposed (default: false)
  49552. */
  49553. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49554. /**
  49555. * Disposes the component and the associated ressources.
  49556. */
  49557. dispose(): void;
  49558. private _isReadyForMesh;
  49559. private _renderMainTexture;
  49560. private _setStencil;
  49561. private _setStencilBack;
  49562. private _draw;
  49563. private _drawCamera;
  49564. private _drawRenderingGroup;
  49565. }
  49566. }
  49567. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49568. /** @hidden */
  49569. export var glowMapMergePixelShader: {
  49570. name: string;
  49571. shader: string;
  49572. };
  49573. }
  49574. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49575. /** @hidden */
  49576. export var glowMapMergeVertexShader: {
  49577. name: string;
  49578. shader: string;
  49579. };
  49580. }
  49581. declare module "babylonjs/Layers/glowLayer" {
  49582. import { Nullable } from "babylonjs/types";
  49583. import { Camera } from "babylonjs/Cameras/camera";
  49584. import { Scene } from "babylonjs/scene";
  49585. import { Color4 } from "babylonjs/Maths/math";
  49586. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49588. import { Mesh } from "babylonjs/Meshes/mesh";
  49589. import { Texture } from "babylonjs/Materials/Textures/texture";
  49590. import { Effect } from "babylonjs/Materials/effect";
  49591. import { Material } from "babylonjs/Materials/material";
  49592. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49593. import "babylonjs/Shaders/glowMapMerge.fragment";
  49594. import "babylonjs/Shaders/glowMapMerge.vertex";
  49595. import "babylonjs/Layers/effectLayerSceneComponent";
  49596. module "babylonjs/abstractScene" {
  49597. interface AbstractScene {
  49598. /**
  49599. * Return a the first highlight layer of the scene with a given name.
  49600. * @param name The name of the highlight layer to look for.
  49601. * @return The highlight layer if found otherwise null.
  49602. */
  49603. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49604. }
  49605. }
  49606. /**
  49607. * Glow layer options. This helps customizing the behaviour
  49608. * of the glow layer.
  49609. */
  49610. export interface IGlowLayerOptions {
  49611. /**
  49612. * Multiplication factor apply to the canvas size to compute the render target size
  49613. * used to generated the glowing objects (the smaller the faster).
  49614. */
  49615. mainTextureRatio: number;
  49616. /**
  49617. * Enforces a fixed size texture to ensure resize independant blur.
  49618. */
  49619. mainTextureFixedSize?: number;
  49620. /**
  49621. * How big is the kernel of the blur texture.
  49622. */
  49623. blurKernelSize: number;
  49624. /**
  49625. * The camera attached to the layer.
  49626. */
  49627. camera: Nullable<Camera>;
  49628. /**
  49629. * Enable MSAA by chosing the number of samples.
  49630. */
  49631. mainTextureSamples?: number;
  49632. /**
  49633. * The rendering group to draw the layer in.
  49634. */
  49635. renderingGroupId: number;
  49636. }
  49637. /**
  49638. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49639. *
  49640. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49641. * glowy meshes to your scene.
  49642. *
  49643. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49644. */
  49645. export class GlowLayer extends EffectLayer {
  49646. /**
  49647. * Effect Name of the layer.
  49648. */
  49649. static readonly EffectName: string;
  49650. /**
  49651. * The default blur kernel size used for the glow.
  49652. */
  49653. static DefaultBlurKernelSize: number;
  49654. /**
  49655. * The default texture size ratio used for the glow.
  49656. */
  49657. static DefaultTextureRatio: number;
  49658. /**
  49659. * Sets the kernel size of the blur.
  49660. */
  49661. /**
  49662. * Gets the kernel size of the blur.
  49663. */
  49664. blurKernelSize: number;
  49665. /**
  49666. * Sets the glow intensity.
  49667. */
  49668. /**
  49669. * Gets the glow intensity.
  49670. */
  49671. intensity: number;
  49672. private _options;
  49673. private _intensity;
  49674. private _horizontalBlurPostprocess1;
  49675. private _verticalBlurPostprocess1;
  49676. private _horizontalBlurPostprocess2;
  49677. private _verticalBlurPostprocess2;
  49678. private _blurTexture1;
  49679. private _blurTexture2;
  49680. private _postProcesses1;
  49681. private _postProcesses2;
  49682. private _includedOnlyMeshes;
  49683. private _excludedMeshes;
  49684. /**
  49685. * Callback used to let the user override the color selection on a per mesh basis
  49686. */
  49687. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49688. /**
  49689. * Callback used to let the user override the texture selection on a per mesh basis
  49690. */
  49691. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49692. /**
  49693. * Instantiates a new glow Layer and references it to the scene.
  49694. * @param name The name of the layer
  49695. * @param scene The scene to use the layer in
  49696. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49697. */
  49698. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49699. /**
  49700. * Get the effect name of the layer.
  49701. * @return The effect name
  49702. */
  49703. getEffectName(): string;
  49704. /**
  49705. * Create the merge effect. This is the shader use to blit the information back
  49706. * to the main canvas at the end of the scene rendering.
  49707. */
  49708. protected _createMergeEffect(): Effect;
  49709. /**
  49710. * Creates the render target textures and post processes used in the glow layer.
  49711. */
  49712. protected _createTextureAndPostProcesses(): void;
  49713. /**
  49714. * Checks for the readiness of the element composing the layer.
  49715. * @param subMesh the mesh to check for
  49716. * @param useInstances specify wether or not to use instances to render the mesh
  49717. * @param emissiveTexture the associated emissive texture used to generate the glow
  49718. * @return true if ready otherwise, false
  49719. */
  49720. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49721. /**
  49722. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49723. */
  49724. needStencil(): boolean;
  49725. /**
  49726. * Returns true if the mesh can be rendered, otherwise false.
  49727. * @param mesh The mesh to render
  49728. * @param material The material used on the mesh
  49729. * @returns true if it can be rendered otherwise false
  49730. */
  49731. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49732. /**
  49733. * Implementation specific of rendering the generating effect on the main canvas.
  49734. * @param effect The effect used to render through
  49735. */
  49736. protected _internalRender(effect: Effect): void;
  49737. /**
  49738. * Sets the required values for both the emissive texture and and the main color.
  49739. */
  49740. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49741. /**
  49742. * Returns true if the mesh should render, otherwise false.
  49743. * @param mesh The mesh to render
  49744. * @returns true if it should render otherwise false
  49745. */
  49746. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49747. /**
  49748. * Adds specific effects defines.
  49749. * @param defines The defines to add specifics to.
  49750. */
  49751. protected _addCustomEffectDefines(defines: string[]): void;
  49752. /**
  49753. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49754. * @param mesh The mesh to exclude from the glow layer
  49755. */
  49756. addExcludedMesh(mesh: Mesh): void;
  49757. /**
  49758. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49759. * @param mesh The mesh to remove
  49760. */
  49761. removeExcludedMesh(mesh: Mesh): void;
  49762. /**
  49763. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49764. * @param mesh The mesh to include in the glow layer
  49765. */
  49766. addIncludedOnlyMesh(mesh: Mesh): void;
  49767. /**
  49768. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49769. * @param mesh The mesh to remove
  49770. */
  49771. removeIncludedOnlyMesh(mesh: Mesh): void;
  49772. /**
  49773. * Determine if a given mesh will be used in the glow layer
  49774. * @param mesh The mesh to test
  49775. * @returns true if the mesh will be highlighted by the current glow layer
  49776. */
  49777. hasMesh(mesh: AbstractMesh): boolean;
  49778. /**
  49779. * Free any resources and references associated to a mesh.
  49780. * Internal use
  49781. * @param mesh The mesh to free.
  49782. * @hidden
  49783. */
  49784. _disposeMesh(mesh: Mesh): void;
  49785. /**
  49786. * Gets the class name of the effect layer
  49787. * @returns the string with the class name of the effect layer
  49788. */
  49789. getClassName(): string;
  49790. /**
  49791. * Serializes this glow layer
  49792. * @returns a serialized glow layer object
  49793. */
  49794. serialize(): any;
  49795. /**
  49796. * Creates a Glow Layer from parsed glow layer data
  49797. * @param parsedGlowLayer defines glow layer data
  49798. * @param scene defines the current scene
  49799. * @param rootUrl defines the root URL containing the glow layer information
  49800. * @returns a parsed Glow Layer
  49801. */
  49802. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49803. }
  49804. }
  49805. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49806. /** @hidden */
  49807. export var glowBlurPostProcessPixelShader: {
  49808. name: string;
  49809. shader: string;
  49810. };
  49811. }
  49812. declare module "babylonjs/Layers/highlightLayer" {
  49813. import { Observable } from "babylonjs/Misc/observable";
  49814. import { Nullable } from "babylonjs/types";
  49815. import { Camera } from "babylonjs/Cameras/camera";
  49816. import { Scene } from "babylonjs/scene";
  49817. import { Color3, Color4 } from "babylonjs/Maths/math";
  49818. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49820. import { Mesh } from "babylonjs/Meshes/mesh";
  49821. import { Effect } from "babylonjs/Materials/effect";
  49822. import { Material } from "babylonjs/Materials/material";
  49823. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49824. import "babylonjs/Shaders/glowMapMerge.fragment";
  49825. import "babylonjs/Shaders/glowMapMerge.vertex";
  49826. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49827. module "babylonjs/abstractScene" {
  49828. interface AbstractScene {
  49829. /**
  49830. * Return a the first highlight layer of the scene with a given name.
  49831. * @param name The name of the highlight layer to look for.
  49832. * @return The highlight layer if found otherwise null.
  49833. */
  49834. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49835. }
  49836. }
  49837. /**
  49838. * Highlight layer options. This helps customizing the behaviour
  49839. * of the highlight layer.
  49840. */
  49841. export interface IHighlightLayerOptions {
  49842. /**
  49843. * Multiplication factor apply to the canvas size to compute the render target size
  49844. * used to generated the glowing objects (the smaller the faster).
  49845. */
  49846. mainTextureRatio: number;
  49847. /**
  49848. * Enforces a fixed size texture to ensure resize independant blur.
  49849. */
  49850. mainTextureFixedSize?: number;
  49851. /**
  49852. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49853. * of the picture to blur (the smaller the faster).
  49854. */
  49855. blurTextureSizeRatio: number;
  49856. /**
  49857. * How big in texel of the blur texture is the vertical blur.
  49858. */
  49859. blurVerticalSize: number;
  49860. /**
  49861. * How big in texel of the blur texture is the horizontal blur.
  49862. */
  49863. blurHorizontalSize: number;
  49864. /**
  49865. * Alpha blending mode used to apply the blur. Default is combine.
  49866. */
  49867. alphaBlendingMode: number;
  49868. /**
  49869. * The camera attached to the layer.
  49870. */
  49871. camera: Nullable<Camera>;
  49872. /**
  49873. * Should we display highlight as a solid stroke?
  49874. */
  49875. isStroke?: boolean;
  49876. /**
  49877. * The rendering group to draw the layer in.
  49878. */
  49879. renderingGroupId: number;
  49880. }
  49881. /**
  49882. * The highlight layer Helps adding a glow effect around a mesh.
  49883. *
  49884. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49885. * glowy meshes to your scene.
  49886. *
  49887. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49888. */
  49889. export class HighlightLayer extends EffectLayer {
  49890. name: string;
  49891. /**
  49892. * Effect Name of the highlight layer.
  49893. */
  49894. static readonly EffectName: string;
  49895. /**
  49896. * The neutral color used during the preparation of the glow effect.
  49897. * This is black by default as the blend operation is a blend operation.
  49898. */
  49899. static NeutralColor: Color4;
  49900. /**
  49901. * Stencil value used for glowing meshes.
  49902. */
  49903. static GlowingMeshStencilReference: number;
  49904. /**
  49905. * Stencil value used for the other meshes in the scene.
  49906. */
  49907. static NormalMeshStencilReference: number;
  49908. /**
  49909. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49910. */
  49911. innerGlow: boolean;
  49912. /**
  49913. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49914. */
  49915. outerGlow: boolean;
  49916. /**
  49917. * Specifies the horizontal size of the blur.
  49918. */
  49919. /**
  49920. * Gets the horizontal size of the blur.
  49921. */
  49922. blurHorizontalSize: number;
  49923. /**
  49924. * Specifies the vertical size of the blur.
  49925. */
  49926. /**
  49927. * Gets the vertical size of the blur.
  49928. */
  49929. blurVerticalSize: number;
  49930. /**
  49931. * An event triggered when the highlight layer is being blurred.
  49932. */
  49933. onBeforeBlurObservable: Observable<HighlightLayer>;
  49934. /**
  49935. * An event triggered when the highlight layer has been blurred.
  49936. */
  49937. onAfterBlurObservable: Observable<HighlightLayer>;
  49938. private _instanceGlowingMeshStencilReference;
  49939. private _options;
  49940. private _downSamplePostprocess;
  49941. private _horizontalBlurPostprocess;
  49942. private _verticalBlurPostprocess;
  49943. private _blurTexture;
  49944. private _meshes;
  49945. private _excludedMeshes;
  49946. /**
  49947. * Instantiates a new highlight Layer and references it to the scene..
  49948. * @param name The name of the layer
  49949. * @param scene The scene to use the layer in
  49950. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49951. */
  49952. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49953. /**
  49954. * Get the effect name of the layer.
  49955. * @return The effect name
  49956. */
  49957. getEffectName(): string;
  49958. /**
  49959. * Create the merge effect. This is the shader use to blit the information back
  49960. * to the main canvas at the end of the scene rendering.
  49961. */
  49962. protected _createMergeEffect(): Effect;
  49963. /**
  49964. * Creates the render target textures and post processes used in the highlight layer.
  49965. */
  49966. protected _createTextureAndPostProcesses(): void;
  49967. /**
  49968. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49969. */
  49970. needStencil(): boolean;
  49971. /**
  49972. * Checks for the readiness of the element composing the layer.
  49973. * @param subMesh the mesh to check for
  49974. * @param useInstances specify wether or not to use instances to render the mesh
  49975. * @param emissiveTexture the associated emissive texture used to generate the glow
  49976. * @return true if ready otherwise, false
  49977. */
  49978. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49979. /**
  49980. * Implementation specific of rendering the generating effect on the main canvas.
  49981. * @param effect The effect used to render through
  49982. */
  49983. protected _internalRender(effect: Effect): void;
  49984. /**
  49985. * Returns true if the layer contains information to display, otherwise false.
  49986. */
  49987. shouldRender(): boolean;
  49988. /**
  49989. * Returns true if the mesh should render, otherwise false.
  49990. * @param mesh The mesh to render
  49991. * @returns true if it should render otherwise false
  49992. */
  49993. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49994. /**
  49995. * Sets the required values for both the emissive texture and and the main color.
  49996. */
  49997. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49998. /**
  49999. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50000. * @param mesh The mesh to exclude from the highlight layer
  50001. */
  50002. addExcludedMesh(mesh: Mesh): void;
  50003. /**
  50004. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50005. * @param mesh The mesh to highlight
  50006. */
  50007. removeExcludedMesh(mesh: Mesh): void;
  50008. /**
  50009. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50010. * @param mesh mesh to test
  50011. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50012. */
  50013. hasMesh(mesh: AbstractMesh): boolean;
  50014. /**
  50015. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50016. * @param mesh The mesh to highlight
  50017. * @param color The color of the highlight
  50018. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50019. */
  50020. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50021. /**
  50022. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50023. * @param mesh The mesh to highlight
  50024. */
  50025. removeMesh(mesh: Mesh): void;
  50026. /**
  50027. * Force the stencil to the normal expected value for none glowing parts
  50028. */
  50029. private _defaultStencilReference;
  50030. /**
  50031. * Free any resources and references associated to a mesh.
  50032. * Internal use
  50033. * @param mesh The mesh to free.
  50034. * @hidden
  50035. */
  50036. _disposeMesh(mesh: Mesh): void;
  50037. /**
  50038. * Dispose the highlight layer and free resources.
  50039. */
  50040. dispose(): void;
  50041. /**
  50042. * Gets the class name of the effect layer
  50043. * @returns the string with the class name of the effect layer
  50044. */
  50045. getClassName(): string;
  50046. /**
  50047. * Serializes this Highlight layer
  50048. * @returns a serialized Highlight layer object
  50049. */
  50050. serialize(): any;
  50051. /**
  50052. * Creates a Highlight layer from parsed Highlight layer data
  50053. * @param parsedHightlightLayer defines the Highlight layer data
  50054. * @param scene defines the current scene
  50055. * @param rootUrl defines the root URL containing the Highlight layer information
  50056. * @returns a parsed Highlight layer
  50057. */
  50058. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50059. }
  50060. }
  50061. declare module "babylonjs/Layers/layerSceneComponent" {
  50062. import { Scene } from "babylonjs/scene";
  50063. import { ISceneComponent } from "babylonjs/sceneComponent";
  50064. import { Layer } from "babylonjs/Layers/layer";
  50065. import { AbstractScene } from "babylonjs/abstractScene";
  50066. module "babylonjs/abstractScene" {
  50067. interface AbstractScene {
  50068. /**
  50069. * The list of layers (background and foreground) of the scene
  50070. */
  50071. layers: Array<Layer>;
  50072. }
  50073. }
  50074. /**
  50075. * Defines the layer scene component responsible to manage any layers
  50076. * in a given scene.
  50077. */
  50078. export class LayerSceneComponent implements ISceneComponent {
  50079. /**
  50080. * The component name helpfull to identify the component in the list of scene components.
  50081. */
  50082. readonly name: string;
  50083. /**
  50084. * The scene the component belongs to.
  50085. */
  50086. scene: Scene;
  50087. private _engine;
  50088. /**
  50089. * Creates a new instance of the component for the given scene
  50090. * @param scene Defines the scene to register the component in
  50091. */
  50092. constructor(scene: Scene);
  50093. /**
  50094. * Registers the component in a given scene
  50095. */
  50096. register(): void;
  50097. /**
  50098. * Rebuilds the elements related to this component in case of
  50099. * context lost for instance.
  50100. */
  50101. rebuild(): void;
  50102. /**
  50103. * Disposes the component and the associated ressources.
  50104. */
  50105. dispose(): void;
  50106. private _draw;
  50107. private _drawCameraPredicate;
  50108. private _drawCameraBackground;
  50109. private _drawCameraForeground;
  50110. private _drawRenderTargetPredicate;
  50111. private _drawRenderTargetBackground;
  50112. private _drawRenderTargetForeground;
  50113. /**
  50114. * Adds all the elements from the container to the scene
  50115. * @param container the container holding the elements
  50116. */
  50117. addFromContainer(container: AbstractScene): void;
  50118. /**
  50119. * Removes all the elements in the container from the scene
  50120. * @param container contains the elements to remove
  50121. * @param dispose if the removed element should be disposed (default: false)
  50122. */
  50123. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50124. }
  50125. }
  50126. declare module "babylonjs/Shaders/layer.fragment" {
  50127. /** @hidden */
  50128. export var layerPixelShader: {
  50129. name: string;
  50130. shader: string;
  50131. };
  50132. }
  50133. declare module "babylonjs/Shaders/layer.vertex" {
  50134. /** @hidden */
  50135. export var layerVertexShader: {
  50136. name: string;
  50137. shader: string;
  50138. };
  50139. }
  50140. declare module "babylonjs/Layers/layer" {
  50141. import { Observable } from "babylonjs/Misc/observable";
  50142. import { Nullable } from "babylonjs/types";
  50143. import { Scene } from "babylonjs/scene";
  50144. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50145. import { Texture } from "babylonjs/Materials/Textures/texture";
  50146. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50147. import "babylonjs/Shaders/layer.fragment";
  50148. import "babylonjs/Shaders/layer.vertex";
  50149. /**
  50150. * This represents a full screen 2d layer.
  50151. * This can be useful to display a picture in the background of your scene for instance.
  50152. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50153. */
  50154. export class Layer {
  50155. /**
  50156. * Define the name of the layer.
  50157. */
  50158. name: string;
  50159. /**
  50160. * Define the texture the layer should display.
  50161. */
  50162. texture: Nullable<Texture>;
  50163. /**
  50164. * Is the layer in background or foreground.
  50165. */
  50166. isBackground: boolean;
  50167. /**
  50168. * Define the color of the layer (instead of texture).
  50169. */
  50170. color: Color4;
  50171. /**
  50172. * Define the scale of the layer in order to zoom in out of the texture.
  50173. */
  50174. scale: Vector2;
  50175. /**
  50176. * Define an offset for the layer in order to shift the texture.
  50177. */
  50178. offset: Vector2;
  50179. /**
  50180. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50181. */
  50182. alphaBlendingMode: number;
  50183. /**
  50184. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50185. * Alpha test will not mix with the background color in case of transparency.
  50186. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50187. */
  50188. alphaTest: boolean;
  50189. /**
  50190. * Define a mask to restrict the layer to only some of the scene cameras.
  50191. */
  50192. layerMask: number;
  50193. /**
  50194. * Define the list of render target the layer is visible into.
  50195. */
  50196. renderTargetTextures: RenderTargetTexture[];
  50197. /**
  50198. * Define if the layer is only used in renderTarget or if it also
  50199. * renders in the main frame buffer of the canvas.
  50200. */
  50201. renderOnlyInRenderTargetTextures: boolean;
  50202. private _scene;
  50203. private _vertexBuffers;
  50204. private _indexBuffer;
  50205. private _effect;
  50206. private _alphaTestEffect;
  50207. /**
  50208. * An event triggered when the layer is disposed.
  50209. */
  50210. onDisposeObservable: Observable<Layer>;
  50211. private _onDisposeObserver;
  50212. /**
  50213. * Back compatibility with callback before the onDisposeObservable existed.
  50214. * The set callback will be triggered when the layer has been disposed.
  50215. */
  50216. onDispose: () => void;
  50217. /**
  50218. * An event triggered before rendering the scene
  50219. */
  50220. onBeforeRenderObservable: Observable<Layer>;
  50221. private _onBeforeRenderObserver;
  50222. /**
  50223. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50224. * The set callback will be triggered just before rendering the layer.
  50225. */
  50226. onBeforeRender: () => void;
  50227. /**
  50228. * An event triggered after rendering the scene
  50229. */
  50230. onAfterRenderObservable: Observable<Layer>;
  50231. private _onAfterRenderObserver;
  50232. /**
  50233. * Back compatibility with callback before the onAfterRenderObservable existed.
  50234. * The set callback will be triggered just after rendering the layer.
  50235. */
  50236. onAfterRender: () => void;
  50237. /**
  50238. * Instantiates a new layer.
  50239. * This represents a full screen 2d layer.
  50240. * This can be useful to display a picture in the background of your scene for instance.
  50241. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50242. * @param name Define the name of the layer in the scene
  50243. * @param imgUrl Define the url of the texture to display in the layer
  50244. * @param scene Define the scene the layer belongs to
  50245. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50246. * @param color Defines a color for the layer
  50247. */
  50248. constructor(
  50249. /**
  50250. * Define the name of the layer.
  50251. */
  50252. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50253. private _createIndexBuffer;
  50254. /** @hidden */
  50255. _rebuild(): void;
  50256. /**
  50257. * Renders the layer in the scene.
  50258. */
  50259. render(): void;
  50260. /**
  50261. * Disposes and releases the associated ressources.
  50262. */
  50263. dispose(): void;
  50264. }
  50265. }
  50266. declare module "babylonjs/Layers/index" {
  50267. export * from "babylonjs/Layers/effectLayer";
  50268. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50269. export * from "babylonjs/Layers/glowLayer";
  50270. export * from "babylonjs/Layers/highlightLayer";
  50271. export * from "babylonjs/Layers/layer";
  50272. export * from "babylonjs/Layers/layerSceneComponent";
  50273. }
  50274. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50275. /** @hidden */
  50276. export var lensFlarePixelShader: {
  50277. name: string;
  50278. shader: string;
  50279. };
  50280. }
  50281. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50282. /** @hidden */
  50283. export var lensFlareVertexShader: {
  50284. name: string;
  50285. shader: string;
  50286. };
  50287. }
  50288. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50289. import { Scene } from "babylonjs/scene";
  50290. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50292. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50293. import "babylonjs/Shaders/lensFlare.fragment";
  50294. import "babylonjs/Shaders/lensFlare.vertex";
  50295. /**
  50296. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50297. * It is usually composed of several `lensFlare`.
  50298. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50299. */
  50300. export class LensFlareSystem {
  50301. /**
  50302. * Define the name of the lens flare system
  50303. */
  50304. name: string;
  50305. /**
  50306. * List of lens flares used in this system.
  50307. */
  50308. lensFlares: LensFlare[];
  50309. /**
  50310. * Define a limit from the border the lens flare can be visible.
  50311. */
  50312. borderLimit: number;
  50313. /**
  50314. * Define a viewport border we do not want to see the lens flare in.
  50315. */
  50316. viewportBorder: number;
  50317. /**
  50318. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50319. */
  50320. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50321. /**
  50322. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50323. */
  50324. layerMask: number;
  50325. /**
  50326. * Define the id of the lens flare system in the scene.
  50327. * (equal to name by default)
  50328. */
  50329. id: string;
  50330. private _scene;
  50331. private _emitter;
  50332. private _vertexBuffers;
  50333. private _indexBuffer;
  50334. private _effect;
  50335. private _positionX;
  50336. private _positionY;
  50337. private _isEnabled;
  50338. /** @hidden */
  50339. static _SceneComponentInitialization: (scene: Scene) => void;
  50340. /**
  50341. * Instantiates a lens flare system.
  50342. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50343. * It is usually composed of several `lensFlare`.
  50344. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50345. * @param name Define the name of the lens flare system in the scene
  50346. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50347. * @param scene Define the scene the lens flare system belongs to
  50348. */
  50349. constructor(
  50350. /**
  50351. * Define the name of the lens flare system
  50352. */
  50353. name: string, emitter: any, scene: Scene);
  50354. /**
  50355. * Define if the lens flare system is enabled.
  50356. */
  50357. isEnabled: boolean;
  50358. /**
  50359. * Get the scene the effects belongs to.
  50360. * @returns the scene holding the lens flare system
  50361. */
  50362. getScene(): Scene;
  50363. /**
  50364. * Get the emitter of the lens flare system.
  50365. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50366. * @returns the emitter of the lens flare system
  50367. */
  50368. getEmitter(): any;
  50369. /**
  50370. * Set the emitter of the lens flare system.
  50371. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50372. * @param newEmitter Define the new emitter of the system
  50373. */
  50374. setEmitter(newEmitter: any): void;
  50375. /**
  50376. * Get the lens flare system emitter position.
  50377. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50378. * @returns the position
  50379. */
  50380. getEmitterPosition(): Vector3;
  50381. /**
  50382. * @hidden
  50383. */
  50384. computeEffectivePosition(globalViewport: Viewport): boolean;
  50385. /** @hidden */
  50386. _isVisible(): boolean;
  50387. /**
  50388. * @hidden
  50389. */
  50390. render(): boolean;
  50391. /**
  50392. * Dispose and release the lens flare with its associated resources.
  50393. */
  50394. dispose(): void;
  50395. /**
  50396. * Parse a lens flare system from a JSON repressentation
  50397. * @param parsedLensFlareSystem Define the JSON to parse
  50398. * @param scene Define the scene the parsed system should be instantiated in
  50399. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50400. * @returns the parsed system
  50401. */
  50402. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50403. /**
  50404. * Serialize the current Lens Flare System into a JSON representation.
  50405. * @returns the serialized JSON
  50406. */
  50407. serialize(): any;
  50408. }
  50409. }
  50410. declare module "babylonjs/LensFlares/lensFlare" {
  50411. import { Nullable } from "babylonjs/types";
  50412. import { Color3 } from "babylonjs/Maths/math";
  50413. import { Texture } from "babylonjs/Materials/Textures/texture";
  50414. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50415. /**
  50416. * This represents one of the lens effect in a `lensFlareSystem`.
  50417. * It controls one of the indiviual texture used in the effect.
  50418. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50419. */
  50420. export class LensFlare {
  50421. /**
  50422. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50423. */
  50424. size: number;
  50425. /**
  50426. * 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.
  50427. */
  50428. position: number;
  50429. /**
  50430. * Define the lens color.
  50431. */
  50432. color: Color3;
  50433. /**
  50434. * Define the lens texture.
  50435. */
  50436. texture: Nullable<Texture>;
  50437. /**
  50438. * Define the alpha mode to render this particular lens.
  50439. */
  50440. alphaMode: number;
  50441. private _system;
  50442. /**
  50443. * Creates a new Lens Flare.
  50444. * This represents one of the lens effect in a `lensFlareSystem`.
  50445. * It controls one of the indiviual texture used in the effect.
  50446. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50447. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50448. * @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.
  50449. * @param color Define the lens color
  50450. * @param imgUrl Define the lens texture url
  50451. * @param system Define the `lensFlareSystem` this flare is part of
  50452. * @returns The newly created Lens Flare
  50453. */
  50454. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50455. /**
  50456. * Instantiates a new Lens Flare.
  50457. * This represents one of the lens effect in a `lensFlareSystem`.
  50458. * It controls one of the indiviual texture used in the effect.
  50459. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50460. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50461. * @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.
  50462. * @param color Define the lens color
  50463. * @param imgUrl Define the lens texture url
  50464. * @param system Define the `lensFlareSystem` this flare is part of
  50465. */
  50466. constructor(
  50467. /**
  50468. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50469. */
  50470. size: number,
  50471. /**
  50472. * 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.
  50473. */
  50474. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50475. /**
  50476. * Dispose and release the lens flare with its associated resources.
  50477. */
  50478. dispose(): void;
  50479. }
  50480. }
  50481. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50482. import { Nullable } from "babylonjs/types";
  50483. import { Scene } from "babylonjs/scene";
  50484. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50485. import { AbstractScene } from "babylonjs/abstractScene";
  50486. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50487. module "babylonjs/abstractScene" {
  50488. interface AbstractScene {
  50489. /**
  50490. * The list of lens flare system added to the scene
  50491. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50492. */
  50493. lensFlareSystems: Array<LensFlareSystem>;
  50494. /**
  50495. * Removes the given lens flare system from this scene.
  50496. * @param toRemove The lens flare system to remove
  50497. * @returns The index of the removed lens flare system
  50498. */
  50499. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50500. /**
  50501. * Adds the given lens flare system to this scene
  50502. * @param newLensFlareSystem The lens flare system to add
  50503. */
  50504. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50505. /**
  50506. * Gets a lens flare system using its name
  50507. * @param name defines the name to look for
  50508. * @returns the lens flare system or null if not found
  50509. */
  50510. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50511. /**
  50512. * Gets a lens flare system using its id
  50513. * @param id defines the id to look for
  50514. * @returns the lens flare system or null if not found
  50515. */
  50516. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50517. }
  50518. }
  50519. /**
  50520. * Defines the lens flare scene component responsible to manage any lens flares
  50521. * in a given scene.
  50522. */
  50523. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50524. /**
  50525. * The component name helpfull to identify the component in the list of scene components.
  50526. */
  50527. readonly name: string;
  50528. /**
  50529. * The scene the component belongs to.
  50530. */
  50531. scene: Scene;
  50532. /**
  50533. * Creates a new instance of the component for the given scene
  50534. * @param scene Defines the scene to register the component in
  50535. */
  50536. constructor(scene: Scene);
  50537. /**
  50538. * Registers the component in a given scene
  50539. */
  50540. register(): void;
  50541. /**
  50542. * Rebuilds the elements related to this component in case of
  50543. * context lost for instance.
  50544. */
  50545. rebuild(): void;
  50546. /**
  50547. * Adds all the elements from the container to the scene
  50548. * @param container the container holding the elements
  50549. */
  50550. addFromContainer(container: AbstractScene): void;
  50551. /**
  50552. * Removes all the elements in the container from the scene
  50553. * @param container contains the elements to remove
  50554. * @param dispose if the removed element should be disposed (default: false)
  50555. */
  50556. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50557. /**
  50558. * Serializes the component data to the specified json object
  50559. * @param serializationObject The object to serialize to
  50560. */
  50561. serialize(serializationObject: any): void;
  50562. /**
  50563. * Disposes the component and the associated ressources.
  50564. */
  50565. dispose(): void;
  50566. private _draw;
  50567. }
  50568. }
  50569. declare module "babylonjs/LensFlares/index" {
  50570. export * from "babylonjs/LensFlares/lensFlare";
  50571. export * from "babylonjs/LensFlares/lensFlareSystem";
  50572. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50573. }
  50574. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50575. import { Scene } from "babylonjs/scene";
  50576. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50577. import { AbstractScene } from "babylonjs/abstractScene";
  50578. /**
  50579. * Defines the shadow generator component responsible to manage any shadow generators
  50580. * in a given scene.
  50581. */
  50582. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50583. /**
  50584. * The component name helpfull to identify the component in the list of scene components.
  50585. */
  50586. readonly name: string;
  50587. /**
  50588. * The scene the component belongs to.
  50589. */
  50590. scene: Scene;
  50591. /**
  50592. * Creates a new instance of the component for the given scene
  50593. * @param scene Defines the scene to register the component in
  50594. */
  50595. constructor(scene: Scene);
  50596. /**
  50597. * Registers the component in a given scene
  50598. */
  50599. register(): void;
  50600. /**
  50601. * Rebuilds the elements related to this component in case of
  50602. * context lost for instance.
  50603. */
  50604. rebuild(): void;
  50605. /**
  50606. * Serializes the component data to the specified json object
  50607. * @param serializationObject The object to serialize to
  50608. */
  50609. serialize(serializationObject: any): void;
  50610. /**
  50611. * Adds all the elements from the container to the scene
  50612. * @param container the container holding the elements
  50613. */
  50614. addFromContainer(container: AbstractScene): void;
  50615. /**
  50616. * Removes all the elements in the container from the scene
  50617. * @param container contains the elements to remove
  50618. * @param dispose if the removed element should be disposed (default: false)
  50619. */
  50620. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50621. /**
  50622. * Rebuilds the elements related to this component in case of
  50623. * context lost for instance.
  50624. */
  50625. dispose(): void;
  50626. private _gatherRenderTargets;
  50627. }
  50628. }
  50629. declare module "babylonjs/Lights/Shadows/index" {
  50630. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50631. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50632. }
  50633. declare module "babylonjs/Lights/pointLight" {
  50634. import { Scene } from "babylonjs/scene";
  50635. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50637. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50638. import { Effect } from "babylonjs/Materials/effect";
  50639. /**
  50640. * A point light is a light defined by an unique point in world space.
  50641. * The light is emitted in every direction from this point.
  50642. * A good example of a point light is a standard light bulb.
  50643. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50644. */
  50645. export class PointLight extends ShadowLight {
  50646. private _shadowAngle;
  50647. /**
  50648. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50649. * This specifies what angle the shadow will use to be created.
  50650. *
  50651. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50652. */
  50653. /**
  50654. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50655. * This specifies what angle the shadow will use to be created.
  50656. *
  50657. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50658. */
  50659. shadowAngle: number;
  50660. /**
  50661. * Gets the direction if it has been set.
  50662. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50663. */
  50664. /**
  50665. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50666. */
  50667. direction: Vector3;
  50668. /**
  50669. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50670. * A PointLight emits the light in every direction.
  50671. * It can cast shadows.
  50672. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50673. * ```javascript
  50674. * var pointLight = new PointLight("pl", camera.position, scene);
  50675. * ```
  50676. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50677. * @param name The light friendly name
  50678. * @param position The position of the point light in the scene
  50679. * @param scene The scene the lights belongs to
  50680. */
  50681. constructor(name: string, position: Vector3, scene: Scene);
  50682. /**
  50683. * Returns the string "PointLight"
  50684. * @returns the class name
  50685. */
  50686. getClassName(): string;
  50687. /**
  50688. * Returns the integer 0.
  50689. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50690. */
  50691. getTypeID(): number;
  50692. /**
  50693. * Specifies wether or not the shadowmap should be a cube texture.
  50694. * @returns true if the shadowmap needs to be a cube texture.
  50695. */
  50696. needCube(): boolean;
  50697. /**
  50698. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50699. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50700. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50701. */
  50702. getShadowDirection(faceIndex?: number): Vector3;
  50703. /**
  50704. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50705. * - fov = PI / 2
  50706. * - aspect ratio : 1.0
  50707. * - z-near and far equal to the active camera minZ and maxZ.
  50708. * Returns the PointLight.
  50709. */
  50710. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50711. protected _buildUniformLayout(): void;
  50712. /**
  50713. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50714. * @param effect The effect to update
  50715. * @param lightIndex The index of the light in the effect to update
  50716. * @returns The point light
  50717. */
  50718. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50719. /**
  50720. * Prepares the list of defines specific to the light type.
  50721. * @param defines the list of defines
  50722. * @param lightIndex defines the index of the light for the effect
  50723. */
  50724. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50725. }
  50726. }
  50727. declare module "babylonjs/Lights/index" {
  50728. export * from "babylonjs/Lights/light";
  50729. export * from "babylonjs/Lights/shadowLight";
  50730. export * from "babylonjs/Lights/Shadows/index";
  50731. export * from "babylonjs/Lights/directionalLight";
  50732. export * from "babylonjs/Lights/hemisphericLight";
  50733. export * from "babylonjs/Lights/pointLight";
  50734. export * from "babylonjs/Lights/spotLight";
  50735. }
  50736. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50737. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50738. /**
  50739. * Header information of HDR texture files.
  50740. */
  50741. export interface HDRInfo {
  50742. /**
  50743. * The height of the texture in pixels.
  50744. */
  50745. height: number;
  50746. /**
  50747. * The width of the texture in pixels.
  50748. */
  50749. width: number;
  50750. /**
  50751. * The index of the beginning of the data in the binary file.
  50752. */
  50753. dataPosition: number;
  50754. }
  50755. /**
  50756. * This groups tools to convert HDR texture to native colors array.
  50757. */
  50758. export class HDRTools {
  50759. private static Ldexp;
  50760. private static Rgbe2float;
  50761. private static readStringLine;
  50762. /**
  50763. * Reads header information from an RGBE texture stored in a native array.
  50764. * More information on this format are available here:
  50765. * https://en.wikipedia.org/wiki/RGBE_image_format
  50766. *
  50767. * @param uint8array The binary file stored in native array.
  50768. * @return The header information.
  50769. */
  50770. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50771. /**
  50772. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50773. * This RGBE texture needs to store the information as a panorama.
  50774. *
  50775. * More information on this format are available here:
  50776. * https://en.wikipedia.org/wiki/RGBE_image_format
  50777. *
  50778. * @param buffer The binary file stored in an array buffer.
  50779. * @param size The expected size of the extracted cubemap.
  50780. * @return The Cube Map information.
  50781. */
  50782. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50783. /**
  50784. * Returns the pixels data extracted from an RGBE texture.
  50785. * This pixels will be stored left to right up to down in the R G B order in one array.
  50786. *
  50787. * More information on this format are available here:
  50788. * https://en.wikipedia.org/wiki/RGBE_image_format
  50789. *
  50790. * @param uint8array The binary file stored in an array buffer.
  50791. * @param hdrInfo The header information of the file.
  50792. * @return The pixels data in RGB right to left up to down order.
  50793. */
  50794. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50795. private static RGBE_ReadPixels_RLE;
  50796. }
  50797. }
  50798. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50799. import { Nullable } from "babylonjs/types";
  50800. import { Scene } from "babylonjs/scene";
  50801. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50803. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50804. /**
  50805. * This represents a texture coming from an HDR input.
  50806. *
  50807. * The only supported format is currently panorama picture stored in RGBE format.
  50808. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50809. */
  50810. export class HDRCubeTexture extends BaseTexture {
  50811. private static _facesMapping;
  50812. private _generateHarmonics;
  50813. private _noMipmap;
  50814. private _textureMatrix;
  50815. private _size;
  50816. private _onLoad;
  50817. private _onError;
  50818. /**
  50819. * The texture URL.
  50820. */
  50821. url: string;
  50822. /**
  50823. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50824. */
  50825. coordinatesMode: number;
  50826. protected _isBlocking: boolean;
  50827. /**
  50828. * Sets wether or not the texture is blocking during loading.
  50829. */
  50830. /**
  50831. * Gets wether or not the texture is blocking during loading.
  50832. */
  50833. isBlocking: boolean;
  50834. protected _rotationY: number;
  50835. /**
  50836. * Sets texture matrix rotation angle around Y axis in radians.
  50837. */
  50838. /**
  50839. * Gets texture matrix rotation angle around Y axis radians.
  50840. */
  50841. rotationY: number;
  50842. /**
  50843. * Gets or sets the center of the bounding box associated with the cube texture
  50844. * It must define where the camera used to render the texture was set
  50845. */
  50846. boundingBoxPosition: Vector3;
  50847. private _boundingBoxSize;
  50848. /**
  50849. * Gets or sets the size of the bounding box associated with the cube texture
  50850. * When defined, the cubemap will switch to local mode
  50851. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50852. * @example https://www.babylonjs-playground.com/#RNASML
  50853. */
  50854. boundingBoxSize: Vector3;
  50855. /**
  50856. * Instantiates an HDRTexture from the following parameters.
  50857. *
  50858. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50859. * @param scene The scene the texture will be used in
  50860. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50861. * @param noMipmap Forces to not generate the mipmap if true
  50862. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50863. * @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)
  50864. * @param reserved Reserved flag for internal use.
  50865. */
  50866. 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>);
  50867. /**
  50868. * Get the current class name of the texture useful for serialization or dynamic coding.
  50869. * @returns "HDRCubeTexture"
  50870. */
  50871. getClassName(): string;
  50872. /**
  50873. * Occurs when the file is raw .hdr file.
  50874. */
  50875. private loadTexture;
  50876. clone(): HDRCubeTexture;
  50877. delayLoad(): void;
  50878. /**
  50879. * Get the texture reflection matrix used to rotate/transform the reflection.
  50880. * @returns the reflection matrix
  50881. */
  50882. getReflectionTextureMatrix(): Matrix;
  50883. /**
  50884. * Set the texture reflection matrix used to rotate/transform the reflection.
  50885. * @param value Define the reflection matrix to set
  50886. */
  50887. setReflectionTextureMatrix(value: Matrix): void;
  50888. /**
  50889. * Parses a JSON representation of an HDR Texture in order to create the texture
  50890. * @param parsedTexture Define the JSON representation
  50891. * @param scene Define the scene the texture should be created in
  50892. * @param rootUrl Define the root url in case we need to load relative dependencies
  50893. * @returns the newly created texture after parsing
  50894. */
  50895. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50896. serialize(): any;
  50897. }
  50898. }
  50899. declare module "babylonjs/Physics/physicsEngine" {
  50900. import { Nullable } from "babylonjs/types";
  50901. import { Vector3 } from "babylonjs/Maths/math";
  50902. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50903. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50904. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50905. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50906. /**
  50907. * Class used to control physics engine
  50908. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50909. */
  50910. export class PhysicsEngine implements IPhysicsEngine {
  50911. private _physicsPlugin;
  50912. /**
  50913. * Global value used to control the smallest number supported by the simulation
  50914. */
  50915. static Epsilon: number;
  50916. private _impostors;
  50917. private _joints;
  50918. /**
  50919. * Gets the gravity vector used by the simulation
  50920. */
  50921. gravity: Vector3;
  50922. /**
  50923. * Factory used to create the default physics plugin.
  50924. * @returns The default physics plugin
  50925. */
  50926. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50927. /**
  50928. * Creates a new Physics Engine
  50929. * @param gravity defines the gravity vector used by the simulation
  50930. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50931. */
  50932. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50933. /**
  50934. * Sets the gravity vector used by the simulation
  50935. * @param gravity defines the gravity vector to use
  50936. */
  50937. setGravity(gravity: Vector3): void;
  50938. /**
  50939. * Set the time step of the physics engine.
  50940. * Default is 1/60.
  50941. * To slow it down, enter 1/600 for example.
  50942. * To speed it up, 1/30
  50943. * @param newTimeStep defines the new timestep to apply to this world.
  50944. */
  50945. setTimeStep(newTimeStep?: number): void;
  50946. /**
  50947. * Get the time step of the physics engine.
  50948. * @returns the current time step
  50949. */
  50950. getTimeStep(): number;
  50951. /**
  50952. * Release all resources
  50953. */
  50954. dispose(): void;
  50955. /**
  50956. * Gets the name of the current physics plugin
  50957. * @returns the name of the plugin
  50958. */
  50959. getPhysicsPluginName(): string;
  50960. /**
  50961. * Adding a new impostor for the impostor tracking.
  50962. * This will be done by the impostor itself.
  50963. * @param impostor the impostor to add
  50964. */
  50965. addImpostor(impostor: PhysicsImpostor): void;
  50966. /**
  50967. * Remove an impostor from the engine.
  50968. * This impostor and its mesh will not longer be updated by the physics engine.
  50969. * @param impostor the impostor to remove
  50970. */
  50971. removeImpostor(impostor: PhysicsImpostor): void;
  50972. /**
  50973. * Add a joint to the physics engine
  50974. * @param mainImpostor defines the main impostor to which the joint is added.
  50975. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50976. * @param joint defines the joint that will connect both impostors.
  50977. */
  50978. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50979. /**
  50980. * Removes a joint from the simulation
  50981. * @param mainImpostor defines the impostor used with the joint
  50982. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50983. * @param joint defines the joint to remove
  50984. */
  50985. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50986. /**
  50987. * Called by the scene. No need to call it.
  50988. * @param delta defines the timespam between frames
  50989. */
  50990. _step(delta: number): void;
  50991. /**
  50992. * Gets the current plugin used to run the simulation
  50993. * @returns current plugin
  50994. */
  50995. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50996. /**
  50997. * Gets the list of physic impostors
  50998. * @returns an array of PhysicsImpostor
  50999. */
  51000. getImpostors(): Array<PhysicsImpostor>;
  51001. /**
  51002. * Gets the impostor for a physics enabled object
  51003. * @param object defines the object impersonated by the impostor
  51004. * @returns the PhysicsImpostor or null if not found
  51005. */
  51006. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51007. /**
  51008. * Gets the impostor for a physics body object
  51009. * @param body defines physics body used by the impostor
  51010. * @returns the PhysicsImpostor or null if not found
  51011. */
  51012. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51013. /**
  51014. * Does a raycast in the physics world
  51015. * @param from when should the ray start?
  51016. * @param to when should the ray end?
  51017. * @returns PhysicsRaycastResult
  51018. */
  51019. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51020. }
  51021. }
  51022. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51023. import { Nullable } from "babylonjs/types";
  51024. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51026. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51027. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51028. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51029. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51030. /** @hidden */
  51031. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51032. private _useDeltaForWorldStep;
  51033. world: any;
  51034. name: string;
  51035. private _physicsMaterials;
  51036. private _fixedTimeStep;
  51037. private _cannonRaycastResult;
  51038. private _raycastResult;
  51039. private _removeAfterStep;
  51040. BJSCANNON: any;
  51041. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51042. setGravity(gravity: Vector3): void;
  51043. setTimeStep(timeStep: number): void;
  51044. getTimeStep(): number;
  51045. executeStep(delta: number): void;
  51046. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51047. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51048. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51049. private _processChildMeshes;
  51050. removePhysicsBody(impostor: PhysicsImpostor): void;
  51051. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51052. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51053. private _addMaterial;
  51054. private _checkWithEpsilon;
  51055. private _createShape;
  51056. private _createHeightmap;
  51057. private _minus90X;
  51058. private _plus90X;
  51059. private _tmpPosition;
  51060. private _tmpDeltaPosition;
  51061. private _tmpUnityRotation;
  51062. private _updatePhysicsBodyTransformation;
  51063. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51064. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51065. isSupported(): boolean;
  51066. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51067. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51068. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51069. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51070. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51071. getBodyMass(impostor: PhysicsImpostor): number;
  51072. getBodyFriction(impostor: PhysicsImpostor): number;
  51073. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51074. getBodyRestitution(impostor: PhysicsImpostor): number;
  51075. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51076. sleepBody(impostor: PhysicsImpostor): void;
  51077. wakeUpBody(impostor: PhysicsImpostor): void;
  51078. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51079. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51080. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51081. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51082. getRadius(impostor: PhysicsImpostor): number;
  51083. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51084. dispose(): void;
  51085. private _extendNamespace;
  51086. /**
  51087. * Does a raycast in the physics world
  51088. * @param from when should the ray start?
  51089. * @param to when should the ray end?
  51090. * @returns PhysicsRaycastResult
  51091. */
  51092. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51093. }
  51094. }
  51095. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51096. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51097. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51098. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51100. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51101. import { Nullable } from "babylonjs/types";
  51102. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51103. /** @hidden */
  51104. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51105. world: any;
  51106. name: string;
  51107. BJSOIMO: any;
  51108. private _raycastResult;
  51109. constructor(iterations?: number, oimoInjection?: any);
  51110. setGravity(gravity: Vector3): void;
  51111. setTimeStep(timeStep: number): void;
  51112. getTimeStep(): number;
  51113. private _tmpImpostorsArray;
  51114. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51115. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51116. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51117. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51118. private _tmpPositionVector;
  51119. removePhysicsBody(impostor: PhysicsImpostor): void;
  51120. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51121. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51122. isSupported(): boolean;
  51123. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51124. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51125. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51126. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51127. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51128. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51129. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51130. getBodyMass(impostor: PhysicsImpostor): number;
  51131. getBodyFriction(impostor: PhysicsImpostor): number;
  51132. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51133. getBodyRestitution(impostor: PhysicsImpostor): number;
  51134. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51135. sleepBody(impostor: PhysicsImpostor): void;
  51136. wakeUpBody(impostor: PhysicsImpostor): void;
  51137. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51138. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51139. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51140. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51141. getRadius(impostor: PhysicsImpostor): number;
  51142. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51143. dispose(): void;
  51144. /**
  51145. * Does a raycast in the physics world
  51146. * @param from when should the ray start?
  51147. * @param to when should the ray end?
  51148. * @returns PhysicsRaycastResult
  51149. */
  51150. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51151. }
  51152. }
  51153. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51154. import { Nullable } from "babylonjs/types";
  51155. import { Scene } from "babylonjs/scene";
  51156. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51157. import { Mesh } from "babylonjs/Meshes/mesh";
  51158. /**
  51159. * Class containing static functions to help procedurally build meshes
  51160. */
  51161. export class RibbonBuilder {
  51162. /**
  51163. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51164. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51165. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51166. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51167. * * 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
  51168. * * 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
  51169. * * 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
  51170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51173. * * 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
  51174. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51175. * * 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
  51176. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51178. * @param name defines the name of the mesh
  51179. * @param options defines the options used to create the mesh
  51180. * @param scene defines the hosting scene
  51181. * @returns the ribbon mesh
  51182. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51183. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51184. */
  51185. static CreateRibbon(name: string, options: {
  51186. pathArray: Vector3[][];
  51187. closeArray?: boolean;
  51188. closePath?: boolean;
  51189. offset?: number;
  51190. updatable?: boolean;
  51191. sideOrientation?: number;
  51192. frontUVs?: Vector4;
  51193. backUVs?: Vector4;
  51194. instance?: Mesh;
  51195. invertUV?: boolean;
  51196. uvs?: Vector2[];
  51197. colors?: Color4[];
  51198. }, scene?: Nullable<Scene>): Mesh;
  51199. }
  51200. }
  51201. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51202. import { Nullable } from "babylonjs/types";
  51203. import { Scene } from "babylonjs/scene";
  51204. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51205. import { Mesh } from "babylonjs/Meshes/mesh";
  51206. /**
  51207. * Class containing static functions to help procedurally build meshes
  51208. */
  51209. export class ShapeBuilder {
  51210. /**
  51211. * 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.
  51212. * * 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.
  51213. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51214. * * 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.
  51215. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51216. * * 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
  51217. * * 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
  51218. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51221. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51223. * @param name defines the name of the mesh
  51224. * @param options defines the options used to create the mesh
  51225. * @param scene defines the hosting scene
  51226. * @returns the extruded shape mesh
  51227. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51229. */
  51230. static ExtrudeShape(name: string, options: {
  51231. shape: Vector3[];
  51232. path: Vector3[];
  51233. scale?: number;
  51234. rotation?: number;
  51235. cap?: number;
  51236. updatable?: boolean;
  51237. sideOrientation?: number;
  51238. frontUVs?: Vector4;
  51239. backUVs?: Vector4;
  51240. instance?: Mesh;
  51241. invertUV?: boolean;
  51242. }, scene?: Nullable<Scene>): Mesh;
  51243. /**
  51244. * Creates an custom extruded shape mesh.
  51245. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51246. * * 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.
  51247. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51248. * * 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
  51249. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51250. * * 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
  51251. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51252. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51253. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51254. * * 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
  51255. * * 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
  51256. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51261. * @param name defines the name of the mesh
  51262. * @param options defines the options used to create the mesh
  51263. * @param scene defines the hosting scene
  51264. * @returns the custom extruded shape mesh
  51265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51266. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51268. */
  51269. static ExtrudeShapeCustom(name: string, options: {
  51270. shape: Vector3[];
  51271. path: Vector3[];
  51272. scaleFunction?: any;
  51273. rotationFunction?: any;
  51274. ribbonCloseArray?: boolean;
  51275. ribbonClosePath?: boolean;
  51276. cap?: number;
  51277. updatable?: boolean;
  51278. sideOrientation?: number;
  51279. frontUVs?: Vector4;
  51280. backUVs?: Vector4;
  51281. instance?: Mesh;
  51282. invertUV?: boolean;
  51283. }, scene?: Nullable<Scene>): Mesh;
  51284. private static _ExtrudeShapeGeneric;
  51285. }
  51286. }
  51287. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51288. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51289. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51290. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51291. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51292. import { Nullable } from "babylonjs/types";
  51293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51294. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51295. /**
  51296. * AmmoJS Physics plugin
  51297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51298. * @see https://github.com/kripken/ammo.js/
  51299. */
  51300. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51301. private _useDeltaForWorldStep;
  51302. /**
  51303. * Reference to the Ammo library
  51304. */
  51305. bjsAMMO: any;
  51306. /**
  51307. * Created ammoJS world which physics bodies are added to
  51308. */
  51309. world: any;
  51310. /**
  51311. * Name of the plugin
  51312. */
  51313. name: string;
  51314. private _timeStep;
  51315. private _fixedTimeStep;
  51316. private _maxSteps;
  51317. private _tmpQuaternion;
  51318. private _tmpAmmoTransform;
  51319. private _tmpAmmoQuaternion;
  51320. private _tmpAmmoConcreteContactResultCallback;
  51321. private _collisionConfiguration;
  51322. private _dispatcher;
  51323. private _overlappingPairCache;
  51324. private _solver;
  51325. private _softBodySolver;
  51326. private _tmpAmmoVectorA;
  51327. private _tmpAmmoVectorB;
  51328. private _tmpAmmoVectorC;
  51329. private _tmpAmmoVectorD;
  51330. private _tmpContactCallbackResult;
  51331. private _tmpAmmoVectorRCA;
  51332. private _tmpAmmoVectorRCB;
  51333. private _raycastResult;
  51334. private static readonly DISABLE_COLLISION_FLAG;
  51335. private static readonly KINEMATIC_FLAG;
  51336. private static readonly DISABLE_DEACTIVATION_FLAG;
  51337. /**
  51338. * Initializes the ammoJS plugin
  51339. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51340. * @param ammoInjection can be used to inject your own ammo reference
  51341. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51342. */
  51343. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51344. /**
  51345. * Sets the gravity of the physics world (m/(s^2))
  51346. * @param gravity Gravity to set
  51347. */
  51348. setGravity(gravity: Vector3): void;
  51349. /**
  51350. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51351. * @param timeStep timestep to use in seconds
  51352. */
  51353. setTimeStep(timeStep: number): void;
  51354. /**
  51355. * 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)
  51356. * @param fixedTimeStep fixedTimeStep to use in seconds
  51357. */
  51358. setFixedTimeStep(fixedTimeStep: number): void;
  51359. /**
  51360. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51361. * @param maxSteps the maximum number of steps by the physics engine per frame
  51362. */
  51363. setMaxSteps(maxSteps: number): void;
  51364. /**
  51365. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51366. * @returns the current timestep in seconds
  51367. */
  51368. getTimeStep(): number;
  51369. private _isImpostorInContact;
  51370. private _isImpostorPairInContact;
  51371. private _stepSimulation;
  51372. /**
  51373. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51374. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51375. * After the step the babylon meshes are set to the position of the physics imposters
  51376. * @param delta amount of time to step forward
  51377. * @param impostors array of imposters to update before/after the step
  51378. */
  51379. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51380. /**
  51381. * Update babylon mesh to match physics world object
  51382. * @param impostor imposter to match
  51383. */
  51384. private _afterSoftStep;
  51385. /**
  51386. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51387. * @param impostor imposter to match
  51388. */
  51389. private _ropeStep;
  51390. /**
  51391. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51392. * @param impostor imposter to match
  51393. */
  51394. private _softbodyOrClothStep;
  51395. private _tmpVector;
  51396. private _tmpMatrix;
  51397. /**
  51398. * Applies an impulse on the imposter
  51399. * @param impostor imposter to apply impulse to
  51400. * @param force amount of force to be applied to the imposter
  51401. * @param contactPoint the location to apply the impulse on the imposter
  51402. */
  51403. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51404. /**
  51405. * Applies a force on the imposter
  51406. * @param impostor imposter to apply force
  51407. * @param force amount of force to be applied to the imposter
  51408. * @param contactPoint the location to apply the force on the imposter
  51409. */
  51410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51411. /**
  51412. * Creates a physics body using the plugin
  51413. * @param impostor the imposter to create the physics body on
  51414. */
  51415. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51416. /**
  51417. * Removes the physics body from the imposter and disposes of the body's memory
  51418. * @param impostor imposter to remove the physics body from
  51419. */
  51420. removePhysicsBody(impostor: PhysicsImpostor): void;
  51421. /**
  51422. * Generates a joint
  51423. * @param impostorJoint the imposter joint to create the joint with
  51424. */
  51425. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51426. /**
  51427. * Removes a joint
  51428. * @param impostorJoint the imposter joint to remove the joint from
  51429. */
  51430. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51431. private _addMeshVerts;
  51432. /**
  51433. * Initialise the soft body vertices to match its object's (mesh) vertices
  51434. * Softbody vertices (nodes) are in world space and to match this
  51435. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51436. * @param impostor to create the softbody for
  51437. */
  51438. private _softVertexData;
  51439. /**
  51440. * Create an impostor's soft body
  51441. * @param impostor to create the softbody for
  51442. */
  51443. private _createSoftbody;
  51444. /**
  51445. * Create cloth for an impostor
  51446. * @param impostor to create the softbody for
  51447. */
  51448. private _createCloth;
  51449. /**
  51450. * Create rope for an impostor
  51451. * @param impostor to create the softbody for
  51452. */
  51453. private _createRope;
  51454. private _addHullVerts;
  51455. private _createShape;
  51456. /**
  51457. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51458. * @param impostor imposter containing the physics body and babylon object
  51459. */
  51460. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51461. /**
  51462. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51463. * @param impostor imposter containing the physics body and babylon object
  51464. * @param newPosition new position
  51465. * @param newRotation new rotation
  51466. */
  51467. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51468. /**
  51469. * If this plugin is supported
  51470. * @returns true if its supported
  51471. */
  51472. isSupported(): boolean;
  51473. /**
  51474. * Sets the linear velocity of the physics body
  51475. * @param impostor imposter to set the velocity on
  51476. * @param velocity velocity to set
  51477. */
  51478. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51479. /**
  51480. * Sets the angular velocity of the physics body
  51481. * @param impostor imposter to set the velocity on
  51482. * @param velocity velocity to set
  51483. */
  51484. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51485. /**
  51486. * gets the linear velocity
  51487. * @param impostor imposter to get linear velocity from
  51488. * @returns linear velocity
  51489. */
  51490. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51491. /**
  51492. * gets the angular velocity
  51493. * @param impostor imposter to get angular velocity from
  51494. * @returns angular velocity
  51495. */
  51496. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51497. /**
  51498. * Sets the mass of physics body
  51499. * @param impostor imposter to set the mass on
  51500. * @param mass mass to set
  51501. */
  51502. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51503. /**
  51504. * Gets the mass of the physics body
  51505. * @param impostor imposter to get the mass from
  51506. * @returns mass
  51507. */
  51508. getBodyMass(impostor: PhysicsImpostor): number;
  51509. /**
  51510. * Gets friction of the impostor
  51511. * @param impostor impostor to get friction from
  51512. * @returns friction value
  51513. */
  51514. getBodyFriction(impostor: PhysicsImpostor): number;
  51515. /**
  51516. * Sets friction of the impostor
  51517. * @param impostor impostor to set friction on
  51518. * @param friction friction value
  51519. */
  51520. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51521. /**
  51522. * Gets restitution of the impostor
  51523. * @param impostor impostor to get restitution from
  51524. * @returns restitution value
  51525. */
  51526. getBodyRestitution(impostor: PhysicsImpostor): number;
  51527. /**
  51528. * Sets resitution of the impostor
  51529. * @param impostor impostor to set resitution on
  51530. * @param restitution resitution value
  51531. */
  51532. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51533. /**
  51534. * Gets pressure inside the impostor
  51535. * @param impostor impostor to get pressure from
  51536. * @returns pressure value
  51537. */
  51538. getBodyPressure(impostor: PhysicsImpostor): number;
  51539. /**
  51540. * Sets pressure inside a soft body impostor
  51541. * Cloth and rope must remain 0 pressure
  51542. * @param impostor impostor to set pressure on
  51543. * @param pressure pressure value
  51544. */
  51545. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51546. /**
  51547. * Gets stiffness of the impostor
  51548. * @param impostor impostor to get stiffness from
  51549. * @returns pressure value
  51550. */
  51551. getBodyStiffness(impostor: PhysicsImpostor): number;
  51552. /**
  51553. * Sets stiffness of the impostor
  51554. * @param impostor impostor to set stiffness on
  51555. * @param stiffness stiffness value from 0 to 1
  51556. */
  51557. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51558. /**
  51559. * Gets velocityIterations of the impostor
  51560. * @param impostor impostor to get velocity iterations from
  51561. * @returns velocityIterations value
  51562. */
  51563. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51564. /**
  51565. * Sets velocityIterations of the impostor
  51566. * @param impostor impostor to set velocity iterations on
  51567. * @param velocityIterations velocityIterations value
  51568. */
  51569. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51570. /**
  51571. * Gets positionIterations of the impostor
  51572. * @param impostor impostor to get position iterations from
  51573. * @returns positionIterations value
  51574. */
  51575. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51576. /**
  51577. * Sets positionIterations of the impostor
  51578. * @param impostor impostor to set position on
  51579. * @param positionIterations positionIterations value
  51580. */
  51581. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51582. /**
  51583. * Append an anchor to a cloth object
  51584. * @param impostor is the cloth impostor to add anchor to
  51585. * @param otherImpostor is the rigid impostor to anchor to
  51586. * @param width ratio across width from 0 to 1
  51587. * @param height ratio up height from 0 to 1
  51588. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51589. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51590. */
  51591. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51592. /**
  51593. * Append an hook to a rope object
  51594. * @param impostor is the rope impostor to add hook to
  51595. * @param otherImpostor is the rigid impostor to hook to
  51596. * @param length ratio along the rope from 0 to 1
  51597. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51598. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51599. */
  51600. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51601. /**
  51602. * Sleeps the physics body and stops it from being active
  51603. * @param impostor impostor to sleep
  51604. */
  51605. sleepBody(impostor: PhysicsImpostor): void;
  51606. /**
  51607. * Activates the physics body
  51608. * @param impostor impostor to activate
  51609. */
  51610. wakeUpBody(impostor: PhysicsImpostor): void;
  51611. /**
  51612. * Updates the distance parameters of the joint
  51613. * @param joint joint to update
  51614. * @param maxDistance maximum distance of the joint
  51615. * @param minDistance minimum distance of the joint
  51616. */
  51617. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51618. /**
  51619. * Sets a motor on the joint
  51620. * @param joint joint to set motor on
  51621. * @param speed speed of the motor
  51622. * @param maxForce maximum force of the motor
  51623. * @param motorIndex index of the motor
  51624. */
  51625. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51626. /**
  51627. * Sets the motors limit
  51628. * @param joint joint to set limit on
  51629. * @param upperLimit upper limit
  51630. * @param lowerLimit lower limit
  51631. */
  51632. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51633. /**
  51634. * Syncs the position and rotation of a mesh with the impostor
  51635. * @param mesh mesh to sync
  51636. * @param impostor impostor to update the mesh with
  51637. */
  51638. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51639. /**
  51640. * Gets the radius of the impostor
  51641. * @param impostor impostor to get radius from
  51642. * @returns the radius
  51643. */
  51644. getRadius(impostor: PhysicsImpostor): number;
  51645. /**
  51646. * Gets the box size of the impostor
  51647. * @param impostor impostor to get box size from
  51648. * @param result the resulting box size
  51649. */
  51650. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51651. /**
  51652. * Disposes of the impostor
  51653. */
  51654. dispose(): void;
  51655. /**
  51656. * Does a raycast in the physics world
  51657. * @param from when should the ray start?
  51658. * @param to when should the ray end?
  51659. * @returns PhysicsRaycastResult
  51660. */
  51661. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51662. }
  51663. }
  51664. declare module "babylonjs/Probes/reflectionProbe" {
  51665. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51666. import { Vector3 } from "babylonjs/Maths/math";
  51667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51668. import { Nullable } from "babylonjs/types";
  51669. import { Scene } from "babylonjs/scene";
  51670. module "babylonjs/abstractScene" {
  51671. interface AbstractScene {
  51672. /**
  51673. * The list of reflection probes added to the scene
  51674. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51675. */
  51676. reflectionProbes: Array<ReflectionProbe>;
  51677. /**
  51678. * Removes the given reflection probe from this scene.
  51679. * @param toRemove The reflection probe to remove
  51680. * @returns The index of the removed reflection probe
  51681. */
  51682. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51683. /**
  51684. * Adds the given reflection probe to this scene.
  51685. * @param newReflectionProbe The reflection probe to add
  51686. */
  51687. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51688. }
  51689. }
  51690. /**
  51691. * Class used to generate realtime reflection / refraction cube textures
  51692. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51693. */
  51694. export class ReflectionProbe {
  51695. /** defines the name of the probe */
  51696. name: string;
  51697. private _scene;
  51698. private _renderTargetTexture;
  51699. private _projectionMatrix;
  51700. private _viewMatrix;
  51701. private _target;
  51702. private _add;
  51703. private _attachedMesh;
  51704. private _invertYAxis;
  51705. /** Gets or sets probe position (center of the cube map) */
  51706. position: Vector3;
  51707. /**
  51708. * Creates a new reflection probe
  51709. * @param name defines the name of the probe
  51710. * @param size defines the texture resolution (for each face)
  51711. * @param scene defines the hosting scene
  51712. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51713. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51714. */
  51715. constructor(
  51716. /** defines the name of the probe */
  51717. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51718. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51719. samples: number;
  51720. /** Gets or sets the refresh rate to use (on every frame by default) */
  51721. refreshRate: number;
  51722. /**
  51723. * Gets the hosting scene
  51724. * @returns a Scene
  51725. */
  51726. getScene(): Scene;
  51727. /** Gets the internal CubeTexture used to render to */
  51728. readonly cubeTexture: RenderTargetTexture;
  51729. /** Gets the list of meshes to render */
  51730. readonly renderList: Nullable<AbstractMesh[]>;
  51731. /**
  51732. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51733. * @param mesh defines the mesh to attach to
  51734. */
  51735. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51736. /**
  51737. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51738. * @param renderingGroupId The rendering group id corresponding to its index
  51739. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51740. */
  51741. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51742. /**
  51743. * Clean all associated resources
  51744. */
  51745. dispose(): void;
  51746. /**
  51747. * Converts the reflection probe information to a readable string for debug purpose.
  51748. * @param fullDetails Supports for multiple levels of logging within scene loading
  51749. * @returns the human readable reflection probe info
  51750. */
  51751. toString(fullDetails?: boolean): string;
  51752. /**
  51753. * Get the class name of the relfection probe.
  51754. * @returns "ReflectionProbe"
  51755. */
  51756. getClassName(): string;
  51757. /**
  51758. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51759. * @returns The JSON representation of the texture
  51760. */
  51761. serialize(): any;
  51762. /**
  51763. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51764. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51765. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51766. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51767. * @returns The parsed reflection probe if successful
  51768. */
  51769. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51770. }
  51771. }
  51772. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51773. /** @hidden */
  51774. export var _BabylonLoaderRegistered: boolean;
  51775. }
  51776. declare module "babylonjs/Loading/Plugins/index" {
  51777. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51778. }
  51779. declare module "babylonjs/Loading/index" {
  51780. export * from "babylonjs/Loading/loadingScreen";
  51781. export * from "babylonjs/Loading/Plugins/index";
  51782. export * from "babylonjs/Loading/sceneLoader";
  51783. export * from "babylonjs/Loading/sceneLoaderFlags";
  51784. }
  51785. declare module "babylonjs/Materials/Background/index" {
  51786. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51787. }
  51788. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51789. import { Scene } from "babylonjs/scene";
  51790. import { Color3 } from "babylonjs/Maths/math";
  51791. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51792. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51793. /**
  51794. * The Physically based simple base material of BJS.
  51795. *
  51796. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51797. * It is used as the base class for both the specGloss and metalRough conventions.
  51798. */
  51799. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51800. /**
  51801. * Number of Simultaneous lights allowed on the material.
  51802. */
  51803. maxSimultaneousLights: number;
  51804. /**
  51805. * If sets to true, disables all the lights affecting the material.
  51806. */
  51807. disableLighting: boolean;
  51808. /**
  51809. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51810. */
  51811. environmentTexture: BaseTexture;
  51812. /**
  51813. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51814. */
  51815. invertNormalMapX: boolean;
  51816. /**
  51817. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51818. */
  51819. invertNormalMapY: boolean;
  51820. /**
  51821. * Normal map used in the model.
  51822. */
  51823. normalTexture: BaseTexture;
  51824. /**
  51825. * Emissivie color used to self-illuminate the model.
  51826. */
  51827. emissiveColor: Color3;
  51828. /**
  51829. * Emissivie texture used to self-illuminate the model.
  51830. */
  51831. emissiveTexture: BaseTexture;
  51832. /**
  51833. * Occlusion Channel Strenght.
  51834. */
  51835. occlusionStrength: number;
  51836. /**
  51837. * Occlusion Texture of the material (adding extra occlusion effects).
  51838. */
  51839. occlusionTexture: BaseTexture;
  51840. /**
  51841. * Defines the alpha limits in alpha test mode.
  51842. */
  51843. alphaCutOff: number;
  51844. /**
  51845. * Gets the current double sided mode.
  51846. */
  51847. /**
  51848. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51849. */
  51850. doubleSided: boolean;
  51851. /**
  51852. * Stores the pre-calculated light information of a mesh in a texture.
  51853. */
  51854. lightmapTexture: BaseTexture;
  51855. /**
  51856. * If true, the light map contains occlusion information instead of lighting info.
  51857. */
  51858. useLightmapAsShadowmap: boolean;
  51859. /**
  51860. * Instantiates a new PBRMaterial instance.
  51861. *
  51862. * @param name The material name
  51863. * @param scene The scene the material will be use in.
  51864. */
  51865. constructor(name: string, scene: Scene);
  51866. getClassName(): string;
  51867. }
  51868. }
  51869. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51870. import { Scene } from "babylonjs/scene";
  51871. import { Color3 } from "babylonjs/Maths/math";
  51872. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51873. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51874. /**
  51875. * The PBR material of BJS following the metal roughness convention.
  51876. *
  51877. * This fits to the PBR convention in the GLTF definition:
  51878. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51879. */
  51880. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51881. /**
  51882. * The base color has two different interpretations depending on the value of metalness.
  51883. * When the material is a metal, the base color is the specific measured reflectance value
  51884. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51885. * of the material.
  51886. */
  51887. baseColor: Color3;
  51888. /**
  51889. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51890. * well as opacity information in the alpha channel.
  51891. */
  51892. baseTexture: BaseTexture;
  51893. /**
  51894. * Specifies the metallic scalar value of the material.
  51895. * Can also be used to scale the metalness values of the metallic texture.
  51896. */
  51897. metallic: number;
  51898. /**
  51899. * Specifies the roughness scalar value of the material.
  51900. * Can also be used to scale the roughness values of the metallic texture.
  51901. */
  51902. roughness: number;
  51903. /**
  51904. * Texture containing both the metallic value in the B channel and the
  51905. * roughness value in the G channel to keep better precision.
  51906. */
  51907. metallicRoughnessTexture: BaseTexture;
  51908. /**
  51909. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51910. *
  51911. * @param name The material name
  51912. * @param scene The scene the material will be use in.
  51913. */
  51914. constructor(name: string, scene: Scene);
  51915. /**
  51916. * Return the currrent class name of the material.
  51917. */
  51918. getClassName(): string;
  51919. /**
  51920. * Makes a duplicate of the current material.
  51921. * @param name - name to use for the new material.
  51922. */
  51923. clone(name: string): PBRMetallicRoughnessMaterial;
  51924. /**
  51925. * Serialize the material to a parsable JSON object.
  51926. */
  51927. serialize(): any;
  51928. /**
  51929. * Parses a JSON object correponding to the serialize function.
  51930. */
  51931. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51932. }
  51933. }
  51934. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51935. import { Scene } from "babylonjs/scene";
  51936. import { Color3 } from "babylonjs/Maths/math";
  51937. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51938. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51939. /**
  51940. * The PBR material of BJS following the specular glossiness convention.
  51941. *
  51942. * This fits to the PBR convention in the GLTF definition:
  51943. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51944. */
  51945. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51946. /**
  51947. * Specifies the diffuse color of the material.
  51948. */
  51949. diffuseColor: Color3;
  51950. /**
  51951. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51952. * channel.
  51953. */
  51954. diffuseTexture: BaseTexture;
  51955. /**
  51956. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51957. */
  51958. specularColor: Color3;
  51959. /**
  51960. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51961. */
  51962. glossiness: number;
  51963. /**
  51964. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51965. */
  51966. specularGlossinessTexture: BaseTexture;
  51967. /**
  51968. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51969. *
  51970. * @param name The material name
  51971. * @param scene The scene the material will be use in.
  51972. */
  51973. constructor(name: string, scene: Scene);
  51974. /**
  51975. * Return the currrent class name of the material.
  51976. */
  51977. getClassName(): string;
  51978. /**
  51979. * Makes a duplicate of the current material.
  51980. * @param name - name to use for the new material.
  51981. */
  51982. clone(name: string): PBRSpecularGlossinessMaterial;
  51983. /**
  51984. * Serialize the material to a parsable JSON object.
  51985. */
  51986. serialize(): any;
  51987. /**
  51988. * Parses a JSON object correponding to the serialize function.
  51989. */
  51990. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51991. }
  51992. }
  51993. declare module "babylonjs/Materials/PBR/index" {
  51994. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51995. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51996. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51997. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51998. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51999. }
  52000. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52001. import { Nullable } from "babylonjs/types";
  52002. import { Scene } from "babylonjs/scene";
  52003. import { Matrix } from "babylonjs/Maths/math";
  52004. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52005. /**
  52006. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52007. * It can help converting any input color in a desired output one. This can then be used to create effects
  52008. * from sepia, black and white to sixties or futuristic rendering...
  52009. *
  52010. * The only supported format is currently 3dl.
  52011. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52012. */
  52013. export class ColorGradingTexture extends BaseTexture {
  52014. /**
  52015. * The current texture matrix. (will always be identity in color grading texture)
  52016. */
  52017. private _textureMatrix;
  52018. /**
  52019. * The texture URL.
  52020. */
  52021. url: string;
  52022. /**
  52023. * Empty line regex stored for GC.
  52024. */
  52025. private static _noneEmptyLineRegex;
  52026. private _engine;
  52027. /**
  52028. * Instantiates a ColorGradingTexture from the following parameters.
  52029. *
  52030. * @param url The location of the color gradind data (currently only supporting 3dl)
  52031. * @param scene The scene the texture will be used in
  52032. */
  52033. constructor(url: string, scene: Scene);
  52034. /**
  52035. * Returns the texture matrix used in most of the material.
  52036. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52037. */
  52038. getTextureMatrix(): Matrix;
  52039. /**
  52040. * Occurs when the file being loaded is a .3dl LUT file.
  52041. */
  52042. private load3dlTexture;
  52043. /**
  52044. * Starts the loading process of the texture.
  52045. */
  52046. private loadTexture;
  52047. /**
  52048. * Clones the color gradind texture.
  52049. */
  52050. clone(): ColorGradingTexture;
  52051. /**
  52052. * Called during delayed load for textures.
  52053. */
  52054. delayLoad(): void;
  52055. /**
  52056. * Parses a color grading texture serialized by Babylon.
  52057. * @param parsedTexture The texture information being parsedTexture
  52058. * @param scene The scene to load the texture in
  52059. * @param rootUrl The root url of the data assets to load
  52060. * @return A color gradind texture
  52061. */
  52062. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52063. /**
  52064. * Serializes the LUT texture to json format.
  52065. */
  52066. serialize(): any;
  52067. }
  52068. }
  52069. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52071. import { Scene } from "babylonjs/scene";
  52072. import { Nullable } from "babylonjs/types";
  52073. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52074. /**
  52075. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52076. */
  52077. export class EquiRectangularCubeTexture extends BaseTexture {
  52078. /** The six faces of the cube. */
  52079. private static _FacesMapping;
  52080. private _noMipmap;
  52081. private _onLoad;
  52082. private _onError;
  52083. /** The size of the cubemap. */
  52084. private _size;
  52085. /** The buffer of the image. */
  52086. private _buffer;
  52087. /** The width of the input image. */
  52088. private _width;
  52089. /** The height of the input image. */
  52090. private _height;
  52091. /** The URL to the image. */
  52092. url: string;
  52093. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52094. coordinatesMode: number;
  52095. /**
  52096. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52097. * @param url The location of the image
  52098. * @param scene The scene the texture will be used in
  52099. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52100. * @param noMipmap Forces to not generate the mipmap if true
  52101. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52102. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52103. * @param onLoad — defines a callback called when texture is loaded
  52104. * @param onError — defines a callback called if there is an error
  52105. */
  52106. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52107. /**
  52108. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52109. */
  52110. private loadImage;
  52111. /**
  52112. * Convert the image buffer into a cubemap and create a CubeTexture.
  52113. */
  52114. private loadTexture;
  52115. /**
  52116. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52117. * @param buffer The ArrayBuffer that should be converted.
  52118. * @returns The buffer as Float32Array.
  52119. */
  52120. private getFloat32ArrayFromArrayBuffer;
  52121. /**
  52122. * Get the current class name of the texture useful for serialization or dynamic coding.
  52123. * @returns "EquiRectangularCubeTexture"
  52124. */
  52125. getClassName(): string;
  52126. /**
  52127. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52128. * @returns A clone of the current EquiRectangularCubeTexture.
  52129. */
  52130. clone(): EquiRectangularCubeTexture;
  52131. }
  52132. }
  52133. declare module "babylonjs/Misc/tga" {
  52134. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52135. /**
  52136. * Based on jsTGALoader - Javascript loader for TGA file
  52137. * By Vincent Thibault
  52138. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52139. */
  52140. export class TGATools {
  52141. private static _TYPE_INDEXED;
  52142. private static _TYPE_RGB;
  52143. private static _TYPE_GREY;
  52144. private static _TYPE_RLE_INDEXED;
  52145. private static _TYPE_RLE_RGB;
  52146. private static _TYPE_RLE_GREY;
  52147. private static _ORIGIN_MASK;
  52148. private static _ORIGIN_SHIFT;
  52149. private static _ORIGIN_BL;
  52150. private static _ORIGIN_BR;
  52151. private static _ORIGIN_UL;
  52152. private static _ORIGIN_UR;
  52153. /**
  52154. * Gets the header of a TGA file
  52155. * @param data defines the TGA data
  52156. * @returns the header
  52157. */
  52158. static GetTGAHeader(data: Uint8Array): any;
  52159. /**
  52160. * Uploads TGA content to a Babylon Texture
  52161. * @hidden
  52162. */
  52163. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52164. /** @hidden */
  52165. 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;
  52166. /** @hidden */
  52167. 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;
  52168. /** @hidden */
  52169. 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;
  52170. /** @hidden */
  52171. 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;
  52172. /** @hidden */
  52173. 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;
  52174. /** @hidden */
  52175. 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;
  52176. }
  52177. }
  52178. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52179. import { Nullable } from "babylonjs/types";
  52180. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52181. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52182. /**
  52183. * Implementation of the TGA Texture Loader.
  52184. * @hidden
  52185. */
  52186. export class _TGATextureLoader implements IInternalTextureLoader {
  52187. /**
  52188. * Defines wether the loader supports cascade loading the different faces.
  52189. */
  52190. readonly supportCascades: boolean;
  52191. /**
  52192. * This returns if the loader support the current file information.
  52193. * @param extension defines the file extension of the file being loaded
  52194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52195. * @param fallback defines the fallback internal texture if any
  52196. * @param isBase64 defines whether the texture is encoded as a base64
  52197. * @param isBuffer defines whether the texture data are stored as a buffer
  52198. * @returns true if the loader can load the specified file
  52199. */
  52200. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52201. /**
  52202. * Transform the url before loading if required.
  52203. * @param rootUrl the url of the texture
  52204. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52205. * @returns the transformed texture
  52206. */
  52207. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52208. /**
  52209. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52210. * @param rootUrl the url of the texture
  52211. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52212. * @returns the fallback texture
  52213. */
  52214. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52215. /**
  52216. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52217. * @param data contains the texture data
  52218. * @param texture defines the BabylonJS internal texture
  52219. * @param createPolynomials will be true if polynomials have been requested
  52220. * @param onLoad defines the callback to trigger once the texture is ready
  52221. * @param onError defines the callback to trigger in case of error
  52222. */
  52223. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52224. /**
  52225. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52226. * @param data contains the texture data
  52227. * @param texture defines the BabylonJS internal texture
  52228. * @param callback defines the method to call once ready to upload
  52229. */
  52230. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52231. }
  52232. }
  52233. declare module "babylonjs/Misc/basis" {
  52234. import { Nullable } from "babylonjs/types";
  52235. import { Engine } from "babylonjs/Engines/engine";
  52236. /**
  52237. * Info about the .basis files
  52238. */
  52239. class BasisFileInfo {
  52240. /**
  52241. * If the file has alpha
  52242. */
  52243. hasAlpha: boolean;
  52244. /**
  52245. * Width of the image
  52246. */
  52247. width: number;
  52248. /**
  52249. * Height of the image
  52250. */
  52251. height: number;
  52252. /**
  52253. * Aligned width used when falling back to Rgb565 ((width + 3) & ~3)
  52254. */
  52255. alignedWidth: number;
  52256. /**
  52257. * Aligned height used when falling back to Rgb565 ((height + 3) & ~3)
  52258. */
  52259. alignedHeight: number;
  52260. }
  52261. /**
  52262. * Used to load .Basis files
  52263. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52264. */
  52265. export class BasisTools {
  52266. private static _IgnoreSupportedFormats;
  52267. private static _LoadScriptPromise;
  52268. private static _FallbackURL;
  52269. private static _BASIS_FORMAT;
  52270. /**
  52271. * Basis module can be aquired from https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52272. * This should be set prior to loading a .basis texture
  52273. */
  52274. static BasisModule: Nullable<any>;
  52275. /**
  52276. * Verifies that the BasisModule has been populated and falls back to loading from the web if not availible
  52277. * @returns promise which will resolve if the basis module was loaded
  52278. */
  52279. static VerifyBasisModuleAsync(): any;
  52280. /**
  52281. * Verifies that the basis module has been populated and creates a bsis file from the image data
  52282. * @param data array buffer of the .basis file
  52283. * @returns the Basis file
  52284. */
  52285. static LoadBasisFile(data: ArrayBuffer): any;
  52286. /**
  52287. * Detects the supported transcode format for the file
  52288. * @param engine Babylon engine
  52289. * @param fileInfo info about the file
  52290. * @returns the chosed format or null if none are supported
  52291. */
  52292. static GetSupportedTranscodeFormat(engine: Engine, fileInfo: BasisFileInfo): Nullable<number>;
  52293. /**
  52294. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52295. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52296. * @returns internal format corresponding to the Basis format
  52297. */
  52298. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52299. /**
  52300. * Retreives information about the basis file eg. dimensions
  52301. * @param basisFile the basis file to get the info from
  52302. * @returns information about the basis file
  52303. */
  52304. static GetFileInfo(basisFile: any): BasisFileInfo;
  52305. /**
  52306. * Transcodes the basis file to the requested format to be transferred to the gpu
  52307. * @param format fromat to be transferred to
  52308. * @param fileInfo information about the loaded file
  52309. * @param loadedFile the loaded basis file
  52310. * @returns the resulting pixels and if the transcode fell back to using Rgb565
  52311. */
  52312. static TranscodeFile(format: Nullable<number>, fileInfo: BasisFileInfo, loadedFile: any): {
  52313. fallbackToRgb565: boolean;
  52314. pixels: Uint8Array;
  52315. };
  52316. /**
  52317. * From https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture/dxt-to-rgb565.js
  52318. * An unoptimized version of dxtToRgb565. Also, the floating
  52319. * point math used to compute the colors actually results in
  52320. * slightly different colors compared to hardware DXT decoders.
  52321. * @param src dxt src pixels
  52322. * @param srcByteOffset offset for the start of src
  52323. * @param width aligned width of the image
  52324. * @param height aligned height of the image
  52325. * @return the converted pixels
  52326. */
  52327. static ConvertDxtToRgb565(src: Uint16Array, srcByteOffset: number, width: number, height: number): Uint16Array;
  52328. }
  52329. }
  52330. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52331. import { Nullable } from "babylonjs/types";
  52332. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52333. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52334. /**
  52335. * Loader for .basis file format
  52336. */
  52337. export class _BasisTextureLoader implements IInternalTextureLoader {
  52338. /**
  52339. * Defines whether the loader supports cascade loading the different faces.
  52340. */
  52341. readonly supportCascades: boolean;
  52342. /**
  52343. * This returns if the loader support the current file information.
  52344. * @param extension defines the file extension of the file being loaded
  52345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52346. * @param fallback defines the fallback internal texture if any
  52347. * @param isBase64 defines whether the texture is encoded as a base64
  52348. * @param isBuffer defines whether the texture data are stored as a buffer
  52349. * @returns true if the loader can load the specified file
  52350. */
  52351. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52352. /**
  52353. * Transform the url before loading if required.
  52354. * @param rootUrl the url of the texture
  52355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52356. * @returns the transformed texture
  52357. */
  52358. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52359. /**
  52360. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52361. * @param rootUrl the url of the texture
  52362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52363. * @returns the fallback texture
  52364. */
  52365. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52366. /**
  52367. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52368. * @param data contains the texture data
  52369. * @param texture defines the BabylonJS internal texture
  52370. * @param createPolynomials will be true if polynomials have been requested
  52371. * @param onLoad defines the callback to trigger once the texture is ready
  52372. * @param onError defines the callback to trigger in case of error
  52373. */
  52374. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52375. /**
  52376. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52377. * @param data contains the texture data
  52378. * @param texture defines the BabylonJS internal texture
  52379. * @param callback defines the method to call once ready to upload
  52380. */
  52381. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52382. }
  52383. }
  52384. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52385. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52386. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52387. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52388. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52389. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52390. }
  52391. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52392. import { Scene } from "babylonjs/scene";
  52393. import { Texture } from "babylonjs/Materials/Textures/texture";
  52394. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52395. /**
  52396. * 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.
  52397. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52398. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52399. */
  52400. export class CustomProceduralTexture extends ProceduralTexture {
  52401. private _animate;
  52402. private _time;
  52403. private _config;
  52404. private _texturePath;
  52405. /**
  52406. * Instantiates a new Custom Procedural Texture.
  52407. * 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.
  52408. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52409. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52410. * @param name Define the name of the texture
  52411. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52412. * @param size Define the size of the texture to create
  52413. * @param scene Define the scene the texture belongs to
  52414. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52415. * @param generateMipMaps Define if the texture should creates mip maps or not
  52416. */
  52417. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52418. private _loadJson;
  52419. /**
  52420. * Is the texture ready to be used ? (rendered at least once)
  52421. * @returns true if ready, otherwise, false.
  52422. */
  52423. isReady(): boolean;
  52424. /**
  52425. * Render the texture to its associated render target.
  52426. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52427. */
  52428. render(useCameraPostProcess?: boolean): void;
  52429. /**
  52430. * Update the list of dependant textures samplers in the shader.
  52431. */
  52432. updateTextures(): void;
  52433. /**
  52434. * Update the uniform values of the procedural texture in the shader.
  52435. */
  52436. updateShaderUniforms(): void;
  52437. /**
  52438. * Define if the texture animates or not.
  52439. */
  52440. animate: boolean;
  52441. }
  52442. }
  52443. declare module "babylonjs/Shaders/noise.fragment" {
  52444. /** @hidden */
  52445. export var noisePixelShader: {
  52446. name: string;
  52447. shader: string;
  52448. };
  52449. }
  52450. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52451. import { Nullable } from "babylonjs/types";
  52452. import { Scene } from "babylonjs/scene";
  52453. import { Texture } from "babylonjs/Materials/Textures/texture";
  52454. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52455. import "babylonjs/Shaders/noise.fragment";
  52456. /**
  52457. * Class used to generate noise procedural textures
  52458. */
  52459. export class NoiseProceduralTexture extends ProceduralTexture {
  52460. private _time;
  52461. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52462. brightness: number;
  52463. /** Defines the number of octaves to process */
  52464. octaves: number;
  52465. /** Defines the level of persistence (0.8 by default) */
  52466. persistence: number;
  52467. /** Gets or sets animation speed factor (default is 1) */
  52468. animationSpeedFactor: number;
  52469. /**
  52470. * Creates a new NoiseProceduralTexture
  52471. * @param name defines the name fo the texture
  52472. * @param size defines the size of the texture (default is 256)
  52473. * @param scene defines the hosting scene
  52474. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52475. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52476. */
  52477. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52478. private _updateShaderUniforms;
  52479. protected _getDefines(): string;
  52480. /** Generate the current state of the procedural texture */
  52481. render(useCameraPostProcess?: boolean): void;
  52482. /**
  52483. * Serializes this noise procedural texture
  52484. * @returns a serialized noise procedural texture object
  52485. */
  52486. serialize(): any;
  52487. /**
  52488. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52489. * @param parsedTexture defines parsed texture data
  52490. * @param scene defines the current scene
  52491. * @param rootUrl defines the root URL containing noise procedural texture information
  52492. * @returns a parsed NoiseProceduralTexture
  52493. */
  52494. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52495. }
  52496. }
  52497. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52498. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52499. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52500. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52501. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52502. }
  52503. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52504. import { Nullable } from "babylonjs/types";
  52505. import { Scene } from "babylonjs/scene";
  52506. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52507. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52508. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52509. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52510. /**
  52511. * Raw cube texture where the raw buffers are passed in
  52512. */
  52513. export class RawCubeTexture extends CubeTexture {
  52514. /**
  52515. * Creates a cube texture where the raw buffers are passed in.
  52516. * @param scene defines the scene the texture is attached to
  52517. * @param data defines the array of data to use to create each face
  52518. * @param size defines the size of the textures
  52519. * @param format defines the format of the data
  52520. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52521. * @param generateMipMaps defines if the engine should generate the mip levels
  52522. * @param invertY defines if data must be stored with Y axis inverted
  52523. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52524. * @param compression defines the compression used (null by default)
  52525. */
  52526. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52527. /**
  52528. * Updates the raw cube texture.
  52529. * @param data defines the data to store
  52530. * @param format defines the data format
  52531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52532. * @param invertY defines if data must be stored with Y axis inverted
  52533. * @param compression defines the compression used (null by default)
  52534. * @param level defines which level of the texture to update
  52535. */
  52536. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52537. /**
  52538. * Updates a raw cube texture with RGBD encoded data.
  52539. * @param data defines the array of data [mipmap][face] to use to create each face
  52540. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52541. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52542. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52543. * @returns a promsie that resolves when the operation is complete
  52544. */
  52545. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52546. /**
  52547. * Clones the raw cube texture.
  52548. * @return a new cube texture
  52549. */
  52550. clone(): CubeTexture;
  52551. /** @hidden */
  52552. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52553. }
  52554. }
  52555. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52556. import { Scene } from "babylonjs/scene";
  52557. import { Texture } from "babylonjs/Materials/Textures/texture";
  52558. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52559. /**
  52560. * Class used to store 3D textures containing user data
  52561. */
  52562. export class RawTexture3D extends Texture {
  52563. /** Gets or sets the texture format to use */
  52564. format: number;
  52565. private _engine;
  52566. /**
  52567. * Create a new RawTexture3D
  52568. * @param data defines the data of the texture
  52569. * @param width defines the width of the texture
  52570. * @param height defines the height of the texture
  52571. * @param depth defines the depth of the texture
  52572. * @param format defines the texture format to use
  52573. * @param scene defines the hosting scene
  52574. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52575. * @param invertY defines if texture must be stored with Y axis inverted
  52576. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52577. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52578. */
  52579. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52580. /** Gets or sets the texture format to use */
  52581. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52582. /**
  52583. * Update the texture with new data
  52584. * @param data defines the data to store in the texture
  52585. */
  52586. update(data: ArrayBufferView): void;
  52587. }
  52588. }
  52589. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52590. import { Scene } from "babylonjs/scene";
  52591. import { Plane } from "babylonjs/Maths/math";
  52592. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52593. /**
  52594. * Creates a refraction texture used by refraction channel of the standard material.
  52595. * It is like a mirror but to see through a material.
  52596. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52597. */
  52598. export class RefractionTexture extends RenderTargetTexture {
  52599. /**
  52600. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52601. * 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.
  52602. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52603. */
  52604. refractionPlane: Plane;
  52605. /**
  52606. * Define how deep under the surface we should see.
  52607. */
  52608. depth: number;
  52609. /**
  52610. * Creates a refraction texture used by refraction channel of the standard material.
  52611. * It is like a mirror but to see through a material.
  52612. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52613. * @param name Define the texture name
  52614. * @param size Define the size of the underlying texture
  52615. * @param scene Define the scene the refraction belongs to
  52616. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52617. */
  52618. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52619. /**
  52620. * Clone the refraction texture.
  52621. * @returns the cloned texture
  52622. */
  52623. clone(): RefractionTexture;
  52624. /**
  52625. * Serialize the texture to a JSON representation you could use in Parse later on
  52626. * @returns the serialized JSON representation
  52627. */
  52628. serialize(): any;
  52629. }
  52630. }
  52631. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52632. import { Nullable } from "babylonjs/types";
  52633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52634. import { Matrix } from "babylonjs/Maths/math";
  52635. import { Engine } from "babylonjs/Engines/engine";
  52636. import { Scene } from "babylonjs/scene";
  52637. /**
  52638. * Defines the options related to the creation of an HtmlElementTexture
  52639. */
  52640. export interface IHtmlElementTextureOptions {
  52641. /**
  52642. * Defines wether mip maps should be created or not.
  52643. */
  52644. generateMipMaps?: boolean;
  52645. /**
  52646. * Defines the sampling mode of the texture.
  52647. */
  52648. samplingMode?: number;
  52649. /**
  52650. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52651. */
  52652. engine: Nullable<Engine>;
  52653. /**
  52654. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52655. */
  52656. scene: Nullable<Scene>;
  52657. }
  52658. /**
  52659. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52660. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52661. * is automatically managed.
  52662. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52663. * in your application.
  52664. *
  52665. * As the update is not automatic, you need to call them manually.
  52666. */
  52667. export class HtmlElementTexture extends BaseTexture {
  52668. /**
  52669. * The texture URL.
  52670. */
  52671. element: HTMLVideoElement | HTMLCanvasElement;
  52672. private static readonly DefaultOptions;
  52673. private _textureMatrix;
  52674. private _engine;
  52675. private _isVideo;
  52676. private _generateMipMaps;
  52677. private _samplingMode;
  52678. /**
  52679. * Instantiates a HtmlElementTexture from the following parameters.
  52680. *
  52681. * @param name Defines the name of the texture
  52682. * @param element Defines the video or canvas the texture is filled with
  52683. * @param options Defines the other none mandatory texture creation options
  52684. */
  52685. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52686. private _createInternalTexture;
  52687. /**
  52688. * Returns the texture matrix used in most of the material.
  52689. */
  52690. getTextureMatrix(): Matrix;
  52691. /**
  52692. * Updates the content of the texture.
  52693. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52694. */
  52695. update(invertY?: Nullable<boolean>): void;
  52696. }
  52697. }
  52698. declare module "babylonjs/Materials/Textures/index" {
  52699. export * from "babylonjs/Materials/Textures/baseTexture";
  52700. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52701. export * from "babylonjs/Materials/Textures/cubeTexture";
  52702. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52703. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52704. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52705. export * from "babylonjs/Materials/Textures/internalTexture";
  52706. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52707. export * from "babylonjs/Materials/Textures/Loaders/index";
  52708. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52709. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52710. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52711. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52712. export * from "babylonjs/Materials/Textures/rawTexture";
  52713. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52714. export * from "babylonjs/Materials/Textures/refractionTexture";
  52715. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52716. export * from "babylonjs/Materials/Textures/texture";
  52717. export * from "babylonjs/Materials/Textures/videoTexture";
  52718. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52719. }
  52720. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52721. /**
  52722. * Enum used to define the target of a block
  52723. */
  52724. export enum NodeMaterialBlockTargets {
  52725. /** Vertex shader */
  52726. Vertex = 1,
  52727. /** Fragment shader */
  52728. Fragment = 2,
  52729. /** Vertex and Fragment */
  52730. VertexAndFragment = 3
  52731. }
  52732. }
  52733. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52734. /**
  52735. * Defines the kind of connection point for node based material
  52736. */
  52737. export enum NodeMaterialBlockConnectionPointTypes {
  52738. /** Float */
  52739. Float = 1,
  52740. /** Int */
  52741. Int = 2,
  52742. /** Vector2 */
  52743. Vector2 = 4,
  52744. /** Vector3 */
  52745. Vector3 = 8,
  52746. /** Vector4 */
  52747. Vector4 = 16,
  52748. /** Color3 */
  52749. Color3 = 32,
  52750. /** Color4 */
  52751. Color4 = 64,
  52752. /** Matrix */
  52753. Matrix = 128,
  52754. /** Texture */
  52755. Texture = 256,
  52756. /** Texture3D */
  52757. Texture3D = 512,
  52758. /** Vector3 or Color3 */
  52759. Vector3OrColor3 = 40,
  52760. /** Vector3 or Vector4 */
  52761. Vector3OrVector4 = 24,
  52762. /** Vector4 or Color4 */
  52763. Vector4OrColor4 = 80,
  52764. /** Color3 or Color4 */
  52765. Color3OrColor4 = 96,
  52766. /** Vector3 or Color3 */
  52767. Vector3OrColor3OrVector4OrColor4 = 120
  52768. }
  52769. }
  52770. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52771. /**
  52772. * Enum used to define well known values e.g. values automatically provided by the system
  52773. */
  52774. export enum NodeMaterialWellKnownValues {
  52775. /** World */
  52776. World = 1,
  52777. /** View */
  52778. View = 2,
  52779. /** Projection */
  52780. Projection = 3,
  52781. /** ViewProjection */
  52782. ViewProjection = 4,
  52783. /** WorldView */
  52784. WorldView = 5,
  52785. /** WorldViewProjection */
  52786. WorldViewProjection = 6,
  52787. /** Will be filled by the block itself */
  52788. Automatic = 7
  52789. }
  52790. }
  52791. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  52792. /**
  52793. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52794. */
  52795. export enum NodeMaterialBlockConnectionPointMode {
  52796. /** Value is an uniform */
  52797. Uniform = 0,
  52798. /** Value is a mesh attribute */
  52799. Attribute = 1,
  52800. /** Value is a varying between vertex and fragment shaders */
  52801. Varying = 2,
  52802. /** Mode is undefined */
  52803. Undefined = 3
  52804. }
  52805. }
  52806. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  52807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52809. /**
  52810. * Class used to store shared data between 2 NodeMaterialBuildState
  52811. */
  52812. export class NodeMaterialBuildStateSharedData {
  52813. /**
  52814. * Gets the list of emitted varyings
  52815. */
  52816. varyings: string[];
  52817. /**
  52818. * Gets the varying declaration string
  52819. */
  52820. varyingDeclaration: string;
  52821. /**
  52822. * Uniform connection points
  52823. */
  52824. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  52825. /**
  52826. * Bindable blocks (Blocks that need to set data to the effect)
  52827. */
  52828. bindableBlocks: NodeMaterialBlock[];
  52829. /**
  52830. * List of blocks that can provide a compilation fallback
  52831. */
  52832. blocksWithFallbacks: NodeMaterialBlock[];
  52833. /**
  52834. * List of blocks that can provide a define update
  52835. */
  52836. blocksWithDefines: NodeMaterialBlock[];
  52837. /**
  52838. * List of blocks that can provide a repeatable content
  52839. */
  52840. repeatableContentBlocks: NodeMaterialBlock[];
  52841. /**
  52842. * List of blocks that can block the isReady function for the material
  52843. */
  52844. blockingBlocks: NodeMaterialBlock[];
  52845. /**
  52846. * Build Id used to avoid multiple recompilations
  52847. */
  52848. buildId: number;
  52849. /** List of emitted variables */
  52850. variableNames: {
  52851. [key: string]: number;
  52852. };
  52853. /** List of emitted defines */
  52854. defineNames: {
  52855. [key: string]: number;
  52856. };
  52857. /** Should emit comments? */
  52858. emitComments: boolean;
  52859. /** Emit build activity */
  52860. verbose: boolean;
  52861. /**
  52862. * Gets the compilation hints emitted at compilation time
  52863. */
  52864. hints: {
  52865. needWorldViewMatrix: boolean;
  52866. needWorldViewProjectionMatrix: boolean;
  52867. needAlphaBlending: boolean;
  52868. needAlphaTesting: boolean;
  52869. };
  52870. /**
  52871. * List of compilation checks
  52872. */
  52873. checks: {
  52874. emitVertex: boolean;
  52875. emitFragment: boolean;
  52876. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52877. };
  52878. /** Creates a new shared data */
  52879. constructor();
  52880. /**
  52881. * Emits console errors and exceptions if there is a failing check
  52882. */
  52883. emitErrors(): void;
  52884. }
  52885. }
  52886. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  52887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52888. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52889. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52890. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  52891. /**
  52892. * Class used to store node based material build state
  52893. */
  52894. export class NodeMaterialBuildState {
  52895. /**
  52896. * Gets the list of emitted attributes
  52897. */
  52898. attributes: string[];
  52899. /**
  52900. * Gets the list of emitted uniforms
  52901. */
  52902. uniforms: string[];
  52903. /**
  52904. * Gets the list of emitted samplers
  52905. */
  52906. samplers: string[];
  52907. /**
  52908. * Gets the list of emitted functions
  52909. */
  52910. functions: {
  52911. [key: string]: string;
  52912. };
  52913. /**
  52914. * Gets the target of the compilation state
  52915. */
  52916. target: NodeMaterialBlockTargets;
  52917. /**
  52918. * Shared data between multiple NodeMaterialBuildState instances
  52919. */
  52920. sharedData: NodeMaterialBuildStateSharedData;
  52921. /** @hidden */
  52922. _vertexState: NodeMaterialBuildState;
  52923. private _attributeDeclaration;
  52924. private _uniformDeclaration;
  52925. private _samplerDeclaration;
  52926. private _varyingTransfer;
  52927. private _repeatableContentAnchorIndex;
  52928. /** @hidden */
  52929. _builtCompilationString: string;
  52930. /**
  52931. * Gets the emitted compilation strings
  52932. */
  52933. compilationString: string;
  52934. /**
  52935. * Finalize the compilation strings
  52936. * @param state defines the current compilation state
  52937. */
  52938. finalize(state: NodeMaterialBuildState): void;
  52939. /** @hidden */
  52940. readonly _repeatableContentAnchor: string;
  52941. /** @hidden */
  52942. _getFreeVariableName(prefix: string): string;
  52943. /** @hidden */
  52944. _getFreeDefineName(prefix: string): string;
  52945. /** @hidden */
  52946. _excludeVariableName(name: string): void;
  52947. /** @hidden */
  52948. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52949. /** @hidden */
  52950. _emitFunction(name: string, code: string, comments: string): void;
  52951. /** @hidden */
  52952. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52953. replaceStrings?: {
  52954. search: RegExp;
  52955. replace: string;
  52956. }[];
  52957. }): string;
  52958. /** @hidden */
  52959. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52960. repeatKey?: string;
  52961. removeAttributes?: boolean;
  52962. removeUniforms?: boolean;
  52963. removeVaryings?: boolean;
  52964. removeIfDef?: boolean;
  52965. replaceStrings?: {
  52966. search: RegExp;
  52967. replace: string;
  52968. }[];
  52969. }): void;
  52970. /** @hidden */
  52971. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  52972. private _emitDefine;
  52973. /** @hidden */
  52974. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  52975. }
  52976. }
  52977. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  52978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52979. /**
  52980. * Root class for all node material optimizers
  52981. */
  52982. export class NodeMaterialOptimizer {
  52983. /**
  52984. * Function used to optimize a NodeMaterial graph
  52985. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52986. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52987. */
  52988. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52989. }
  52990. }
  52991. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  52992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52995. /**
  52996. * Block used to transform a vector4 with a matrix
  52997. */
  52998. export class Vector4TransformBlock extends NodeMaterialBlock {
  52999. /**
  53000. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53001. */
  53002. complementW: number;
  53003. /**
  53004. * Creates a new Vector4TransformBlock
  53005. * @param name defines the block name
  53006. */
  53007. constructor(name: string);
  53008. /**
  53009. * Gets the current class name
  53010. * @returns the class name
  53011. */
  53012. getClassName(): string;
  53013. /**
  53014. * Gets the vector input
  53015. */
  53016. readonly vector: NodeMaterialConnectionPoint;
  53017. /**
  53018. * Gets the matrix transform input
  53019. */
  53020. readonly transform: NodeMaterialConnectionPoint;
  53021. protected _buildBlock(state: NodeMaterialBuildState): this;
  53022. }
  53023. }
  53024. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53028. /**
  53029. * Block used to output the vertex position
  53030. */
  53031. export class VertexOutputBlock extends NodeMaterialBlock {
  53032. /**
  53033. * Creates a new VertexOutputBlock
  53034. * @param name defines the block name
  53035. */
  53036. constructor(name: string);
  53037. /**
  53038. * Gets the current class name
  53039. * @returns the class name
  53040. */
  53041. getClassName(): string;
  53042. /**
  53043. * Gets the vector input component
  53044. */
  53045. readonly vector: NodeMaterialConnectionPoint;
  53046. protected _buildBlock(state: NodeMaterialBuildState): this;
  53047. }
  53048. }
  53049. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53053. /**
  53054. * Block used to output the final color
  53055. */
  53056. export class FragmentOutputBlock extends NodeMaterialBlock {
  53057. /**
  53058. * Gets or sets a boolean indicating if this block will output an alpha value
  53059. */
  53060. alphaBlendingEnabled: boolean;
  53061. /**
  53062. * Create a new FragmentOutputBlock
  53063. * @param name defines the block name
  53064. */
  53065. constructor(name: string);
  53066. /**
  53067. * Gets the current class name
  53068. * @returns the class name
  53069. */
  53070. getClassName(): string;
  53071. /**
  53072. * Gets the color input component
  53073. */
  53074. readonly color: NodeMaterialConnectionPoint;
  53075. protected _buildBlock(state: NodeMaterialBuildState): this;
  53076. }
  53077. }
  53078. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53080. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53081. import { Scene } from "babylonjs/scene";
  53082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53083. import { Matrix } from "babylonjs/Maths/math";
  53084. import { Mesh } from "babylonjs/Meshes/mesh";
  53085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53086. import { Observable } from "babylonjs/Misc/observable";
  53087. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53088. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53089. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53090. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53091. import { Nullable } from "babylonjs/types";
  53092. /**
  53093. * Interface used to configure the node material editor
  53094. */
  53095. export interface INodeMaterialEditorOptions {
  53096. /** Define the URl to load node editor script */
  53097. editorURL?: string;
  53098. }
  53099. /** @hidden */
  53100. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53101. /** BONES */
  53102. NUM_BONE_INFLUENCERS: number;
  53103. BonesPerMesh: number;
  53104. BONETEXTURE: boolean;
  53105. /** MORPH TARGETS */
  53106. MORPHTARGETS: boolean;
  53107. MORPHTARGETS_NORMAL: boolean;
  53108. MORPHTARGETS_TANGENT: boolean;
  53109. NUM_MORPH_INFLUENCERS: number;
  53110. /** IMAGE PROCESSING */
  53111. IMAGEPROCESSING: boolean;
  53112. VIGNETTE: boolean;
  53113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53114. VIGNETTEBLENDMODEOPAQUE: boolean;
  53115. TONEMAPPING: boolean;
  53116. TONEMAPPING_ACES: boolean;
  53117. CONTRAST: boolean;
  53118. EXPOSURE: boolean;
  53119. COLORCURVES: boolean;
  53120. COLORGRADING: boolean;
  53121. COLORGRADING3D: boolean;
  53122. SAMPLER3DGREENDEPTH: boolean;
  53123. SAMPLER3DBGRMAP: boolean;
  53124. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53125. constructor();
  53126. setValue(name: string, value: boolean): void;
  53127. }
  53128. /**
  53129. * Class used to configure NodeMaterial
  53130. */
  53131. export interface INodeMaterialOptions {
  53132. /**
  53133. * Defines if blocks should emit comments
  53134. */
  53135. emitComments: boolean;
  53136. }
  53137. /**
  53138. * Class used to create a node based material built by assembling shader blocks
  53139. */
  53140. export class NodeMaterial extends PushMaterial {
  53141. private _options;
  53142. private _vertexCompilationState;
  53143. private _fragmentCompilationState;
  53144. private _sharedData;
  53145. private _buildId;
  53146. private _buildWasSuccessful;
  53147. private _cachedWorldViewMatrix;
  53148. private _cachedWorldViewProjectionMatrix;
  53149. private _textureConnectionPoints;
  53150. private _optimizers;
  53151. /** Define the URl to load node editor script */
  53152. static EditorURL: string;
  53153. private BJSNODEMATERIALEDITOR;
  53154. /** Get the inspector from bundle or global */
  53155. private _getGlobalNodeMaterialEditor;
  53156. /**
  53157. * Defines the maximum number of lights that can be used in the material
  53158. */
  53159. maxSimultaneousLights: number;
  53160. /**
  53161. * Observable raised when the material is built
  53162. */
  53163. onBuildObservable: Observable<NodeMaterial>;
  53164. /**
  53165. * Gets or sets the root nodes of the material vertex shader
  53166. */
  53167. _vertexOutputNodes: NodeMaterialBlock[];
  53168. /**
  53169. * Gets or sets the root nodes of the material fragment (pixel) shader
  53170. */
  53171. _fragmentOutputNodes: NodeMaterialBlock[];
  53172. /** Gets or sets options to control the node material overall behavior */
  53173. options: INodeMaterialOptions;
  53174. /**
  53175. * Default configuration related to image processing available in the standard Material.
  53176. */
  53177. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53178. /**
  53179. * Gets the image processing configuration used either in this material.
  53180. */
  53181. /**
  53182. * Sets the Default image processing configuration used either in the this material.
  53183. *
  53184. * If sets to null, the scene one is in use.
  53185. */
  53186. imageProcessingConfiguration: ImageProcessingConfiguration;
  53187. /**
  53188. * Create a new node based material
  53189. * @param name defines the material name
  53190. * @param scene defines the hosting scene
  53191. * @param options defines creation option
  53192. */
  53193. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53194. /**
  53195. * Gets the current class name of the material e.g. "NodeMaterial"
  53196. * @returns the class name
  53197. */
  53198. getClassName(): string;
  53199. /**
  53200. * Keep track of the image processing observer to allow dispose and replace.
  53201. */
  53202. private _imageProcessingObserver;
  53203. /**
  53204. * Attaches a new image processing configuration to the Standard Material.
  53205. * @param configuration
  53206. */
  53207. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53208. /**
  53209. * Adds a new optimizer to the list of optimizers
  53210. * @param optimizer defines the optimizers to add
  53211. * @returns the current material
  53212. */
  53213. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53214. /**
  53215. * Remove an optimizer from the list of optimizers
  53216. * @param optimizer defines the optimizers to remove
  53217. * @returns the current material
  53218. */
  53219. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53220. /**
  53221. * Add a new block to the list of output nodes
  53222. * @param node defines the node to add
  53223. * @returns the current material
  53224. */
  53225. addOutputNode(node: NodeMaterialBlock): this;
  53226. /**
  53227. * Remove a block from the list of root nodes
  53228. * @param node defines the node to remove
  53229. * @returns the current material
  53230. */
  53231. removeOutputNode(node: NodeMaterialBlock): this;
  53232. private _addVertexOutputNode;
  53233. private _removeVertexOutputNode;
  53234. private _addFragmentOutputNode;
  53235. private _removeFragmentOutputNode;
  53236. /**
  53237. * Specifies if the material will require alpha blending
  53238. * @returns a boolean specifying if alpha blending is needed
  53239. */
  53240. needAlphaBlending(): boolean;
  53241. /**
  53242. * Specifies if this material should be rendered in alpha test mode
  53243. * @returns a boolean specifying if an alpha test is needed.
  53244. */
  53245. needAlphaTesting(): boolean;
  53246. private _initializeBlock;
  53247. private _resetDualBlocks;
  53248. /**
  53249. * Build the material and generates the inner effect
  53250. * @param verbose defines if the build should log activity
  53251. */
  53252. build(verbose?: boolean): void;
  53253. /**
  53254. * Runs an otpimization phase to try to improve the shader code
  53255. */
  53256. optimize(): void;
  53257. private _prepareDefinesForAttributes;
  53258. /**
  53259. * Get if the submesh is ready to be used and all its information available.
  53260. * Child classes can use it to update shaders
  53261. * @param mesh defines the mesh to check
  53262. * @param subMesh defines which submesh to check
  53263. * @param useInstances specifies that instances should be used
  53264. * @returns a boolean indicating that the submesh is ready or not
  53265. */
  53266. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53267. /**
  53268. * Binds the world matrix to the material
  53269. * @param world defines the world transformation matrix
  53270. */
  53271. bindOnlyWorldMatrix(world: Matrix): void;
  53272. /**
  53273. * Binds the submesh to this material by preparing the effect and shader to draw
  53274. * @param world defines the world transformation matrix
  53275. * @param mesh defines the mesh containing the submesh
  53276. * @param subMesh defines the submesh to bind the material to
  53277. */
  53278. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53279. /**
  53280. * Gets the active textures from the material
  53281. * @returns an array of textures
  53282. */
  53283. getActiveTextures(): BaseTexture[];
  53284. /**
  53285. * Specifies if the material uses a texture
  53286. * @param texture defines the texture to check against the material
  53287. * @returns a boolean specifying if the material uses the texture
  53288. */
  53289. hasTexture(texture: BaseTexture): boolean;
  53290. /**
  53291. * Disposes the material
  53292. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53293. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53294. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53295. */
  53296. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53297. /** Creates the node editor window. */
  53298. private _createNodeEditor;
  53299. /**
  53300. * Launch the node material editor
  53301. * @param config Define the configuration of the editor
  53302. * @return a promise fulfilled when the node editor is visible
  53303. */
  53304. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53305. /**
  53306. * Clear the current material
  53307. */
  53308. clear(): void;
  53309. /**
  53310. * Clear the current material and set it to a default state
  53311. */
  53312. setToDefault(): void;
  53313. }
  53314. }
  53315. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53316. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53318. import { Nullable } from "babylonjs/types";
  53319. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53320. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53321. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53323. import { Mesh } from "babylonjs/Meshes/mesh";
  53324. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53325. /**
  53326. * Defines a block that can be used inside a node based material
  53327. */
  53328. export class NodeMaterialBlock {
  53329. private _buildId;
  53330. private _target;
  53331. private _isFinalMerger;
  53332. /** @hidden */
  53333. _inputs: NodeMaterialConnectionPoint[];
  53334. /** @hidden */
  53335. _outputs: NodeMaterialConnectionPoint[];
  53336. /**
  53337. * Gets or sets the name of the block
  53338. */
  53339. name: string;
  53340. /**
  53341. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53342. */
  53343. readonly isFinalMerger: boolean;
  53344. /**
  53345. * Gets or sets the build Id
  53346. */
  53347. buildId: number;
  53348. /**
  53349. * Gets or sets the target of the block
  53350. */
  53351. target: NodeMaterialBlockTargets;
  53352. /**
  53353. * Gets the list of input points
  53354. */
  53355. readonly inputs: NodeMaterialConnectionPoint[];
  53356. /** Gets the list of output points */
  53357. readonly outputs: NodeMaterialConnectionPoint[];
  53358. /**
  53359. * Find an input by its name
  53360. * @param name defines the name of the input to look for
  53361. * @returns the input or null if not found
  53362. */
  53363. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53364. /**
  53365. * Find an output by its name
  53366. * @param name defines the name of the outputto look for
  53367. * @returns the output or null if not found
  53368. */
  53369. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53370. /**
  53371. * Creates a new NodeMaterialBlock
  53372. * @param name defines the block name
  53373. * @param target defines the target of that block (Vertex by default)
  53374. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53375. */
  53376. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53377. /**
  53378. * Initialize the block and prepare the context for build
  53379. * @param state defines the state that will be used for the build
  53380. */
  53381. initialize(state: NodeMaterialBuildState): void;
  53382. /**
  53383. * Bind data to effect. Will only be called for blocks with isBindable === true
  53384. * @param effect defines the effect to bind data to
  53385. * @param nodeMaterial defines the hosting NodeMaterial
  53386. * @param mesh defines the mesh that will be rendered
  53387. */
  53388. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53389. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53390. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53391. protected _writeFloat(value: number): string;
  53392. /**
  53393. * Gets the current class name e.g. "NodeMaterialBlock"
  53394. * @returns the class name
  53395. */
  53396. getClassName(): string;
  53397. /**
  53398. * Register a new input. Must be called inside a block constructor
  53399. * @param name defines the connection point name
  53400. * @param type defines the connection point type
  53401. * @param isOptional defines a boolean indicating that this input can be omitted
  53402. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53403. * @returns the current block
  53404. */
  53405. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53406. /**
  53407. * Register a new output. Must be called inside a block constructor
  53408. * @param name defines the connection point name
  53409. * @param type defines the connection point type
  53410. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53411. * @returns the current block
  53412. */
  53413. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53414. /**
  53415. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53416. * @param forOutput defines an optional connection point to check compatibility with
  53417. * @returns the first available input or null
  53418. */
  53419. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53420. /**
  53421. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53422. * @param forBlock defines an optional block to check compatibility with
  53423. * @returns the first available input or null
  53424. */
  53425. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53426. /**
  53427. * Connect current block with another block
  53428. * @param other defines the block to connect with
  53429. * @param options define the various options to help pick the right connections
  53430. * @returns the current block
  53431. */
  53432. connectTo(other: NodeMaterialBlock, options?: {
  53433. input?: string;
  53434. output?: string;
  53435. outputSwizzle?: string;
  53436. }): this | undefined;
  53437. protected _buildBlock(state: NodeMaterialBuildState): void;
  53438. /**
  53439. * Add potential fallbacks if shader compilation fails
  53440. * @param mesh defines the mesh to be rendered
  53441. * @param fallbacks defines the current prioritized list of fallbacks
  53442. */
  53443. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53444. /**
  53445. * Update defines for shader compilation
  53446. * @param mesh defines the mesh to be rendered
  53447. * @param nodeMaterial defines the node material requesting the update
  53448. * @param defines defines the material defines to update
  53449. * @param useInstances specifies that instances should be used
  53450. */
  53451. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53452. /**
  53453. * Lets the block try to connect some inputs automatically
  53454. */
  53455. autoConfigure(): void;
  53456. /**
  53457. * Function called when a block is declared as repeatable content generator
  53458. * @param vertexShaderState defines the current compilation state for the vertex shader
  53459. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53460. * @param mesh defines the mesh to be rendered
  53461. * @param defines defines the material defines to update
  53462. */
  53463. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53464. /**
  53465. * Checks if the block is ready
  53466. * @param mesh defines the mesh to be rendered
  53467. * @param nodeMaterial defines the node material requesting the update
  53468. * @param defines defines the material defines to update
  53469. * @param useInstances specifies that instances should be used
  53470. * @returns true if the block is ready
  53471. */
  53472. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53473. /**
  53474. * Compile the current node and generate the shader code
  53475. * @param state defines the current compilation state (uniforms, samplers, current string)
  53476. * @returns the current block
  53477. */
  53478. build(state: NodeMaterialBuildState): this | undefined;
  53479. }
  53480. }
  53481. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53482. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53483. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53484. import { Nullable } from "babylonjs/types";
  53485. import { Effect } from "babylonjs/Materials/effect";
  53486. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53487. import { Scene } from "babylonjs/scene";
  53488. import { Matrix } from "babylonjs/Maths/math";
  53489. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53490. /**
  53491. * Defines a connection point for a block
  53492. */
  53493. export class NodeMaterialConnectionPoint {
  53494. /** @hidden */
  53495. _ownerBlock: NodeMaterialBlock;
  53496. /** @hidden */
  53497. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53498. private _associatedVariableName;
  53499. private _endpoints;
  53500. private _storedValue;
  53501. private _valueCallback;
  53502. private _mode;
  53503. /** @hidden */
  53504. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53505. /** @hidden */
  53506. _needToEmitVarying: boolean;
  53507. /**
  53508. * Gets or sets the connection point type (default is float)
  53509. */
  53510. type: NodeMaterialBlockConnectionPointTypes;
  53511. /**
  53512. * Gets or sets the connection point name
  53513. */
  53514. name: string;
  53515. /**
  53516. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53517. */
  53518. swizzle: string;
  53519. /**
  53520. * Gets or sets a boolean indicating that this connection point can be omitted
  53521. */
  53522. isOptional: boolean;
  53523. /**
  53524. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53525. */
  53526. define: string;
  53527. /** Gets or sets the target of that connection point */
  53528. target: NodeMaterialBlockTargets;
  53529. /**
  53530. * Gets or sets the value of that point.
  53531. * Please note that this value will be ignored if valueCallback is defined
  53532. */
  53533. value: any;
  53534. /**
  53535. * Gets or sets a callback used to get the value of that point.
  53536. * Please note that setting this value will force the connection point to ignore the value property
  53537. */
  53538. valueCallback: () => any;
  53539. /**
  53540. * Gets or sets the associated variable name in the shader
  53541. */
  53542. associatedVariableName: string;
  53543. /**
  53544. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53545. * In this case the connection point name must be the name of the uniform to use.
  53546. * Can only be set on inputs
  53547. */
  53548. isUniform: boolean;
  53549. /**
  53550. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53551. * In this case the connection point name must be the name of the attribute to use
  53552. * Can only be set on inputs
  53553. */
  53554. isAttribute: boolean;
  53555. /**
  53556. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53557. * Can only be set on exit points
  53558. */
  53559. isVarying: boolean;
  53560. /** Get the other side of the connection (if any) */
  53561. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53562. /** Get the block that owns this connection point */
  53563. readonly ownerBlock: NodeMaterialBlock;
  53564. /** Get the block connected on the other side of this connection (if any) */
  53565. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53566. /** Get the block connected on the endpoints of this connection (if any) */
  53567. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53568. /**
  53569. * Creates a new connection point
  53570. * @param name defines the connection point name
  53571. * @param ownerBlock defines the block hosting this connection point
  53572. */
  53573. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53574. /**
  53575. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53576. * @returns the class name
  53577. */
  53578. getClassName(): string;
  53579. /**
  53580. * Set the source of this connection point to a vertex attribute
  53581. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53582. * @returns the current connection point
  53583. */
  53584. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53585. /**
  53586. * Set the source of this connection point to a well known value
  53587. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53588. * @returns the current connection point
  53589. */
  53590. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53591. /**
  53592. * Gets a boolean indicating that the current connection point is a well known value
  53593. */
  53594. readonly isWellKnownValue: boolean;
  53595. /**
  53596. * Gets or sets the current well known value or null if not defined as well know value
  53597. */
  53598. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53599. private _getTypeLength;
  53600. /**
  53601. * Connect this point to another connection point
  53602. * @param connectionPoint defines the other connection point
  53603. * @returns the current connection point
  53604. */
  53605. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53606. /**
  53607. * Disconnect this point from one of his endpoint
  53608. * @param endpoint defines the other connection point
  53609. * @returns the current connection point
  53610. */
  53611. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53612. /**
  53613. * When connection point is an uniform, this function will send its value to the effect
  53614. * @param effect defines the effect to transmit value to
  53615. * @param world defines the world matrix
  53616. * @param worldView defines the worldxview matrix
  53617. * @param worldViewProjection defines the worldxviewxprojection matrix
  53618. */
  53619. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53620. /**
  53621. * When connection point is an uniform, this function will send its value to the effect
  53622. * @param effect defines the effect to transmit value to
  53623. * @param scene defines the hosting scene
  53624. */
  53625. transmit(effect: Effect, scene: Scene): void;
  53626. }
  53627. }
  53628. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53632. import { Mesh } from "babylonjs/Meshes/mesh";
  53633. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53634. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53635. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53636. /**
  53637. * Block used to add support for vertex skinning (bones)
  53638. */
  53639. export class BonesBlock extends NodeMaterialBlock {
  53640. /**
  53641. * Creates a new BonesBlock
  53642. * @param name defines the block name
  53643. */
  53644. constructor(name: string);
  53645. /**
  53646. * Initialize the block and prepare the context for build
  53647. * @param state defines the state that will be used for the build
  53648. */
  53649. initialize(state: NodeMaterialBuildState): void;
  53650. /**
  53651. * Gets the current class name
  53652. * @returns the class name
  53653. */
  53654. getClassName(): string;
  53655. /**
  53656. * Gets the matrix indices input component
  53657. */
  53658. readonly matricesIndices: NodeMaterialConnectionPoint;
  53659. /**
  53660. * Gets the matrix weights input component
  53661. */
  53662. readonly matricesWeights: NodeMaterialConnectionPoint;
  53663. /**
  53664. * Gets the extra matrix indices input component
  53665. */
  53666. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53667. /**
  53668. * Gets the extra matrix weights input component
  53669. */
  53670. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53671. /**
  53672. * Gets the world input component
  53673. */
  53674. readonly world: NodeMaterialConnectionPoint;
  53675. autoConfigure(): void;
  53676. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53677. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53679. protected _buildBlock(state: NodeMaterialBuildState): this;
  53680. }
  53681. }
  53682. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53684. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53687. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53688. /**
  53689. * Block used to add support for instances
  53690. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53691. */
  53692. export class InstancesBlock extends NodeMaterialBlock {
  53693. /**
  53694. * Creates a new InstancesBlock
  53695. * @param name defines the block name
  53696. */
  53697. constructor(name: string);
  53698. /**
  53699. * Gets the current class name
  53700. * @returns the class name
  53701. */
  53702. getClassName(): string;
  53703. /**
  53704. * Gets the first world row input component
  53705. */
  53706. readonly world0: NodeMaterialConnectionPoint;
  53707. /**
  53708. * Gets the second world row input component
  53709. */
  53710. readonly world1: NodeMaterialConnectionPoint;
  53711. /**
  53712. * Gets the third world row input component
  53713. */
  53714. readonly world2: NodeMaterialConnectionPoint;
  53715. /**
  53716. * Gets the forth world row input component
  53717. */
  53718. readonly world3: NodeMaterialConnectionPoint;
  53719. /**
  53720. * Gets the world input component
  53721. */
  53722. readonly world: NodeMaterialConnectionPoint;
  53723. /**
  53724. * Gets the output component
  53725. */
  53726. readonly output: NodeMaterialConnectionPoint;
  53727. autoConfigure(): void;
  53728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53729. protected _buildBlock(state: NodeMaterialBuildState): this;
  53730. }
  53731. }
  53732. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53733. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53734. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53735. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53737. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53738. import { Effect } from "babylonjs/Materials/effect";
  53739. import { Mesh } from "babylonjs/Meshes/mesh";
  53740. /**
  53741. * Block used to add morph targets support to vertex shader
  53742. */
  53743. export class MorphTargetsBlock extends NodeMaterialBlock {
  53744. private _repeatableContentAnchor;
  53745. private _repeatebleContentGenerated;
  53746. /**
  53747. * Create a new MorphTargetsBlock
  53748. * @param name defines the block name
  53749. */
  53750. constructor(name: string);
  53751. /**
  53752. * Gets the current class name
  53753. * @returns the class name
  53754. */
  53755. getClassName(): string;
  53756. /**
  53757. * Gets the position input component
  53758. */
  53759. readonly position: NodeMaterialConnectionPoint;
  53760. /**
  53761. * Gets the normal input component
  53762. */
  53763. readonly normal: NodeMaterialConnectionPoint;
  53764. /**
  53765. * Gets the tangent input component
  53766. */
  53767. readonly tangent: NodeMaterialConnectionPoint;
  53768. /**
  53769. * Gets the position output component
  53770. */
  53771. readonly positionOutput: NodeMaterialConnectionPoint;
  53772. /**
  53773. * Gets the normal output component
  53774. */
  53775. readonly normalOutput: NodeMaterialConnectionPoint;
  53776. /**
  53777. * Gets the tangent output component
  53778. */
  53779. readonly tangentOutput: NodeMaterialConnectionPoint;
  53780. initialize(state: NodeMaterialBuildState): void;
  53781. autoConfigure(): void;
  53782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53783. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53784. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53785. protected _buildBlock(state: NodeMaterialBuildState): this;
  53786. }
  53787. }
  53788. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  53789. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  53790. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  53791. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  53792. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  53793. }
  53794. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  53795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53798. /**
  53799. * Block used to add an alpha test in the fragment shader
  53800. */
  53801. export class AlphaTestBlock extends NodeMaterialBlock {
  53802. /**
  53803. * Gets or sets the alpha value where alpha testing happens
  53804. */
  53805. alphaCutOff: number;
  53806. /**
  53807. * Create a new AlphaTestBlock
  53808. * @param name defines the block name
  53809. */
  53810. constructor(name: string);
  53811. /**
  53812. * Gets the current class name
  53813. * @returns the class name
  53814. */
  53815. getClassName(): string;
  53816. /**
  53817. * Gets the color input component
  53818. */
  53819. readonly color: NodeMaterialConnectionPoint;
  53820. protected _buildBlock(state: NodeMaterialBuildState): this;
  53821. }
  53822. }
  53823. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  53824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53826. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53827. /**
  53828. * Block used to create a Color4 out of 4 inputs (one for each component)
  53829. */
  53830. export class RGBAMergerBlock extends NodeMaterialBlock {
  53831. /**
  53832. * Create a new RGBAMergerBlock
  53833. * @param name defines the block name
  53834. */
  53835. constructor(name: string);
  53836. /**
  53837. * Gets the current class name
  53838. * @returns the class name
  53839. */
  53840. getClassName(): string;
  53841. /**
  53842. * Gets the R input component
  53843. */
  53844. readonly r: NodeMaterialConnectionPoint;
  53845. /**
  53846. * Gets the G input component
  53847. */
  53848. readonly g: NodeMaterialConnectionPoint;
  53849. /**
  53850. * Gets the B input component
  53851. */
  53852. readonly b: NodeMaterialConnectionPoint;
  53853. /**
  53854. * Gets the RGB input component
  53855. */
  53856. readonly rgb: NodeMaterialConnectionPoint;
  53857. /**
  53858. * Gets the R input component
  53859. */
  53860. readonly a: NodeMaterialConnectionPoint;
  53861. protected _buildBlock(state: NodeMaterialBuildState): this;
  53862. }
  53863. }
  53864. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  53865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53868. /**
  53869. * Block used to create a Color3 out of 3 inputs (one for each component)
  53870. */
  53871. export class RGBMergerBlock extends NodeMaterialBlock {
  53872. /**
  53873. * Create a new RGBMergerBlock
  53874. * @param name defines the block name
  53875. */
  53876. constructor(name: string);
  53877. /**
  53878. * Gets the current class name
  53879. * @returns the class name
  53880. */
  53881. getClassName(): string;
  53882. /**
  53883. * Gets the R component input
  53884. */
  53885. readonly r: NodeMaterialConnectionPoint;
  53886. /**
  53887. * Gets the G component input
  53888. */
  53889. readonly g: NodeMaterialConnectionPoint;
  53890. /**
  53891. * Gets the B component input
  53892. */
  53893. readonly b: NodeMaterialConnectionPoint;
  53894. protected _buildBlock(state: NodeMaterialBuildState): this;
  53895. }
  53896. }
  53897. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  53898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53901. /**
  53902. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  53903. */
  53904. export class RGBASplitterBlock extends NodeMaterialBlock {
  53905. /**
  53906. * Create a new RGBASplitterBlock
  53907. * @param name defines the block name
  53908. */
  53909. constructor(name: string);
  53910. /**
  53911. * Gets the current class name
  53912. * @returns the class name
  53913. */
  53914. getClassName(): string;
  53915. /**
  53916. * Gets the input component
  53917. */
  53918. readonly input: NodeMaterialConnectionPoint;
  53919. protected _buildBlock(state: NodeMaterialBuildState): this;
  53920. }
  53921. }
  53922. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  53923. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53925. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53926. /**
  53927. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  53928. */
  53929. export class RGBSplitterBlock extends NodeMaterialBlock {
  53930. /**
  53931. * Create a new RGBSplitterBlock
  53932. * @param name defines the block name
  53933. */
  53934. constructor(name: string);
  53935. /**
  53936. * Gets the current class name
  53937. * @returns the class name
  53938. */
  53939. getClassName(): string;
  53940. /**
  53941. * Gets the input component
  53942. */
  53943. readonly input: NodeMaterialConnectionPoint;
  53944. protected _buildBlock(state: NodeMaterialBuildState): this;
  53945. }
  53946. }
  53947. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  53948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53952. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53953. /**
  53954. * Block used to read a texture from a sampler
  53955. */
  53956. export class TextureBlock extends NodeMaterialBlock {
  53957. private _defineName;
  53958. /**
  53959. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  53960. */
  53961. autoConnectTextureMatrix: boolean;
  53962. /**
  53963. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  53964. */
  53965. autoSelectUV: boolean;
  53966. /**
  53967. * Create a new TextureBlock
  53968. * @param name defines the block name
  53969. */
  53970. constructor(name: string);
  53971. /**
  53972. * Gets the current class name
  53973. * @returns the class name
  53974. */
  53975. getClassName(): string;
  53976. /**
  53977. * Gets the uv input component
  53978. */
  53979. readonly uv: NodeMaterialConnectionPoint;
  53980. /**
  53981. * Gets the texture information input component
  53982. */
  53983. readonly textureInfo: NodeMaterialConnectionPoint;
  53984. /**
  53985. * Gets the transformed uv input component
  53986. */
  53987. readonly transformedUV: NodeMaterialConnectionPoint;
  53988. /**
  53989. * Gets the texture input component
  53990. */
  53991. readonly texture: NodeMaterialConnectionPoint;
  53992. /**
  53993. * Gets the texture transform input component
  53994. */
  53995. readonly textureTransform: NodeMaterialConnectionPoint;
  53996. autoConfigure(): void;
  53997. initialize(state: NodeMaterialBuildState): void;
  53998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53999. isReady(): boolean;
  54000. private _injectVertexCode;
  54001. protected _buildBlock(state: NodeMaterialBuildState): this;
  54002. }
  54003. }
  54004. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54009. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54010. import { Effect } from "babylonjs/Materials/effect";
  54011. import { Mesh } from "babylonjs/Meshes/mesh";
  54012. /**
  54013. * Block used to add image processing support to fragment shader
  54014. */
  54015. export class ImageProcessingBlock extends NodeMaterialBlock {
  54016. /**
  54017. * Create a new ImageProcessingBlock
  54018. * @param name defines the block name
  54019. */
  54020. constructor(name: string);
  54021. /**
  54022. * Gets the current class name
  54023. * @returns the class name
  54024. */
  54025. getClassName(): string;
  54026. /**
  54027. * Gets the color input component
  54028. */
  54029. readonly color: NodeMaterialConnectionPoint;
  54030. /**
  54031. * Initialize the block and prepare the context for build
  54032. * @param state defines the state that will be used for the build
  54033. */
  54034. initialize(state: NodeMaterialBuildState): void;
  54035. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54036. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54037. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54038. protected _buildBlock(state: NodeMaterialBuildState): this;
  54039. }
  54040. }
  54041. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54042. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54043. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54044. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54045. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54046. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54047. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54048. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54049. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54050. }
  54051. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54054. import { Mesh } from "babylonjs/Meshes/mesh";
  54055. import { Effect } from "babylonjs/Materials/effect";
  54056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54058. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54059. /**
  54060. * Block used to add support for scene fog
  54061. */
  54062. export class FogBlock extends NodeMaterialBlock {
  54063. /**
  54064. * Create a new FogBlock
  54065. * @param name defines the block name
  54066. */
  54067. constructor(name: string);
  54068. /**
  54069. * Gets the current class name
  54070. * @returns the class name
  54071. */
  54072. getClassName(): string;
  54073. /**
  54074. * Gets the world position input component
  54075. */
  54076. readonly worldPosition: NodeMaterialConnectionPoint;
  54077. /**
  54078. * Gets the view input component
  54079. */
  54080. readonly view: NodeMaterialConnectionPoint;
  54081. /**
  54082. * Gets the color input component
  54083. */
  54084. readonly color: NodeMaterialConnectionPoint;
  54085. /**
  54086. * Gets the fog color input component
  54087. */
  54088. readonly fogColor: NodeMaterialConnectionPoint;
  54089. /**
  54090. * Gets the for parameter input component
  54091. */
  54092. readonly fogParameters: NodeMaterialConnectionPoint;
  54093. autoConfigure(): void;
  54094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54095. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54096. protected _buildBlock(state: NodeMaterialBuildState): this;
  54097. }
  54098. }
  54099. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54100. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54101. }
  54102. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54103. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54104. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54105. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54106. /**
  54107. * Block used to multiply 2 vector4
  54108. */
  54109. export class MultiplyBlock extends NodeMaterialBlock {
  54110. /**
  54111. * Creates a new MultiplyBlock
  54112. * @param name defines the block name
  54113. */
  54114. constructor(name: string);
  54115. /**
  54116. * Gets the current class name
  54117. * @returns the class name
  54118. */
  54119. getClassName(): string;
  54120. /**
  54121. * Gets the left operand input component
  54122. */
  54123. readonly left: NodeMaterialConnectionPoint;
  54124. /**
  54125. * Gets the right operand input component
  54126. */
  54127. readonly right: NodeMaterialConnectionPoint;
  54128. protected _buildBlock(state: NodeMaterialBuildState): this;
  54129. }
  54130. }
  54131. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54133. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54134. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54135. /**
  54136. * Block used to add 2 vector4
  54137. */
  54138. export class AddBlock extends NodeMaterialBlock {
  54139. /**
  54140. * Creates a new AddBlock
  54141. * @param name defines the block name
  54142. */
  54143. constructor(name: string);
  54144. /**
  54145. * Gets the current class name
  54146. * @returns the class name
  54147. */
  54148. getClassName(): string;
  54149. /**
  54150. * Gets the left operand input component
  54151. */
  54152. readonly left: NodeMaterialConnectionPoint;
  54153. /**
  54154. * Gets the right operand input component
  54155. */
  54156. readonly right: NodeMaterialConnectionPoint;
  54157. protected _buildBlock(state: NodeMaterialBuildState): this;
  54158. }
  54159. }
  54160. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54164. /**
  54165. * Block used to clamp a float
  54166. */
  54167. export class ClampBlock extends NodeMaterialBlock {
  54168. /** Gets or sets the minimum range */
  54169. minimum: number;
  54170. /** Gets or sets the maximum range */
  54171. maximum: number;
  54172. /**
  54173. * Creates a new ClampBlock
  54174. * @param name defines the block name
  54175. */
  54176. constructor(name: string);
  54177. /**
  54178. * Gets the current class name
  54179. * @returns the class name
  54180. */
  54181. getClassName(): string;
  54182. /**
  54183. * Gets the value input component
  54184. */
  54185. readonly value: NodeMaterialConnectionPoint;
  54186. protected _buildBlock(state: NodeMaterialBuildState): this;
  54187. }
  54188. }
  54189. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54193. /**
  54194. * Block used to transform a vector2 with a matrix
  54195. */
  54196. export class Vector2TransformBlock extends NodeMaterialBlock {
  54197. /**
  54198. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54199. */
  54200. complementZ: number;
  54201. /**
  54202. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54203. */
  54204. complementW: number;
  54205. /**
  54206. * Creates a new Vector2TransformBlock
  54207. * @param name defines the block name
  54208. */
  54209. constructor(name: string);
  54210. /**
  54211. * Gets the vector input
  54212. */
  54213. readonly vector: NodeMaterialConnectionPoint;
  54214. /**
  54215. * Gets the matrix transform input
  54216. */
  54217. readonly transform: NodeMaterialConnectionPoint;
  54218. /**
  54219. * Gets the current class name
  54220. * @returns the class name
  54221. */
  54222. getClassName(): string;
  54223. protected _buildBlock(state: NodeMaterialBuildState): this;
  54224. }
  54225. }
  54226. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54227. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54228. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54229. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54230. /**
  54231. * Block used to transform a vector3 with a matrix
  54232. */
  54233. export class Vector3TransformBlock extends NodeMaterialBlock {
  54234. /**
  54235. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54236. */
  54237. complement: number;
  54238. /**
  54239. * Creates a new Vector3TransformBlock
  54240. * @param name defines the block name
  54241. */
  54242. constructor(name: string);
  54243. /**
  54244. * Gets the vector input
  54245. */
  54246. readonly vector: NodeMaterialConnectionPoint;
  54247. /**
  54248. * Gets the matrix transform input
  54249. */
  54250. readonly transform: NodeMaterialConnectionPoint;
  54251. /**
  54252. * Gets the current class name
  54253. * @returns the class name
  54254. */
  54255. getClassName(): string;
  54256. protected _buildBlock(state: NodeMaterialBuildState): this;
  54257. }
  54258. }
  54259. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54260. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54261. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54262. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54263. /**
  54264. * Block used to multiply two matrices
  54265. */
  54266. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54267. /**
  54268. * Creates a new MatrixMultiplicationBlock
  54269. * @param name defines the block name
  54270. */
  54271. constructor(name: string);
  54272. /**
  54273. * Gets the left operand
  54274. */
  54275. readonly left: NodeMaterialConnectionPoint;
  54276. /**
  54277. * Gets the right operand
  54278. */
  54279. readonly right: NodeMaterialConnectionPoint;
  54280. /**
  54281. * Gets the current class name
  54282. * @returns the class name
  54283. */
  54284. getClassName(): string;
  54285. protected _buildBlock(state: NodeMaterialBuildState): this;
  54286. }
  54287. }
  54288. declare module "babylonjs/Materials/Node/Blocks/index" {
  54289. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54290. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54291. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54292. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54293. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54294. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54295. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54296. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54297. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54298. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54299. }
  54300. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54301. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54302. }
  54303. declare module "babylonjs/Materials/Node/index" {
  54304. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54305. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54306. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54307. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54308. export * from "babylonjs/Materials/Node/nodeMaterial";
  54309. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54310. export * from "babylonjs/Materials/Node/Blocks/index";
  54311. export * from "babylonjs/Materials/Node/Optimizers/index";
  54312. }
  54313. declare module "babylonjs/Materials/index" {
  54314. export * from "babylonjs/Materials/Background/index";
  54315. export * from "babylonjs/Materials/colorCurves";
  54316. export * from "babylonjs/Materials/effect";
  54317. export * from "babylonjs/Materials/fresnelParameters";
  54318. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54319. export * from "babylonjs/Materials/material";
  54320. export * from "babylonjs/Materials/materialDefines";
  54321. export * from "babylonjs/Materials/materialHelper";
  54322. export * from "babylonjs/Materials/multiMaterial";
  54323. export * from "babylonjs/Materials/PBR/index";
  54324. export * from "babylonjs/Materials/pushMaterial";
  54325. export * from "babylonjs/Materials/shaderMaterial";
  54326. export * from "babylonjs/Materials/standardMaterial";
  54327. export * from "babylonjs/Materials/Textures/index";
  54328. export * from "babylonjs/Materials/uniformBuffer";
  54329. export * from "babylonjs/Materials/materialFlags";
  54330. export * from "babylonjs/Materials/Node/index";
  54331. }
  54332. declare module "babylonjs/Maths/index" {
  54333. export * from "babylonjs/Maths/math.scalar";
  54334. export * from "babylonjs/Maths/math";
  54335. export * from "babylonjs/Maths/sphericalPolynomial";
  54336. }
  54337. declare module "babylonjs/Misc/workerPool" {
  54338. import { IDisposable } from "babylonjs/scene";
  54339. /**
  54340. * Helper class to push actions to a pool of workers.
  54341. */
  54342. export class WorkerPool implements IDisposable {
  54343. private _workerInfos;
  54344. private _pendingActions;
  54345. /**
  54346. * Constructor
  54347. * @param workers Array of workers to use for actions
  54348. */
  54349. constructor(workers: Array<Worker>);
  54350. /**
  54351. * Terminates all workers and clears any pending actions.
  54352. */
  54353. dispose(): void;
  54354. /**
  54355. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54356. * pended until a worker has completed its action.
  54357. * @param action The action to perform. Call onComplete when the action is complete.
  54358. */
  54359. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54360. private _execute;
  54361. }
  54362. }
  54363. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54364. import { IDisposable } from "babylonjs/scene";
  54365. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54366. /**
  54367. * Configuration for Draco compression
  54368. */
  54369. export interface IDracoCompressionConfiguration {
  54370. /**
  54371. * Configuration for the decoder.
  54372. */
  54373. decoder: {
  54374. /**
  54375. * The url to the WebAssembly module.
  54376. */
  54377. wasmUrl?: string;
  54378. /**
  54379. * The url to the WebAssembly binary.
  54380. */
  54381. wasmBinaryUrl?: string;
  54382. /**
  54383. * The url to the fallback JavaScript module.
  54384. */
  54385. fallbackUrl?: string;
  54386. };
  54387. }
  54388. /**
  54389. * Draco compression (https://google.github.io/draco/)
  54390. *
  54391. * This class wraps the Draco module.
  54392. *
  54393. * **Encoder**
  54394. *
  54395. * The encoder is not currently implemented.
  54396. *
  54397. * **Decoder**
  54398. *
  54399. * 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.
  54400. *
  54401. * To update the configuration, use the following code:
  54402. * ```javascript
  54403. * DracoCompression.Configuration = {
  54404. * decoder: {
  54405. * wasmUrl: "<url to the WebAssembly library>",
  54406. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54407. * fallbackUrl: "<url to the fallback JavaScript library>",
  54408. * }
  54409. * };
  54410. * ```
  54411. *
  54412. * 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.
  54413. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54414. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54415. *
  54416. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54417. * ```javascript
  54418. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54419. * ```
  54420. *
  54421. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54422. */
  54423. export class DracoCompression implements IDisposable {
  54424. private _workerPoolPromise?;
  54425. private _decoderModulePromise?;
  54426. /**
  54427. * The configuration. Defaults to the following urls:
  54428. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54429. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54430. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54431. */
  54432. static Configuration: IDracoCompressionConfiguration;
  54433. /**
  54434. * Returns true if the decoder configuration is available.
  54435. */
  54436. static readonly DecoderAvailable: boolean;
  54437. /**
  54438. * Default number of workers to create when creating the draco compression object.
  54439. */
  54440. static DefaultNumWorkers: number;
  54441. private static GetDefaultNumWorkers;
  54442. private static _Default;
  54443. /**
  54444. * Default instance for the draco compression object.
  54445. */
  54446. static readonly Default: DracoCompression;
  54447. /**
  54448. * Constructor
  54449. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54450. */
  54451. constructor(numWorkers?: number);
  54452. /**
  54453. * Stop all async operations and release resources.
  54454. */
  54455. dispose(): void;
  54456. /**
  54457. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54458. * @returns a promise that resolves when ready
  54459. */
  54460. whenReadyAsync(): Promise<void>;
  54461. /**
  54462. * Decode Draco compressed mesh data to vertex data.
  54463. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54464. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54465. * @returns A promise that resolves with the decoded vertex data
  54466. */
  54467. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54468. [kind: string]: number;
  54469. }): Promise<VertexData>;
  54470. }
  54471. }
  54472. declare module "babylonjs/Meshes/Compression/index" {
  54473. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54474. }
  54475. declare module "babylonjs/Meshes/csg" {
  54476. import { Nullable } from "babylonjs/types";
  54477. import { Scene } from "babylonjs/scene";
  54478. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54479. import { Mesh } from "babylonjs/Meshes/mesh";
  54480. import { Material } from "babylonjs/Materials/material";
  54481. /**
  54482. * Class for building Constructive Solid Geometry
  54483. */
  54484. export class CSG {
  54485. private polygons;
  54486. /**
  54487. * The world matrix
  54488. */
  54489. matrix: Matrix;
  54490. /**
  54491. * Stores the position
  54492. */
  54493. position: Vector3;
  54494. /**
  54495. * Stores the rotation
  54496. */
  54497. rotation: Vector3;
  54498. /**
  54499. * Stores the rotation quaternion
  54500. */
  54501. rotationQuaternion: Nullable<Quaternion>;
  54502. /**
  54503. * Stores the scaling vector
  54504. */
  54505. scaling: Vector3;
  54506. /**
  54507. * Convert the Mesh to CSG
  54508. * @param mesh The Mesh to convert to CSG
  54509. * @returns A new CSG from the Mesh
  54510. */
  54511. static FromMesh(mesh: Mesh): CSG;
  54512. /**
  54513. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54514. * @param polygons Polygons used to construct a CSG solid
  54515. */
  54516. private static FromPolygons;
  54517. /**
  54518. * Clones, or makes a deep copy, of the CSG
  54519. * @returns A new CSG
  54520. */
  54521. clone(): CSG;
  54522. /**
  54523. * Unions this CSG with another CSG
  54524. * @param csg The CSG to union against this CSG
  54525. * @returns The unioned CSG
  54526. */
  54527. union(csg: CSG): CSG;
  54528. /**
  54529. * Unions this CSG with another CSG in place
  54530. * @param csg The CSG to union against this CSG
  54531. */
  54532. unionInPlace(csg: CSG): void;
  54533. /**
  54534. * Subtracts this CSG with another CSG
  54535. * @param csg The CSG to subtract against this CSG
  54536. * @returns A new CSG
  54537. */
  54538. subtract(csg: CSG): CSG;
  54539. /**
  54540. * Subtracts this CSG with another CSG in place
  54541. * @param csg The CSG to subtact against this CSG
  54542. */
  54543. subtractInPlace(csg: CSG): void;
  54544. /**
  54545. * Intersect this CSG with another CSG
  54546. * @param csg The CSG to intersect against this CSG
  54547. * @returns A new CSG
  54548. */
  54549. intersect(csg: CSG): CSG;
  54550. /**
  54551. * Intersects this CSG with another CSG in place
  54552. * @param csg The CSG to intersect against this CSG
  54553. */
  54554. intersectInPlace(csg: CSG): void;
  54555. /**
  54556. * Return a new CSG solid with solid and empty space switched. This solid is
  54557. * not modified.
  54558. * @returns A new CSG solid with solid and empty space switched
  54559. */
  54560. inverse(): CSG;
  54561. /**
  54562. * Inverses the CSG in place
  54563. */
  54564. inverseInPlace(): void;
  54565. /**
  54566. * This is used to keep meshes transformations so they can be restored
  54567. * when we build back a Babylon Mesh
  54568. * NB : All CSG operations are performed in world coordinates
  54569. * @param csg The CSG to copy the transform attributes from
  54570. * @returns This CSG
  54571. */
  54572. copyTransformAttributes(csg: CSG): CSG;
  54573. /**
  54574. * Build Raw mesh from CSG
  54575. * Coordinates here are in world space
  54576. * @param name The name of the mesh geometry
  54577. * @param scene The Scene
  54578. * @param keepSubMeshes Specifies if the submeshes should be kept
  54579. * @returns A new Mesh
  54580. */
  54581. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54582. /**
  54583. * Build Mesh from CSG taking material and transforms into account
  54584. * @param name The name of the Mesh
  54585. * @param material The material of the Mesh
  54586. * @param scene The Scene
  54587. * @param keepSubMeshes Specifies if submeshes should be kept
  54588. * @returns The new Mesh
  54589. */
  54590. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54591. }
  54592. }
  54593. declare module "babylonjs/Meshes/trailMesh" {
  54594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54595. import { Mesh } from "babylonjs/Meshes/mesh";
  54596. import { Scene } from "babylonjs/scene";
  54597. /**
  54598. * Class used to create a trail following a mesh
  54599. */
  54600. export class TrailMesh extends Mesh {
  54601. private _generator;
  54602. private _autoStart;
  54603. private _running;
  54604. private _diameter;
  54605. private _length;
  54606. private _sectionPolygonPointsCount;
  54607. private _sectionVectors;
  54608. private _sectionNormalVectors;
  54609. private _beforeRenderObserver;
  54610. /**
  54611. * @constructor
  54612. * @param name The value used by scene.getMeshByName() to do a lookup.
  54613. * @param generator The mesh to generate a trail.
  54614. * @param scene The scene to add this mesh to.
  54615. * @param diameter Diameter of trailing mesh. Default is 1.
  54616. * @param length Length of trailing mesh. Default is 60.
  54617. * @param autoStart Automatically start trailing mesh. Default true.
  54618. */
  54619. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54620. /**
  54621. * "TrailMesh"
  54622. * @returns "TrailMesh"
  54623. */
  54624. getClassName(): string;
  54625. private _createMesh;
  54626. /**
  54627. * Start trailing mesh.
  54628. */
  54629. start(): void;
  54630. /**
  54631. * Stop trailing mesh.
  54632. */
  54633. stop(): void;
  54634. /**
  54635. * Update trailing mesh geometry.
  54636. */
  54637. update(): void;
  54638. /**
  54639. * Returns a new TrailMesh object.
  54640. * @param name is a string, the name given to the new mesh
  54641. * @param newGenerator use new generator object for cloned trail mesh
  54642. * @returns a new mesh
  54643. */
  54644. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54645. /**
  54646. * Serializes this trail mesh
  54647. * @param serializationObject object to write serialization to
  54648. */
  54649. serialize(serializationObject: any): void;
  54650. /**
  54651. * Parses a serialized trail mesh
  54652. * @param parsedMesh the serialized mesh
  54653. * @param scene the scene to create the trail mesh in
  54654. * @returns the created trail mesh
  54655. */
  54656. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54657. }
  54658. }
  54659. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  54660. import { Nullable } from "babylonjs/types";
  54661. import { Scene } from "babylonjs/scene";
  54662. import { Vector4, Color4 } from "babylonjs/Maths/math";
  54663. import { Mesh } from "babylonjs/Meshes/mesh";
  54664. /**
  54665. * Class containing static functions to help procedurally build meshes
  54666. */
  54667. export class TiledBoxBuilder {
  54668. /**
  54669. * Creates a box mesh
  54670. * 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)
  54671. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54675. * @param name defines the name of the mesh
  54676. * @param options defines the options used to create the mesh
  54677. * @param scene defines the hosting scene
  54678. * @returns the box mesh
  54679. */
  54680. static CreateTiledBox(name: string, options: {
  54681. pattern?: number;
  54682. width?: number;
  54683. height?: number;
  54684. depth?: number;
  54685. tileSize?: number;
  54686. tileWidth?: number;
  54687. tileHeight?: number;
  54688. alignHorizontal?: number;
  54689. alignVertical?: number;
  54690. faceUV?: Vector4[];
  54691. faceColors?: Color4[];
  54692. sideOrientation?: number;
  54693. updatable?: boolean;
  54694. }, scene?: Nullable<Scene>): Mesh;
  54695. }
  54696. }
  54697. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  54698. import { Vector4 } from "babylonjs/Maths/math";
  54699. import { Mesh } from "babylonjs/Meshes/mesh";
  54700. /**
  54701. * Class containing static functions to help procedurally build meshes
  54702. */
  54703. export class TorusKnotBuilder {
  54704. /**
  54705. * Creates a torus knot mesh
  54706. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54707. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54708. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54709. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54713. * @param name defines the name of the mesh
  54714. * @param options defines the options used to create the mesh
  54715. * @param scene defines the hosting scene
  54716. * @returns the torus knot mesh
  54717. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54718. */
  54719. static CreateTorusKnot(name: string, options: {
  54720. radius?: number;
  54721. tube?: number;
  54722. radialSegments?: number;
  54723. tubularSegments?: number;
  54724. p?: number;
  54725. q?: number;
  54726. updatable?: boolean;
  54727. sideOrientation?: number;
  54728. frontUVs?: Vector4;
  54729. backUVs?: Vector4;
  54730. }, scene: any): Mesh;
  54731. }
  54732. }
  54733. declare module "babylonjs/Meshes/polygonMesh" {
  54734. import { Scene } from "babylonjs/scene";
  54735. import { Vector2, Path2 } from "babylonjs/Maths/math";
  54736. import { Mesh } from "babylonjs/Meshes/mesh";
  54737. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54738. /**
  54739. * Polygon
  54740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54741. */
  54742. export class Polygon {
  54743. /**
  54744. * Creates a rectangle
  54745. * @param xmin bottom X coord
  54746. * @param ymin bottom Y coord
  54747. * @param xmax top X coord
  54748. * @param ymax top Y coord
  54749. * @returns points that make the resulting rectation
  54750. */
  54751. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54752. /**
  54753. * Creates a circle
  54754. * @param radius radius of circle
  54755. * @param cx scale in x
  54756. * @param cy scale in y
  54757. * @param numberOfSides number of sides that make up the circle
  54758. * @returns points that make the resulting circle
  54759. */
  54760. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54761. /**
  54762. * Creates a polygon from input string
  54763. * @param input Input polygon data
  54764. * @returns the parsed points
  54765. */
  54766. static Parse(input: string): Vector2[];
  54767. /**
  54768. * Starts building a polygon from x and y coordinates
  54769. * @param x x coordinate
  54770. * @param y y coordinate
  54771. * @returns the started path2
  54772. */
  54773. static StartingAt(x: number, y: number): Path2;
  54774. }
  54775. /**
  54776. * Builds a polygon
  54777. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54778. */
  54779. export class PolygonMeshBuilder {
  54780. private _points;
  54781. private _outlinepoints;
  54782. private _holes;
  54783. private _name;
  54784. private _scene;
  54785. private _epoints;
  54786. private _eholes;
  54787. private _addToepoint;
  54788. /**
  54789. * Babylon reference to the earcut plugin.
  54790. */
  54791. bjsEarcut: any;
  54792. /**
  54793. * Creates a PolygonMeshBuilder
  54794. * @param name name of the builder
  54795. * @param contours Path of the polygon
  54796. * @param scene scene to add to when creating the mesh
  54797. * @param earcutInjection can be used to inject your own earcut reference
  54798. */
  54799. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54800. /**
  54801. * Adds a whole within the polygon
  54802. * @param hole Array of points defining the hole
  54803. * @returns this
  54804. */
  54805. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54806. /**
  54807. * Creates the polygon
  54808. * @param updatable If the mesh should be updatable
  54809. * @param depth The depth of the mesh created
  54810. * @returns the created mesh
  54811. */
  54812. build(updatable?: boolean, depth?: number): Mesh;
  54813. /**
  54814. * Creates the polygon
  54815. * @param depth The depth of the mesh created
  54816. * @returns the created VertexData
  54817. */
  54818. buildVertexData(depth?: number): VertexData;
  54819. /**
  54820. * Adds a side to the polygon
  54821. * @param positions points that make the polygon
  54822. * @param normals normals of the polygon
  54823. * @param uvs uvs of the polygon
  54824. * @param indices indices of the polygon
  54825. * @param bounds bounds of the polygon
  54826. * @param points points of the polygon
  54827. * @param depth depth of the polygon
  54828. * @param flip flip of the polygon
  54829. */
  54830. private addSide;
  54831. }
  54832. }
  54833. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  54834. import { Scene } from "babylonjs/scene";
  54835. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  54836. import { Mesh } from "babylonjs/Meshes/mesh";
  54837. import { Nullable } from "babylonjs/types";
  54838. /**
  54839. * Class containing static functions to help procedurally build meshes
  54840. */
  54841. export class PolygonBuilder {
  54842. /**
  54843. * Creates a polygon mesh
  54844. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54845. * * 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
  54846. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  54849. * * Remember you can only change the shape positions, not their number when updating a polygon
  54850. * @param name defines the name of the mesh
  54851. * @param options defines the options used to create the mesh
  54852. * @param scene defines the hosting scene
  54853. * @param earcutInjection can be used to inject your own earcut reference
  54854. * @returns the polygon mesh
  54855. */
  54856. static CreatePolygon(name: string, options: {
  54857. shape: Vector3[];
  54858. holes?: Vector3[][];
  54859. depth?: number;
  54860. faceUV?: Vector4[];
  54861. faceColors?: Color4[];
  54862. updatable?: boolean;
  54863. sideOrientation?: number;
  54864. frontUVs?: Vector4;
  54865. backUVs?: Vector4;
  54866. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54867. /**
  54868. * Creates an extruded polygon mesh, with depth in the Y direction.
  54869. * * 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)
  54870. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54871. * @param name defines the name of the mesh
  54872. * @param options defines the options used to create the mesh
  54873. * @param scene defines the hosting scene
  54874. * @param earcutInjection can be used to inject your own earcut reference
  54875. * @returns the polygon mesh
  54876. */
  54877. static ExtrudePolygon(name: string, options: {
  54878. shape: Vector3[];
  54879. holes?: Vector3[][];
  54880. depth?: number;
  54881. faceUV?: Vector4[];
  54882. faceColors?: Color4[];
  54883. updatable?: boolean;
  54884. sideOrientation?: number;
  54885. frontUVs?: Vector4;
  54886. backUVs?: Vector4;
  54887. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54888. }
  54889. }
  54890. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  54891. import { Scene } from "babylonjs/scene";
  54892. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54893. import { Mesh } from "babylonjs/Meshes/mesh";
  54894. import { Nullable } from "babylonjs/types";
  54895. /**
  54896. * Class containing static functions to help procedurally build meshes
  54897. */
  54898. export class LatheBuilder {
  54899. /**
  54900. * Creates lathe mesh.
  54901. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54902. * * 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
  54903. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54904. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54905. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54906. * * 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
  54907. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54908. * * 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
  54909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54911. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54913. * @param name defines the name of the mesh
  54914. * @param options defines the options used to create the mesh
  54915. * @param scene defines the hosting scene
  54916. * @returns the lathe mesh
  54917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54918. */
  54919. static CreateLathe(name: string, options: {
  54920. shape: Vector3[];
  54921. radius?: number;
  54922. tessellation?: number;
  54923. clip?: number;
  54924. arc?: number;
  54925. closed?: boolean;
  54926. updatable?: boolean;
  54927. sideOrientation?: number;
  54928. frontUVs?: Vector4;
  54929. backUVs?: Vector4;
  54930. cap?: number;
  54931. invertUV?: boolean;
  54932. }, scene?: Nullable<Scene>): Mesh;
  54933. }
  54934. }
  54935. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  54936. import { Nullable } from "babylonjs/types";
  54937. import { Scene } from "babylonjs/scene";
  54938. import { Vector4 } from "babylonjs/Maths/math";
  54939. import { Mesh } from "babylonjs/Meshes/mesh";
  54940. /**
  54941. * Class containing static functions to help procedurally build meshes
  54942. */
  54943. export class TiledPlaneBuilder {
  54944. /**
  54945. * Creates a tiled plane mesh
  54946. * * The parameter `pattern` will, depending on value, do nothing or
  54947. * * * flip (reflect about central vertical) alternate tiles across and up
  54948. * * * flip every tile on alternate rows
  54949. * * * rotate (180 degs) alternate tiles across and up
  54950. * * * rotate every tile on alternate rows
  54951. * * * flip and rotate alternate tiles across and up
  54952. * * * flip and rotate every tile on alternate rows
  54953. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54954. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54957. * * 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)
  54958. * * 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)
  54959. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54960. * @param name defines the name of the mesh
  54961. * @param options defines the options used to create the mesh
  54962. * @param scene defines the hosting scene
  54963. * @returns the box mesh
  54964. */
  54965. static CreateTiledPlane(name: string, options: {
  54966. pattern?: number;
  54967. tileSize?: number;
  54968. tileWidth?: number;
  54969. tileHeight?: number;
  54970. size?: number;
  54971. width?: number;
  54972. height?: number;
  54973. alignHorizontal?: number;
  54974. alignVertical?: number;
  54975. sideOrientation?: number;
  54976. frontUVs?: Vector4;
  54977. backUVs?: Vector4;
  54978. updatable?: boolean;
  54979. }, scene?: Nullable<Scene>): Mesh;
  54980. }
  54981. }
  54982. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  54983. import { Nullable } from "babylonjs/types";
  54984. import { Scene } from "babylonjs/scene";
  54985. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54986. import { Mesh } from "babylonjs/Meshes/mesh";
  54987. /**
  54988. * Class containing static functions to help procedurally build meshes
  54989. */
  54990. export class TubeBuilder {
  54991. /**
  54992. * Creates a tube mesh.
  54993. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54994. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54995. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54996. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54997. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54998. * * 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)
  54999. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55000. * * 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
  55001. * * 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
  55002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55004. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55006. * @param name defines the name of the mesh
  55007. * @param options defines the options used to create the mesh
  55008. * @param scene defines the hosting scene
  55009. * @returns the tube mesh
  55010. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55011. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55012. */
  55013. static CreateTube(name: string, options: {
  55014. path: Vector3[];
  55015. radius?: number;
  55016. tessellation?: number;
  55017. radiusFunction?: {
  55018. (i: number, distance: number): number;
  55019. };
  55020. cap?: number;
  55021. arc?: number;
  55022. updatable?: boolean;
  55023. sideOrientation?: number;
  55024. frontUVs?: Vector4;
  55025. backUVs?: Vector4;
  55026. instance?: Mesh;
  55027. invertUV?: boolean;
  55028. }, scene?: Nullable<Scene>): Mesh;
  55029. }
  55030. }
  55031. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55032. import { Scene } from "babylonjs/scene";
  55033. import { Vector4 } from "babylonjs/Maths/math";
  55034. import { Mesh } from "babylonjs/Meshes/mesh";
  55035. import { Nullable } from "babylonjs/types";
  55036. /**
  55037. * Class containing static functions to help procedurally build meshes
  55038. */
  55039. export class IcoSphereBuilder {
  55040. /**
  55041. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55042. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55043. * * 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`)
  55044. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55045. * * 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
  55046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55049. * @param name defines the name of the mesh
  55050. * @param options defines the options used to create the mesh
  55051. * @param scene defines the hosting scene
  55052. * @returns the icosahedron mesh
  55053. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55054. */
  55055. static CreateIcoSphere(name: string, options: {
  55056. radius?: number;
  55057. radiusX?: number;
  55058. radiusY?: number;
  55059. radiusZ?: number;
  55060. flat?: boolean;
  55061. subdivisions?: number;
  55062. sideOrientation?: number;
  55063. frontUVs?: Vector4;
  55064. backUVs?: Vector4;
  55065. updatable?: boolean;
  55066. }, scene?: Nullable<Scene>): Mesh;
  55067. }
  55068. }
  55069. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55070. import { Vector3 } from "babylonjs/Maths/math";
  55071. import { Mesh } from "babylonjs/Meshes/mesh";
  55072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55073. /**
  55074. * Class containing static functions to help procedurally build meshes
  55075. */
  55076. export class DecalBuilder {
  55077. /**
  55078. * Creates a decal mesh.
  55079. * 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
  55080. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55081. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55082. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55083. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55084. * @param name defines the name of the mesh
  55085. * @param sourceMesh defines the mesh where the decal must be applied
  55086. * @param options defines the options used to create the mesh
  55087. * @param scene defines the hosting scene
  55088. * @returns the decal mesh
  55089. * @see https://doc.babylonjs.com/how_to/decals
  55090. */
  55091. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55092. position?: Vector3;
  55093. normal?: Vector3;
  55094. size?: Vector3;
  55095. angle?: number;
  55096. }): Mesh;
  55097. }
  55098. }
  55099. declare module "babylonjs/Meshes/meshBuilder" {
  55100. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55101. import { Nullable } from "babylonjs/types";
  55102. import { Scene } from "babylonjs/scene";
  55103. import { Mesh } from "babylonjs/Meshes/mesh";
  55104. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55105. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55107. /**
  55108. * Class containing static functions to help procedurally build meshes
  55109. */
  55110. export class MeshBuilder {
  55111. /**
  55112. * Creates a box mesh
  55113. * * The parameter `size` sets the size (float) of each box side (default 1)
  55114. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55115. * * 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)
  55116. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55120. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55121. * @param name defines the name of the mesh
  55122. * @param options defines the options used to create the mesh
  55123. * @param scene defines the hosting scene
  55124. * @returns the box mesh
  55125. */
  55126. static CreateBox(name: string, options: {
  55127. size?: number;
  55128. width?: number;
  55129. height?: number;
  55130. depth?: number;
  55131. faceUV?: Vector4[];
  55132. faceColors?: Color4[];
  55133. sideOrientation?: number;
  55134. frontUVs?: Vector4;
  55135. backUVs?: Vector4;
  55136. updatable?: boolean;
  55137. }, scene?: Nullable<Scene>): Mesh;
  55138. /**
  55139. * Creates a tiled box mesh
  55140. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55142. * @param name defines the name of the mesh
  55143. * @param options defines the options used to create the mesh
  55144. * @param scene defines the hosting scene
  55145. * @returns the tiled box mesh
  55146. */
  55147. static CreateTiledBox(name: string, options: {
  55148. pattern?: number;
  55149. size?: number;
  55150. width?: number;
  55151. height?: number;
  55152. depth: number;
  55153. tileSize?: number;
  55154. tileWidth?: number;
  55155. tileHeight?: number;
  55156. faceUV?: Vector4[];
  55157. faceColors?: Color4[];
  55158. alignHorizontal?: number;
  55159. alignVertical?: number;
  55160. sideOrientation?: number;
  55161. updatable?: boolean;
  55162. }, scene?: Nullable<Scene>): Mesh;
  55163. /**
  55164. * Creates a sphere mesh
  55165. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55166. * * 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`)
  55167. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55168. * * 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
  55169. * * 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)
  55170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55173. * @param name defines the name of the mesh
  55174. * @param options defines the options used to create the mesh
  55175. * @param scene defines the hosting scene
  55176. * @returns the sphere mesh
  55177. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55178. */
  55179. static CreateSphere(name: string, options: {
  55180. segments?: number;
  55181. diameter?: number;
  55182. diameterX?: number;
  55183. diameterY?: number;
  55184. diameterZ?: number;
  55185. arc?: number;
  55186. slice?: number;
  55187. sideOrientation?: number;
  55188. frontUVs?: Vector4;
  55189. backUVs?: Vector4;
  55190. updatable?: boolean;
  55191. }, scene?: Nullable<Scene>): Mesh;
  55192. /**
  55193. * Creates a plane polygonal mesh. By default, this is a disc
  55194. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55195. * * 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
  55196. * * 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
  55197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55200. * @param name defines the name of the mesh
  55201. * @param options defines the options used to create the mesh
  55202. * @param scene defines the hosting scene
  55203. * @returns the plane polygonal mesh
  55204. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55205. */
  55206. static CreateDisc(name: string, options: {
  55207. radius?: number;
  55208. tessellation?: number;
  55209. arc?: number;
  55210. updatable?: boolean;
  55211. sideOrientation?: number;
  55212. frontUVs?: Vector4;
  55213. backUVs?: Vector4;
  55214. }, scene?: Nullable<Scene>): Mesh;
  55215. /**
  55216. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55217. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55218. * * 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`)
  55219. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55220. * * 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
  55221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55224. * @param name defines the name of the mesh
  55225. * @param options defines the options used to create the mesh
  55226. * @param scene defines the hosting scene
  55227. * @returns the icosahedron mesh
  55228. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55229. */
  55230. static CreateIcoSphere(name: string, options: {
  55231. radius?: number;
  55232. radiusX?: number;
  55233. radiusY?: number;
  55234. radiusZ?: number;
  55235. flat?: boolean;
  55236. subdivisions?: number;
  55237. sideOrientation?: number;
  55238. frontUVs?: Vector4;
  55239. backUVs?: Vector4;
  55240. updatable?: boolean;
  55241. }, scene?: Nullable<Scene>): Mesh;
  55242. /**
  55243. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55244. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55245. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55246. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55247. * * 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
  55248. * * 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
  55249. * * 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
  55250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55252. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55253. * * 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
  55254. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55255. * * 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
  55256. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55258. * @param name defines the name of the mesh
  55259. * @param options defines the options used to create the mesh
  55260. * @param scene defines the hosting scene
  55261. * @returns the ribbon mesh
  55262. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55264. */
  55265. static CreateRibbon(name: string, options: {
  55266. pathArray: Vector3[][];
  55267. closeArray?: boolean;
  55268. closePath?: boolean;
  55269. offset?: number;
  55270. updatable?: boolean;
  55271. sideOrientation?: number;
  55272. frontUVs?: Vector4;
  55273. backUVs?: Vector4;
  55274. instance?: Mesh;
  55275. invertUV?: boolean;
  55276. uvs?: Vector2[];
  55277. colors?: Color4[];
  55278. }, scene?: Nullable<Scene>): Mesh;
  55279. /**
  55280. * Creates a cylinder or a cone mesh
  55281. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55282. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55283. * * 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.
  55284. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55285. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55286. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55287. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55288. * * 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).
  55289. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55290. * * 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).
  55291. * * 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
  55292. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55293. * * 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
  55294. * * 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.
  55295. * * If `enclose` is false, a ring surface is one element.
  55296. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55297. * * 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
  55298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55301. * @param name defines the name of the mesh
  55302. * @param options defines the options used to create the mesh
  55303. * @param scene defines the hosting scene
  55304. * @returns the cylinder mesh
  55305. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55306. */
  55307. static CreateCylinder(name: string, options: {
  55308. height?: number;
  55309. diameterTop?: number;
  55310. diameterBottom?: number;
  55311. diameter?: number;
  55312. tessellation?: number;
  55313. subdivisions?: number;
  55314. arc?: number;
  55315. faceColors?: Color4[];
  55316. faceUV?: Vector4[];
  55317. updatable?: boolean;
  55318. hasRings?: boolean;
  55319. enclose?: boolean;
  55320. cap?: number;
  55321. sideOrientation?: number;
  55322. frontUVs?: Vector4;
  55323. backUVs?: Vector4;
  55324. }, scene?: Nullable<Scene>): Mesh;
  55325. /**
  55326. * Creates a torus mesh
  55327. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55328. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55329. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55333. * @param name defines the name of the mesh
  55334. * @param options defines the options used to create the mesh
  55335. * @param scene defines the hosting scene
  55336. * @returns the torus mesh
  55337. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55338. */
  55339. static CreateTorus(name: string, options: {
  55340. diameter?: number;
  55341. thickness?: number;
  55342. tessellation?: number;
  55343. updatable?: boolean;
  55344. sideOrientation?: number;
  55345. frontUVs?: Vector4;
  55346. backUVs?: Vector4;
  55347. }, scene?: Nullable<Scene>): Mesh;
  55348. /**
  55349. * Creates a torus knot mesh
  55350. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55351. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55352. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55353. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55357. * @param name defines the name of the mesh
  55358. * @param options defines the options used to create the mesh
  55359. * @param scene defines the hosting scene
  55360. * @returns the torus knot mesh
  55361. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55362. */
  55363. static CreateTorusKnot(name: string, options: {
  55364. radius?: number;
  55365. tube?: number;
  55366. radialSegments?: number;
  55367. tubularSegments?: number;
  55368. p?: number;
  55369. q?: number;
  55370. updatable?: boolean;
  55371. sideOrientation?: number;
  55372. frontUVs?: Vector4;
  55373. backUVs?: Vector4;
  55374. }, scene?: Nullable<Scene>): Mesh;
  55375. /**
  55376. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55377. * * 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
  55378. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55379. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55380. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55381. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55382. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55383. * * 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
  55384. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55387. * @param name defines the name of the new line system
  55388. * @param options defines the options used to create the line system
  55389. * @param scene defines the hosting scene
  55390. * @returns a new line system mesh
  55391. */
  55392. static CreateLineSystem(name: string, options: {
  55393. lines: Vector3[][];
  55394. updatable?: boolean;
  55395. instance?: Nullable<LinesMesh>;
  55396. colors?: Nullable<Color4[][]>;
  55397. useVertexAlpha?: boolean;
  55398. }, scene: Nullable<Scene>): LinesMesh;
  55399. /**
  55400. * Creates a line mesh
  55401. * 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
  55402. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55403. * * The parameter `points` is an array successive Vector3
  55404. * * 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
  55405. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55406. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55407. * * When updating an instance, remember that only point positions can change, not the number of points
  55408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55410. * @param name defines the name of the new line system
  55411. * @param options defines the options used to create the line system
  55412. * @param scene defines the hosting scene
  55413. * @returns a new line mesh
  55414. */
  55415. static CreateLines(name: string, options: {
  55416. points: Vector3[];
  55417. updatable?: boolean;
  55418. instance?: Nullable<LinesMesh>;
  55419. colors?: Color4[];
  55420. useVertexAlpha?: boolean;
  55421. }, scene?: Nullable<Scene>): LinesMesh;
  55422. /**
  55423. * Creates a dashed line mesh
  55424. * * 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
  55425. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55426. * * The parameter `points` is an array successive Vector3
  55427. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55428. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55429. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55430. * * 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
  55431. * * When updating an instance, remember that only point positions can change, not the number of points
  55432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55433. * @param name defines the name of the mesh
  55434. * @param options defines the options used to create the mesh
  55435. * @param scene defines the hosting scene
  55436. * @returns the dashed line mesh
  55437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55438. */
  55439. static CreateDashedLines(name: string, options: {
  55440. points: Vector3[];
  55441. dashSize?: number;
  55442. gapSize?: number;
  55443. dashNb?: number;
  55444. updatable?: boolean;
  55445. instance?: LinesMesh;
  55446. }, scene?: Nullable<Scene>): LinesMesh;
  55447. /**
  55448. * 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.
  55449. * * 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.
  55450. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55451. * * 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.
  55452. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55453. * * 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
  55454. * * 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
  55455. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55460. * @param name defines the name of the mesh
  55461. * @param options defines the options used to create the mesh
  55462. * @param scene defines the hosting scene
  55463. * @returns the extruded shape mesh
  55464. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55466. */
  55467. static ExtrudeShape(name: string, options: {
  55468. shape: Vector3[];
  55469. path: Vector3[];
  55470. scale?: number;
  55471. rotation?: number;
  55472. cap?: number;
  55473. updatable?: boolean;
  55474. sideOrientation?: number;
  55475. frontUVs?: Vector4;
  55476. backUVs?: Vector4;
  55477. instance?: Mesh;
  55478. invertUV?: boolean;
  55479. }, scene?: Nullable<Scene>): Mesh;
  55480. /**
  55481. * Creates an custom extruded shape mesh.
  55482. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55483. * * 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.
  55484. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55485. * * 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
  55486. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55487. * * 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
  55488. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55489. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55490. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55491. * * 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
  55492. * * 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
  55493. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55498. * @param name defines the name of the mesh
  55499. * @param options defines the options used to create the mesh
  55500. * @param scene defines the hosting scene
  55501. * @returns the custom extruded shape mesh
  55502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55503. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55505. */
  55506. static ExtrudeShapeCustom(name: string, options: {
  55507. shape: Vector3[];
  55508. path: Vector3[];
  55509. scaleFunction?: any;
  55510. rotationFunction?: any;
  55511. ribbonCloseArray?: boolean;
  55512. ribbonClosePath?: boolean;
  55513. cap?: number;
  55514. updatable?: boolean;
  55515. sideOrientation?: number;
  55516. frontUVs?: Vector4;
  55517. backUVs?: Vector4;
  55518. instance?: Mesh;
  55519. invertUV?: boolean;
  55520. }, scene?: Nullable<Scene>): Mesh;
  55521. /**
  55522. * Creates lathe mesh.
  55523. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55524. * * 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
  55525. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55526. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55527. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55528. * * 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
  55529. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55530. * * 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
  55531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55535. * @param name defines the name of the mesh
  55536. * @param options defines the options used to create the mesh
  55537. * @param scene defines the hosting scene
  55538. * @returns the lathe mesh
  55539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55540. */
  55541. static CreateLathe(name: string, options: {
  55542. shape: Vector3[];
  55543. radius?: number;
  55544. tessellation?: number;
  55545. clip?: number;
  55546. arc?: number;
  55547. closed?: boolean;
  55548. updatable?: boolean;
  55549. sideOrientation?: number;
  55550. frontUVs?: Vector4;
  55551. backUVs?: Vector4;
  55552. cap?: number;
  55553. invertUV?: boolean;
  55554. }, scene?: Nullable<Scene>): Mesh;
  55555. /**
  55556. * Creates a tiled plane mesh
  55557. * * You can set a limited pattern arrangement with the tiles
  55558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55561. * @param name defines the name of the mesh
  55562. * @param options defines the options used to create the mesh
  55563. * @param scene defines the hosting scene
  55564. * @returns the plane mesh
  55565. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55566. */
  55567. static CreateTiledPlane(name: string, options: {
  55568. pattern?: number;
  55569. tileSize?: number;
  55570. tileWidth?: number;
  55571. tileHeight?: number;
  55572. size?: number;
  55573. width?: number;
  55574. height?: number;
  55575. alignHorizontal?: number;
  55576. alignVertical?: number;
  55577. sideOrientation?: number;
  55578. frontUVs?: Vector4;
  55579. backUVs?: Vector4;
  55580. updatable?: boolean;
  55581. }, scene?: Nullable<Scene>): Mesh;
  55582. /**
  55583. * Creates a plane mesh
  55584. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55585. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55586. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55590. * @param name defines the name of the mesh
  55591. * @param options defines the options used to create the mesh
  55592. * @param scene defines the hosting scene
  55593. * @returns the plane mesh
  55594. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55595. */
  55596. static CreatePlane(name: string, options: {
  55597. size?: number;
  55598. width?: number;
  55599. height?: number;
  55600. sideOrientation?: number;
  55601. frontUVs?: Vector4;
  55602. backUVs?: Vector4;
  55603. updatable?: boolean;
  55604. sourcePlane?: Plane;
  55605. }, scene?: Nullable<Scene>): Mesh;
  55606. /**
  55607. * Creates a ground mesh
  55608. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55609. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55611. * @param name defines the name of the mesh
  55612. * @param options defines the options used to create the mesh
  55613. * @param scene defines the hosting scene
  55614. * @returns the ground mesh
  55615. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55616. */
  55617. static CreateGround(name: string, options: {
  55618. width?: number;
  55619. height?: number;
  55620. subdivisions?: number;
  55621. subdivisionsX?: number;
  55622. subdivisionsY?: number;
  55623. updatable?: boolean;
  55624. }, scene?: Nullable<Scene>): Mesh;
  55625. /**
  55626. * Creates a tiled ground mesh
  55627. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55628. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55629. * * 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
  55630. * * 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
  55631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55632. * @param name defines the name of the mesh
  55633. * @param options defines the options used to create the mesh
  55634. * @param scene defines the hosting scene
  55635. * @returns the tiled ground mesh
  55636. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55637. */
  55638. static CreateTiledGround(name: string, options: {
  55639. xmin: number;
  55640. zmin: number;
  55641. xmax: number;
  55642. zmax: number;
  55643. subdivisions?: {
  55644. w: number;
  55645. h: number;
  55646. };
  55647. precision?: {
  55648. w: number;
  55649. h: number;
  55650. };
  55651. updatable?: boolean;
  55652. }, scene?: Nullable<Scene>): Mesh;
  55653. /**
  55654. * Creates a ground mesh from a height map
  55655. * * The parameter `url` sets the URL of the height map image resource.
  55656. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55657. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55658. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55659. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55660. * * 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.
  55661. * * 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).
  55662. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55664. * @param name defines the name of the mesh
  55665. * @param url defines the url to the height map
  55666. * @param options defines the options used to create the mesh
  55667. * @param scene defines the hosting scene
  55668. * @returns the ground mesh
  55669. * @see https://doc.babylonjs.com/babylon101/height_map
  55670. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55671. */
  55672. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55673. width?: number;
  55674. height?: number;
  55675. subdivisions?: number;
  55676. minHeight?: number;
  55677. maxHeight?: number;
  55678. colorFilter?: Color3;
  55679. alphaFilter?: number;
  55680. updatable?: boolean;
  55681. onReady?: (mesh: GroundMesh) => void;
  55682. }, scene?: Nullable<Scene>): GroundMesh;
  55683. /**
  55684. * Creates a polygon mesh
  55685. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55686. * * 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
  55687. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55690. * * Remember you can only change the shape positions, not their number when updating a polygon
  55691. * @param name defines the name of the mesh
  55692. * @param options defines the options used to create the mesh
  55693. * @param scene defines the hosting scene
  55694. * @param earcutInjection can be used to inject your own earcut reference
  55695. * @returns the polygon mesh
  55696. */
  55697. static CreatePolygon(name: string, options: {
  55698. shape: Vector3[];
  55699. holes?: Vector3[][];
  55700. depth?: number;
  55701. faceUV?: Vector4[];
  55702. faceColors?: Color4[];
  55703. updatable?: boolean;
  55704. sideOrientation?: number;
  55705. frontUVs?: Vector4;
  55706. backUVs?: Vector4;
  55707. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55708. /**
  55709. * Creates an extruded polygon mesh, with depth in the Y direction.
  55710. * * 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)
  55711. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55712. * @param name defines the name of the mesh
  55713. * @param options defines the options used to create the mesh
  55714. * @param scene defines the hosting scene
  55715. * @param earcutInjection can be used to inject your own earcut reference
  55716. * @returns the polygon mesh
  55717. */
  55718. static ExtrudePolygon(name: string, options: {
  55719. shape: Vector3[];
  55720. holes?: Vector3[][];
  55721. depth?: number;
  55722. faceUV?: Vector4[];
  55723. faceColors?: Color4[];
  55724. updatable?: boolean;
  55725. sideOrientation?: number;
  55726. frontUVs?: Vector4;
  55727. backUVs?: Vector4;
  55728. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55729. /**
  55730. * Creates a tube mesh.
  55731. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55732. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55733. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55734. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55735. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55736. * * 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)
  55737. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55738. * * 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
  55739. * * 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
  55740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55742. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55744. * @param name defines the name of the mesh
  55745. * @param options defines the options used to create the mesh
  55746. * @param scene defines the hosting scene
  55747. * @returns the tube mesh
  55748. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55749. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55750. */
  55751. static CreateTube(name: string, options: {
  55752. path: Vector3[];
  55753. radius?: number;
  55754. tessellation?: number;
  55755. radiusFunction?: {
  55756. (i: number, distance: number): number;
  55757. };
  55758. cap?: number;
  55759. arc?: number;
  55760. updatable?: boolean;
  55761. sideOrientation?: number;
  55762. frontUVs?: Vector4;
  55763. backUVs?: Vector4;
  55764. instance?: Mesh;
  55765. invertUV?: boolean;
  55766. }, scene?: Nullable<Scene>): Mesh;
  55767. /**
  55768. * Creates a polyhedron mesh
  55769. * * 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
  55770. * * The parameter `size` (positive float, default 1) sets the polygon size
  55771. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55772. * * 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`
  55773. * * 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
  55774. * * 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)`)
  55775. * * 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
  55776. * * 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
  55777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55780. * @param name defines the name of the mesh
  55781. * @param options defines the options used to create the mesh
  55782. * @param scene defines the hosting scene
  55783. * @returns the polyhedron mesh
  55784. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55785. */
  55786. static CreatePolyhedron(name: string, options: {
  55787. type?: number;
  55788. size?: number;
  55789. sizeX?: number;
  55790. sizeY?: number;
  55791. sizeZ?: number;
  55792. custom?: any;
  55793. faceUV?: Vector4[];
  55794. faceColors?: Color4[];
  55795. flat?: boolean;
  55796. updatable?: boolean;
  55797. sideOrientation?: number;
  55798. frontUVs?: Vector4;
  55799. backUVs?: Vector4;
  55800. }, scene?: Nullable<Scene>): Mesh;
  55801. /**
  55802. * Creates a decal mesh.
  55803. * 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
  55804. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55805. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55806. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55807. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55808. * @param name defines the name of the mesh
  55809. * @param sourceMesh defines the mesh where the decal must be applied
  55810. * @param options defines the options used to create the mesh
  55811. * @param scene defines the hosting scene
  55812. * @returns the decal mesh
  55813. * @see https://doc.babylonjs.com/how_to/decals
  55814. */
  55815. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55816. position?: Vector3;
  55817. normal?: Vector3;
  55818. size?: Vector3;
  55819. angle?: number;
  55820. }): Mesh;
  55821. }
  55822. }
  55823. declare module "babylonjs/Meshes/meshSimplification" {
  55824. import { Mesh } from "babylonjs/Meshes/mesh";
  55825. /**
  55826. * A simplifier interface for future simplification implementations
  55827. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55828. */
  55829. export interface ISimplifier {
  55830. /**
  55831. * Simplification of a given mesh according to the given settings.
  55832. * Since this requires computation, it is assumed that the function runs async.
  55833. * @param settings The settings of the simplification, including quality and distance
  55834. * @param successCallback A callback that will be called after the mesh was simplified.
  55835. * @param errorCallback in case of an error, this callback will be called. optional.
  55836. */
  55837. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55838. }
  55839. /**
  55840. * Expected simplification settings.
  55841. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55843. */
  55844. export interface ISimplificationSettings {
  55845. /**
  55846. * Gets or sets the expected quality
  55847. */
  55848. quality: number;
  55849. /**
  55850. * Gets or sets the distance when this optimized version should be used
  55851. */
  55852. distance: number;
  55853. /**
  55854. * Gets an already optimized mesh
  55855. */
  55856. optimizeMesh?: boolean;
  55857. }
  55858. /**
  55859. * Class used to specify simplification options
  55860. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55861. */
  55862. export class SimplificationSettings implements ISimplificationSettings {
  55863. /** expected quality */
  55864. quality: number;
  55865. /** distance when this optimized version should be used */
  55866. distance: number;
  55867. /** already optimized mesh */
  55868. optimizeMesh?: boolean | undefined;
  55869. /**
  55870. * Creates a SimplificationSettings
  55871. * @param quality expected quality
  55872. * @param distance distance when this optimized version should be used
  55873. * @param optimizeMesh already optimized mesh
  55874. */
  55875. constructor(
  55876. /** expected quality */
  55877. quality: number,
  55878. /** distance when this optimized version should be used */
  55879. distance: number,
  55880. /** already optimized mesh */
  55881. optimizeMesh?: boolean | undefined);
  55882. }
  55883. /**
  55884. * Interface used to define a simplification task
  55885. */
  55886. export interface ISimplificationTask {
  55887. /**
  55888. * Array of settings
  55889. */
  55890. settings: Array<ISimplificationSettings>;
  55891. /**
  55892. * Simplification type
  55893. */
  55894. simplificationType: SimplificationType;
  55895. /**
  55896. * Mesh to simplify
  55897. */
  55898. mesh: Mesh;
  55899. /**
  55900. * Callback called on success
  55901. */
  55902. successCallback?: () => void;
  55903. /**
  55904. * Defines if parallel processing can be used
  55905. */
  55906. parallelProcessing: boolean;
  55907. }
  55908. /**
  55909. * Queue used to order the simplification tasks
  55910. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55911. */
  55912. export class SimplificationQueue {
  55913. private _simplificationArray;
  55914. /**
  55915. * Gets a boolean indicating that the process is still running
  55916. */
  55917. running: boolean;
  55918. /**
  55919. * Creates a new queue
  55920. */
  55921. constructor();
  55922. /**
  55923. * Adds a new simplification task
  55924. * @param task defines a task to add
  55925. */
  55926. addTask(task: ISimplificationTask): void;
  55927. /**
  55928. * Execute next task
  55929. */
  55930. executeNext(): void;
  55931. /**
  55932. * Execute a simplification task
  55933. * @param task defines the task to run
  55934. */
  55935. runSimplification(task: ISimplificationTask): void;
  55936. private getSimplifier;
  55937. }
  55938. /**
  55939. * The implemented types of simplification
  55940. * At the moment only Quadratic Error Decimation is implemented
  55941. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55942. */
  55943. export enum SimplificationType {
  55944. /** Quadratic error decimation */
  55945. QUADRATIC = 0
  55946. }
  55947. }
  55948. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  55949. import { Scene } from "babylonjs/scene";
  55950. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  55951. import { ISceneComponent } from "babylonjs/sceneComponent";
  55952. module "babylonjs/scene" {
  55953. interface Scene {
  55954. /** @hidden (Backing field) */
  55955. _simplificationQueue: SimplificationQueue;
  55956. /**
  55957. * Gets or sets the simplification queue attached to the scene
  55958. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55959. */
  55960. simplificationQueue: SimplificationQueue;
  55961. }
  55962. }
  55963. module "babylonjs/Meshes/mesh" {
  55964. interface Mesh {
  55965. /**
  55966. * Simplify the mesh according to the given array of settings.
  55967. * Function will return immediately and will simplify async
  55968. * @param settings a collection of simplification settings
  55969. * @param parallelProcessing should all levels calculate parallel or one after the other
  55970. * @param simplificationType the type of simplification to run
  55971. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55972. * @returns the current mesh
  55973. */
  55974. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55975. }
  55976. }
  55977. /**
  55978. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55979. * created in a scene
  55980. */
  55981. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55982. /**
  55983. * The component name helpfull to identify the component in the list of scene components.
  55984. */
  55985. readonly name: string;
  55986. /**
  55987. * The scene the component belongs to.
  55988. */
  55989. scene: Scene;
  55990. /**
  55991. * Creates a new instance of the component for the given scene
  55992. * @param scene Defines the scene to register the component in
  55993. */
  55994. constructor(scene: Scene);
  55995. /**
  55996. * Registers the component in a given scene
  55997. */
  55998. register(): void;
  55999. /**
  56000. * Rebuilds the elements related to this component in case of
  56001. * context lost for instance.
  56002. */
  56003. rebuild(): void;
  56004. /**
  56005. * Disposes the component and the associated ressources
  56006. */
  56007. dispose(): void;
  56008. private _beforeCameraUpdate;
  56009. }
  56010. }
  56011. declare module "babylonjs/Meshes/Builders/index" {
  56012. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56013. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56014. export * from "babylonjs/Meshes/Builders/discBuilder";
  56015. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56016. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56017. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56018. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56019. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56020. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56021. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56022. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56023. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56024. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56025. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56026. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56027. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56028. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56029. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56030. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56031. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56032. }
  56033. declare module "babylonjs/Meshes/index" {
  56034. export * from "babylonjs/Meshes/abstractMesh";
  56035. export * from "babylonjs/Meshes/buffer";
  56036. export * from "babylonjs/Meshes/Compression/index";
  56037. export * from "babylonjs/Meshes/csg";
  56038. export * from "babylonjs/Meshes/geometry";
  56039. export * from "babylonjs/Meshes/groundMesh";
  56040. export * from "babylonjs/Meshes/trailMesh";
  56041. export * from "babylonjs/Meshes/instancedMesh";
  56042. export * from "babylonjs/Meshes/linesMesh";
  56043. export * from "babylonjs/Meshes/mesh";
  56044. export * from "babylonjs/Meshes/mesh.vertexData";
  56045. export * from "babylonjs/Meshes/meshBuilder";
  56046. export * from "babylonjs/Meshes/meshSimplification";
  56047. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56048. export * from "babylonjs/Meshes/polygonMesh";
  56049. export * from "babylonjs/Meshes/subMesh";
  56050. export * from "babylonjs/Meshes/meshLODLevel";
  56051. export * from "babylonjs/Meshes/transformNode";
  56052. export * from "babylonjs/Meshes/Builders/index";
  56053. export * from "babylonjs/Meshes/dataBuffer";
  56054. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56055. }
  56056. declare module "babylonjs/Morph/index" {
  56057. export * from "babylonjs/Morph/morphTarget";
  56058. export * from "babylonjs/Morph/morphTargetManager";
  56059. }
  56060. declare module "babylonjs/Offline/database" {
  56061. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56062. /**
  56063. * Class used to enable access to IndexedDB
  56064. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56065. */
  56066. export class Database implements IOfflineProvider {
  56067. private _callbackManifestChecked;
  56068. private _currentSceneUrl;
  56069. private _db;
  56070. private _enableSceneOffline;
  56071. private _enableTexturesOffline;
  56072. private _manifestVersionFound;
  56073. private _mustUpdateRessources;
  56074. private _hasReachedQuota;
  56075. private _isSupported;
  56076. private _idbFactory;
  56077. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56078. private static IsUASupportingBlobStorage;
  56079. /**
  56080. * Gets a boolean indicating if Database storate is enabled (off by default)
  56081. */
  56082. static IDBStorageEnabled: boolean;
  56083. /**
  56084. * Gets a boolean indicating if scene must be saved in the database
  56085. */
  56086. readonly enableSceneOffline: boolean;
  56087. /**
  56088. * Gets a boolean indicating if textures must be saved in the database
  56089. */
  56090. readonly enableTexturesOffline: boolean;
  56091. /**
  56092. * Creates a new Database
  56093. * @param urlToScene defines the url to load the scene
  56094. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56095. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56096. */
  56097. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56098. private static _ParseURL;
  56099. private static _ReturnFullUrlLocation;
  56100. private _checkManifestFile;
  56101. /**
  56102. * Open the database and make it available
  56103. * @param successCallback defines the callback to call on success
  56104. * @param errorCallback defines the callback to call on error
  56105. */
  56106. open(successCallback: () => void, errorCallback: () => void): void;
  56107. /**
  56108. * Loads an image from the database
  56109. * @param url defines the url to load from
  56110. * @param image defines the target DOM image
  56111. */
  56112. loadImage(url: string, image: HTMLImageElement): void;
  56113. private _loadImageFromDBAsync;
  56114. private _saveImageIntoDBAsync;
  56115. private _checkVersionFromDB;
  56116. private _loadVersionFromDBAsync;
  56117. private _saveVersionIntoDBAsync;
  56118. /**
  56119. * Loads a file from database
  56120. * @param url defines the URL to load from
  56121. * @param sceneLoaded defines a callback to call on success
  56122. * @param progressCallBack defines a callback to call when progress changed
  56123. * @param errorCallback defines a callback to call on error
  56124. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56125. */
  56126. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56127. private _loadFileAsync;
  56128. private _saveFileAsync;
  56129. /**
  56130. * Validates if xhr data is correct
  56131. * @param xhr defines the request to validate
  56132. * @param dataType defines the expected data type
  56133. * @returns true if data is correct
  56134. */
  56135. private static _ValidateXHRData;
  56136. }
  56137. }
  56138. declare module "babylonjs/Offline/index" {
  56139. export * from "babylonjs/Offline/database";
  56140. export * from "babylonjs/Offline/IOfflineProvider";
  56141. }
  56142. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56143. /** @hidden */
  56144. export var gpuUpdateParticlesPixelShader: {
  56145. name: string;
  56146. shader: string;
  56147. };
  56148. }
  56149. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56150. /** @hidden */
  56151. export var gpuUpdateParticlesVertexShader: {
  56152. name: string;
  56153. shader: string;
  56154. };
  56155. }
  56156. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56157. /** @hidden */
  56158. export var clipPlaneFragmentDeclaration2: {
  56159. name: string;
  56160. shader: string;
  56161. };
  56162. }
  56163. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56164. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56165. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56166. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56167. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56168. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56169. /** @hidden */
  56170. export var gpuRenderParticlesPixelShader: {
  56171. name: string;
  56172. shader: string;
  56173. };
  56174. }
  56175. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56176. /** @hidden */
  56177. export var clipPlaneVertexDeclaration2: {
  56178. name: string;
  56179. shader: string;
  56180. };
  56181. }
  56182. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56183. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56184. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56185. /** @hidden */
  56186. export var gpuRenderParticlesVertexShader: {
  56187. name: string;
  56188. shader: string;
  56189. };
  56190. }
  56191. declare module "babylonjs/Particles/gpuParticleSystem" {
  56192. import { Nullable } from "babylonjs/types";
  56193. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56194. import { Observable } from "babylonjs/Misc/observable";
  56195. import { Color4, Color3 } from "babylonjs/Maths/math";
  56196. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56197. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56198. import { Scene, IDisposable } from "babylonjs/scene";
  56199. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56200. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56201. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56202. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56203. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56204. /**
  56205. * This represents a GPU particle system in Babylon
  56206. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56207. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56208. */
  56209. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56210. /**
  56211. * The layer mask we are rendering the particles through.
  56212. */
  56213. layerMask: number;
  56214. private _capacity;
  56215. private _activeCount;
  56216. private _currentActiveCount;
  56217. private _accumulatedCount;
  56218. private _renderEffect;
  56219. private _updateEffect;
  56220. private _buffer0;
  56221. private _buffer1;
  56222. private _spriteBuffer;
  56223. private _updateVAO;
  56224. private _renderVAO;
  56225. private _targetIndex;
  56226. private _sourceBuffer;
  56227. private _targetBuffer;
  56228. private _engine;
  56229. private _currentRenderId;
  56230. private _started;
  56231. private _stopped;
  56232. private _timeDelta;
  56233. private _randomTexture;
  56234. private _randomTexture2;
  56235. private _attributesStrideSize;
  56236. private _updateEffectOptions;
  56237. private _randomTextureSize;
  56238. private _actualFrame;
  56239. private readonly _rawTextureWidth;
  56240. /**
  56241. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56242. */
  56243. static readonly IsSupported: boolean;
  56244. /**
  56245. * An event triggered when the system is disposed.
  56246. */
  56247. onDisposeObservable: Observable<GPUParticleSystem>;
  56248. /**
  56249. * Gets the maximum number of particles active at the same time.
  56250. * @returns The max number of active particles.
  56251. */
  56252. getCapacity(): number;
  56253. /**
  56254. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56255. * to override the particles.
  56256. */
  56257. forceDepthWrite: boolean;
  56258. /**
  56259. * Gets or set the number of active particles
  56260. */
  56261. activeParticleCount: number;
  56262. private _preWarmDone;
  56263. /**
  56264. * Is this system ready to be used/rendered
  56265. * @return true if the system is ready
  56266. */
  56267. isReady(): boolean;
  56268. /**
  56269. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56270. * @returns True if it has been started, otherwise false.
  56271. */
  56272. isStarted(): boolean;
  56273. /**
  56274. * Starts the particle system and begins to emit
  56275. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56276. */
  56277. start(delay?: number): void;
  56278. /**
  56279. * Stops the particle system.
  56280. */
  56281. stop(): void;
  56282. /**
  56283. * Remove all active particles
  56284. */
  56285. reset(): void;
  56286. /**
  56287. * Returns the string "GPUParticleSystem"
  56288. * @returns a string containing the class name
  56289. */
  56290. getClassName(): string;
  56291. private _colorGradientsTexture;
  56292. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56293. /**
  56294. * Adds a new color gradient
  56295. * @param gradient defines the gradient to use (between 0 and 1)
  56296. * @param color1 defines the color to affect to the specified gradient
  56297. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56298. * @returns the current particle system
  56299. */
  56300. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56301. /**
  56302. * Remove a specific color gradient
  56303. * @param gradient defines the gradient to remove
  56304. * @returns the current particle system
  56305. */
  56306. removeColorGradient(gradient: number): GPUParticleSystem;
  56307. private _angularSpeedGradientsTexture;
  56308. private _sizeGradientsTexture;
  56309. private _velocityGradientsTexture;
  56310. private _limitVelocityGradientsTexture;
  56311. private _dragGradientsTexture;
  56312. private _addFactorGradient;
  56313. /**
  56314. * Adds a new size gradient
  56315. * @param gradient defines the gradient to use (between 0 and 1)
  56316. * @param factor defines the size factor to affect to the specified gradient
  56317. * @returns the current particle system
  56318. */
  56319. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56320. /**
  56321. * Remove a specific size gradient
  56322. * @param gradient defines the gradient to remove
  56323. * @returns the current particle system
  56324. */
  56325. removeSizeGradient(gradient: number): GPUParticleSystem;
  56326. /**
  56327. * Adds a new angular speed gradient
  56328. * @param gradient defines the gradient to use (between 0 and 1)
  56329. * @param factor defines the angular speed to affect to the specified gradient
  56330. * @returns the current particle system
  56331. */
  56332. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56333. /**
  56334. * Remove a specific angular speed gradient
  56335. * @param gradient defines the gradient to remove
  56336. * @returns the current particle system
  56337. */
  56338. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56339. /**
  56340. * Adds a new velocity gradient
  56341. * @param gradient defines the gradient to use (between 0 and 1)
  56342. * @param factor defines the velocity to affect to the specified gradient
  56343. * @returns the current particle system
  56344. */
  56345. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56346. /**
  56347. * Remove a specific velocity gradient
  56348. * @param gradient defines the gradient to remove
  56349. * @returns the current particle system
  56350. */
  56351. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56352. /**
  56353. * Adds a new limit velocity gradient
  56354. * @param gradient defines the gradient to use (between 0 and 1)
  56355. * @param factor defines the limit velocity value to affect to the specified gradient
  56356. * @returns the current particle system
  56357. */
  56358. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56359. /**
  56360. * Remove a specific limit velocity gradient
  56361. * @param gradient defines the gradient to remove
  56362. * @returns the current particle system
  56363. */
  56364. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56365. /**
  56366. * Adds a new drag gradient
  56367. * @param gradient defines the gradient to use (between 0 and 1)
  56368. * @param factor defines the drag value to affect to the specified gradient
  56369. * @returns the current particle system
  56370. */
  56371. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56372. /**
  56373. * Remove a specific drag gradient
  56374. * @param gradient defines the gradient to remove
  56375. * @returns the current particle system
  56376. */
  56377. removeDragGradient(gradient: number): GPUParticleSystem;
  56378. /**
  56379. * Not supported by GPUParticleSystem
  56380. * @param gradient defines the gradient to use (between 0 and 1)
  56381. * @param factor defines the emit rate value to affect to the specified gradient
  56382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56383. * @returns the current particle system
  56384. */
  56385. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56386. /**
  56387. * Not supported by GPUParticleSystem
  56388. * @param gradient defines the gradient to remove
  56389. * @returns the current particle system
  56390. */
  56391. removeEmitRateGradient(gradient: number): IParticleSystem;
  56392. /**
  56393. * Not supported by GPUParticleSystem
  56394. * @param gradient defines the gradient to use (between 0 and 1)
  56395. * @param factor defines the start size value to affect to the specified gradient
  56396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56397. * @returns the current particle system
  56398. */
  56399. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56400. /**
  56401. * Not supported by GPUParticleSystem
  56402. * @param gradient defines the gradient to remove
  56403. * @returns the current particle system
  56404. */
  56405. removeStartSizeGradient(gradient: number): IParticleSystem;
  56406. /**
  56407. * Not supported by GPUParticleSystem
  56408. * @param gradient defines the gradient to use (between 0 and 1)
  56409. * @param min defines the color remap minimal range
  56410. * @param max defines the color remap maximal range
  56411. * @returns the current particle system
  56412. */
  56413. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56414. /**
  56415. * Not supported by GPUParticleSystem
  56416. * @param gradient defines the gradient to remove
  56417. * @returns the current particle system
  56418. */
  56419. removeColorRemapGradient(): IParticleSystem;
  56420. /**
  56421. * Not supported by GPUParticleSystem
  56422. * @param gradient defines the gradient to use (between 0 and 1)
  56423. * @param min defines the alpha remap minimal range
  56424. * @param max defines the alpha remap maximal range
  56425. * @returns the current particle system
  56426. */
  56427. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56428. /**
  56429. * Not supported by GPUParticleSystem
  56430. * @param gradient defines the gradient to remove
  56431. * @returns the current particle system
  56432. */
  56433. removeAlphaRemapGradient(): IParticleSystem;
  56434. /**
  56435. * Not supported by GPUParticleSystem
  56436. * @param gradient defines the gradient to use (between 0 and 1)
  56437. * @param color defines the color to affect to the specified gradient
  56438. * @returns the current particle system
  56439. */
  56440. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56441. /**
  56442. * Not supported by GPUParticleSystem
  56443. * @param gradient defines the gradient to remove
  56444. * @returns the current particle system
  56445. */
  56446. removeRampGradient(): IParticleSystem;
  56447. /**
  56448. * Not supported by GPUParticleSystem
  56449. * @returns the list of ramp gradients
  56450. */
  56451. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56452. /**
  56453. * Not supported by GPUParticleSystem
  56454. * Gets or sets a boolean indicating that ramp gradients must be used
  56455. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56456. */
  56457. useRampGradients: boolean;
  56458. /**
  56459. * Not supported by GPUParticleSystem
  56460. * @param gradient defines the gradient to use (between 0 and 1)
  56461. * @param factor defines the life time factor to affect to the specified gradient
  56462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56463. * @returns the current particle system
  56464. */
  56465. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56466. /**
  56467. * Not supported by GPUParticleSystem
  56468. * @param gradient defines the gradient to remove
  56469. * @returns the current particle system
  56470. */
  56471. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56472. /**
  56473. * Instantiates a GPU particle system.
  56474. * 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.
  56475. * @param name The name of the particle system
  56476. * @param options The options used to create the system
  56477. * @param scene The scene the particle system belongs to
  56478. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56479. */
  56480. constructor(name: string, options: Partial<{
  56481. capacity: number;
  56482. randomTextureSize: number;
  56483. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56484. protected _reset(): void;
  56485. private _createUpdateVAO;
  56486. private _createRenderVAO;
  56487. private _initialize;
  56488. /** @hidden */
  56489. _recreateUpdateEffect(): void;
  56490. /** @hidden */
  56491. _recreateRenderEffect(): void;
  56492. /**
  56493. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56494. * @param preWarm defines if we are in the pre-warmimg phase
  56495. */
  56496. animate(preWarm?: boolean): void;
  56497. private _createFactorGradientTexture;
  56498. private _createSizeGradientTexture;
  56499. private _createAngularSpeedGradientTexture;
  56500. private _createVelocityGradientTexture;
  56501. private _createLimitVelocityGradientTexture;
  56502. private _createDragGradientTexture;
  56503. private _createColorGradientTexture;
  56504. /**
  56505. * Renders the particle system in its current state
  56506. * @param preWarm defines if the system should only update the particles but not render them
  56507. * @returns the current number of particles
  56508. */
  56509. render(preWarm?: boolean): number;
  56510. /**
  56511. * Rebuilds the particle system
  56512. */
  56513. rebuild(): void;
  56514. private _releaseBuffers;
  56515. private _releaseVAOs;
  56516. /**
  56517. * Disposes the particle system and free the associated resources
  56518. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56519. */
  56520. dispose(disposeTexture?: boolean): void;
  56521. /**
  56522. * Clones the particle system.
  56523. * @param name The name of the cloned object
  56524. * @param newEmitter The new emitter to use
  56525. * @returns the cloned particle system
  56526. */
  56527. clone(name: string, newEmitter: any): GPUParticleSystem;
  56528. /**
  56529. * Serializes the particle system to a JSON object.
  56530. * @returns the JSON object
  56531. */
  56532. serialize(): any;
  56533. /**
  56534. * Parses a JSON object to create a GPU particle system.
  56535. * @param parsedParticleSystem The JSON object to parse
  56536. * @param scene The scene to create the particle system in
  56537. * @param rootUrl The root url to use to load external dependencies like texture
  56538. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56539. * @returns the parsed GPU particle system
  56540. */
  56541. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56542. }
  56543. }
  56544. declare module "babylonjs/Particles/particleSystemSet" {
  56545. import { Nullable } from "babylonjs/types";
  56546. import { Color3 } from "babylonjs/Maths/math";
  56547. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56549. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56550. import { Scene, IDisposable } from "babylonjs/scene";
  56551. /**
  56552. * Represents a set of particle systems working together to create a specific effect
  56553. */
  56554. export class ParticleSystemSet implements IDisposable {
  56555. private _emitterCreationOptions;
  56556. private _emitterNode;
  56557. /**
  56558. * Gets the particle system list
  56559. */
  56560. systems: IParticleSystem[];
  56561. /**
  56562. * Gets the emitter node used with this set
  56563. */
  56564. readonly emitterNode: Nullable<TransformNode>;
  56565. /**
  56566. * Creates a new emitter mesh as a sphere
  56567. * @param options defines the options used to create the sphere
  56568. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56569. * @param scene defines the hosting scene
  56570. */
  56571. setEmitterAsSphere(options: {
  56572. diameter: number;
  56573. segments: number;
  56574. color: Color3;
  56575. }, renderingGroupId: number, scene: Scene): void;
  56576. /**
  56577. * Starts all particle systems of the set
  56578. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56579. */
  56580. start(emitter?: AbstractMesh): void;
  56581. /**
  56582. * Release all associated resources
  56583. */
  56584. dispose(): void;
  56585. /**
  56586. * Serialize the set into a JSON compatible object
  56587. * @returns a JSON compatible representation of the set
  56588. */
  56589. serialize(): any;
  56590. /**
  56591. * Parse a new ParticleSystemSet from a serialized source
  56592. * @param data defines a JSON compatible representation of the set
  56593. * @param scene defines the hosting scene
  56594. * @param gpu defines if we want GPU particles or CPU particles
  56595. * @returns a new ParticleSystemSet
  56596. */
  56597. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56598. }
  56599. }
  56600. declare module "babylonjs/Particles/particleHelper" {
  56601. import { Nullable } from "babylonjs/types";
  56602. import { Scene } from "babylonjs/scene";
  56603. import { Vector3 } from "babylonjs/Maths/math";
  56604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56605. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56606. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56607. /**
  56608. * This class is made for on one-liner static method to help creating particle system set.
  56609. */
  56610. export class ParticleHelper {
  56611. /**
  56612. * Gets or sets base Assets URL
  56613. */
  56614. static BaseAssetsUrl: string;
  56615. /**
  56616. * Create a default particle system that you can tweak
  56617. * @param emitter defines the emitter to use
  56618. * @param capacity defines the system capacity (default is 500 particles)
  56619. * @param scene defines the hosting scene
  56620. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56621. * @returns the new Particle system
  56622. */
  56623. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56624. /**
  56625. * This is the main static method (one-liner) of this helper to create different particle systems
  56626. * @param type This string represents the type to the particle system to create
  56627. * @param scene The scene where the particle system should live
  56628. * @param gpu If the system will use gpu
  56629. * @returns the ParticleSystemSet created
  56630. */
  56631. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56632. /**
  56633. * Static function used to export a particle system to a ParticleSystemSet variable.
  56634. * Please note that the emitter shape is not exported
  56635. * @param systems defines the particle systems to export
  56636. * @returns the created particle system set
  56637. */
  56638. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56639. }
  56640. }
  56641. declare module "babylonjs/Particles/particleSystemComponent" {
  56642. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56643. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  56644. import "babylonjs/Shaders/particles.vertex";
  56645. module "babylonjs/Engines/engine" {
  56646. interface Engine {
  56647. /**
  56648. * Create an effect to use with particle systems.
  56649. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56650. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56651. * @param uniformsNames defines a list of attribute names
  56652. * @param samplers defines an array of string used to represent textures
  56653. * @param defines defines the string containing the defines to use to compile the shaders
  56654. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56655. * @param onCompiled defines a function to call when the effect creation is successful
  56656. * @param onError defines a function to call when the effect creation has failed
  56657. * @returns the new Effect
  56658. */
  56659. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56660. }
  56661. }
  56662. module "babylonjs/Meshes/mesh" {
  56663. interface Mesh {
  56664. /**
  56665. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56666. * @returns an array of IParticleSystem
  56667. */
  56668. getEmittedParticleSystems(): IParticleSystem[];
  56669. /**
  56670. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56671. * @returns an array of IParticleSystem
  56672. */
  56673. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56674. }
  56675. }
  56676. /**
  56677. * @hidden
  56678. */
  56679. export var _IDoNeedToBeInTheBuild: number;
  56680. }
  56681. declare module "babylonjs/Particles/index" {
  56682. export * from "babylonjs/Particles/baseParticleSystem";
  56683. export * from "babylonjs/Particles/EmitterTypes/index";
  56684. export * from "babylonjs/Particles/gpuParticleSystem";
  56685. export * from "babylonjs/Particles/IParticleSystem";
  56686. export * from "babylonjs/Particles/particle";
  56687. export * from "babylonjs/Particles/particleHelper";
  56688. export * from "babylonjs/Particles/particleSystem";
  56689. export * from "babylonjs/Particles/particleSystemComponent";
  56690. export * from "babylonjs/Particles/particleSystemSet";
  56691. export * from "babylonjs/Particles/solidParticle";
  56692. export * from "babylonjs/Particles/solidParticleSystem";
  56693. export * from "babylonjs/Particles/subEmitter";
  56694. }
  56695. declare module "babylonjs/Physics/physicsEngineComponent" {
  56696. import { Nullable } from "babylonjs/types";
  56697. import { Observable, Observer } from "babylonjs/Misc/observable";
  56698. import { Vector3 } from "babylonjs/Maths/math";
  56699. import { Mesh } from "babylonjs/Meshes/mesh";
  56700. import { ISceneComponent } from "babylonjs/sceneComponent";
  56701. import { Scene } from "babylonjs/scene";
  56702. import { Node } from "babylonjs/node";
  56703. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56704. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56705. module "babylonjs/scene" {
  56706. interface Scene {
  56707. /** @hidden (Backing field) */
  56708. _physicsEngine: Nullable<IPhysicsEngine>;
  56709. /**
  56710. * Gets the current physics engine
  56711. * @returns a IPhysicsEngine or null if none attached
  56712. */
  56713. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56714. /**
  56715. * Enables physics to the current scene
  56716. * @param gravity defines the scene's gravity for the physics engine
  56717. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56718. * @return a boolean indicating if the physics engine was initialized
  56719. */
  56720. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56721. /**
  56722. * Disables and disposes the physics engine associated with the scene
  56723. */
  56724. disablePhysicsEngine(): void;
  56725. /**
  56726. * Gets a boolean indicating if there is an active physics engine
  56727. * @returns a boolean indicating if there is an active physics engine
  56728. */
  56729. isPhysicsEnabled(): boolean;
  56730. /**
  56731. * Deletes a physics compound impostor
  56732. * @param compound defines the compound to delete
  56733. */
  56734. deleteCompoundImpostor(compound: any): void;
  56735. /**
  56736. * An event triggered when physic simulation is about to be run
  56737. */
  56738. onBeforePhysicsObservable: Observable<Scene>;
  56739. /**
  56740. * An event triggered when physic simulation has been done
  56741. */
  56742. onAfterPhysicsObservable: Observable<Scene>;
  56743. }
  56744. }
  56745. module "babylonjs/Meshes/abstractMesh" {
  56746. interface AbstractMesh {
  56747. /** @hidden */
  56748. _physicsImpostor: Nullable<PhysicsImpostor>;
  56749. /**
  56750. * Gets or sets impostor used for physic simulation
  56751. * @see http://doc.babylonjs.com/features/physics_engine
  56752. */
  56753. physicsImpostor: Nullable<PhysicsImpostor>;
  56754. /**
  56755. * Gets the current physics impostor
  56756. * @see http://doc.babylonjs.com/features/physics_engine
  56757. * @returns a physics impostor or null
  56758. */
  56759. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56760. /** Apply a physic impulse to the mesh
  56761. * @param force defines the force to apply
  56762. * @param contactPoint defines where to apply the force
  56763. * @returns the current mesh
  56764. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56765. */
  56766. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56767. /**
  56768. * Creates a physic joint between two meshes
  56769. * @param otherMesh defines the other mesh to use
  56770. * @param pivot1 defines the pivot to use on this mesh
  56771. * @param pivot2 defines the pivot to use on the other mesh
  56772. * @param options defines additional options (can be plugin dependent)
  56773. * @returns the current mesh
  56774. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56775. */
  56776. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56777. /** @hidden */
  56778. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56779. }
  56780. }
  56781. /**
  56782. * Defines the physics engine scene component responsible to manage a physics engine
  56783. */
  56784. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56785. /**
  56786. * The component name helpful to identify the component in the list of scene components.
  56787. */
  56788. readonly name: string;
  56789. /**
  56790. * The scene the component belongs to.
  56791. */
  56792. scene: Scene;
  56793. /**
  56794. * Creates a new instance of the component for the given scene
  56795. * @param scene Defines the scene to register the component in
  56796. */
  56797. constructor(scene: Scene);
  56798. /**
  56799. * Registers the component in a given scene
  56800. */
  56801. register(): void;
  56802. /**
  56803. * Rebuilds the elements related to this component in case of
  56804. * context lost for instance.
  56805. */
  56806. rebuild(): void;
  56807. /**
  56808. * Disposes the component and the associated ressources
  56809. */
  56810. dispose(): void;
  56811. }
  56812. }
  56813. declare module "babylonjs/Physics/physicsHelper" {
  56814. import { Nullable } from "babylonjs/types";
  56815. import { Vector3 } from "babylonjs/Maths/math";
  56816. import { Mesh } from "babylonjs/Meshes/mesh";
  56817. import { Scene } from "babylonjs/scene";
  56818. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56819. /**
  56820. * A helper for physics simulations
  56821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56822. */
  56823. export class PhysicsHelper {
  56824. private _scene;
  56825. private _physicsEngine;
  56826. /**
  56827. * Initializes the Physics helper
  56828. * @param scene Babylon.js scene
  56829. */
  56830. constructor(scene: Scene);
  56831. /**
  56832. * Applies a radial explosion impulse
  56833. * @param origin the origin of the explosion
  56834. * @param radiusOrEventOptions the radius or the options of radial explosion
  56835. * @param strength the explosion strength
  56836. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56837. * @returns A physics radial explosion event, or null
  56838. */
  56839. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56840. /**
  56841. * Applies a radial explosion force
  56842. * @param origin the origin of the explosion
  56843. * @param radiusOrEventOptions the radius or the options of radial explosion
  56844. * @param strength the explosion strength
  56845. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56846. * @returns A physics radial explosion event, or null
  56847. */
  56848. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56849. /**
  56850. * Creates a gravitational field
  56851. * @param origin the origin of the explosion
  56852. * @param radiusOrEventOptions the radius or the options of radial explosion
  56853. * @param strength the explosion strength
  56854. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56855. * @returns A physics gravitational field event, or null
  56856. */
  56857. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56858. /**
  56859. * Creates a physics updraft event
  56860. * @param origin the origin of the updraft
  56861. * @param radiusOrEventOptions the radius or the options of the updraft
  56862. * @param strength the strength of the updraft
  56863. * @param height the height of the updraft
  56864. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56865. * @returns A physics updraft event, or null
  56866. */
  56867. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56868. /**
  56869. * Creates a physics vortex event
  56870. * @param origin the of the vortex
  56871. * @param radiusOrEventOptions the radius or the options of the vortex
  56872. * @param strength the strength of the vortex
  56873. * @param height the height of the vortex
  56874. * @returns a Physics vortex event, or null
  56875. * A physics vortex event or null
  56876. */
  56877. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56878. }
  56879. /**
  56880. * Represents a physics radial explosion event
  56881. */
  56882. class PhysicsRadialExplosionEvent {
  56883. private _scene;
  56884. private _options;
  56885. private _sphere;
  56886. private _dataFetched;
  56887. /**
  56888. * Initializes a radial explosioin event
  56889. * @param _scene BabylonJS scene
  56890. * @param _options The options for the vortex event
  56891. */
  56892. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56893. /**
  56894. * Returns the data related to the radial explosion event (sphere).
  56895. * @returns The radial explosion event data
  56896. */
  56897. getData(): PhysicsRadialExplosionEventData;
  56898. /**
  56899. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56900. * @param impostor A physics imposter
  56901. * @param origin the origin of the explosion
  56902. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56903. */
  56904. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56905. /**
  56906. * Triggers affecterd impostors callbacks
  56907. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56908. */
  56909. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56910. /**
  56911. * Disposes the sphere.
  56912. * @param force Specifies if the sphere should be disposed by force
  56913. */
  56914. dispose(force?: boolean): void;
  56915. /*** Helpers ***/
  56916. private _prepareSphere;
  56917. private _intersectsWithSphere;
  56918. }
  56919. /**
  56920. * Represents a gravitational field event
  56921. */
  56922. class PhysicsGravitationalFieldEvent {
  56923. private _physicsHelper;
  56924. private _scene;
  56925. private _origin;
  56926. private _options;
  56927. private _tickCallback;
  56928. private _sphere;
  56929. private _dataFetched;
  56930. /**
  56931. * Initializes the physics gravitational field event
  56932. * @param _physicsHelper A physics helper
  56933. * @param _scene BabylonJS scene
  56934. * @param _origin The origin position of the gravitational field event
  56935. * @param _options The options for the vortex event
  56936. */
  56937. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56938. /**
  56939. * Returns the data related to the gravitational field event (sphere).
  56940. * @returns A gravitational field event
  56941. */
  56942. getData(): PhysicsGravitationalFieldEventData;
  56943. /**
  56944. * Enables the gravitational field.
  56945. */
  56946. enable(): void;
  56947. /**
  56948. * Disables the gravitational field.
  56949. */
  56950. disable(): void;
  56951. /**
  56952. * Disposes the sphere.
  56953. * @param force The force to dispose from the gravitational field event
  56954. */
  56955. dispose(force?: boolean): void;
  56956. private _tick;
  56957. }
  56958. /**
  56959. * Represents a physics updraft event
  56960. */
  56961. class PhysicsUpdraftEvent {
  56962. private _scene;
  56963. private _origin;
  56964. private _options;
  56965. private _physicsEngine;
  56966. private _originTop;
  56967. private _originDirection;
  56968. private _tickCallback;
  56969. private _cylinder;
  56970. private _cylinderPosition;
  56971. private _dataFetched;
  56972. /**
  56973. * Initializes the physics updraft event
  56974. * @param _scene BabylonJS scene
  56975. * @param _origin The origin position of the updraft
  56976. * @param _options The options for the updraft event
  56977. */
  56978. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56979. /**
  56980. * Returns the data related to the updraft event (cylinder).
  56981. * @returns A physics updraft event
  56982. */
  56983. getData(): PhysicsUpdraftEventData;
  56984. /**
  56985. * Enables the updraft.
  56986. */
  56987. enable(): void;
  56988. /**
  56989. * Disables the updraft.
  56990. */
  56991. disable(): void;
  56992. /**
  56993. * Disposes the cylinder.
  56994. * @param force Specifies if the updraft should be disposed by force
  56995. */
  56996. dispose(force?: boolean): void;
  56997. private getImpostorHitData;
  56998. private _tick;
  56999. /*** Helpers ***/
  57000. private _prepareCylinder;
  57001. private _intersectsWithCylinder;
  57002. }
  57003. /**
  57004. * Represents a physics vortex event
  57005. */
  57006. class PhysicsVortexEvent {
  57007. private _scene;
  57008. private _origin;
  57009. private _options;
  57010. private _physicsEngine;
  57011. private _originTop;
  57012. private _tickCallback;
  57013. private _cylinder;
  57014. private _cylinderPosition;
  57015. private _dataFetched;
  57016. /**
  57017. * Initializes the physics vortex event
  57018. * @param _scene The BabylonJS scene
  57019. * @param _origin The origin position of the vortex
  57020. * @param _options The options for the vortex event
  57021. */
  57022. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57023. /**
  57024. * Returns the data related to the vortex event (cylinder).
  57025. * @returns The physics vortex event data
  57026. */
  57027. getData(): PhysicsVortexEventData;
  57028. /**
  57029. * Enables the vortex.
  57030. */
  57031. enable(): void;
  57032. /**
  57033. * Disables the cortex.
  57034. */
  57035. disable(): void;
  57036. /**
  57037. * Disposes the sphere.
  57038. * @param force
  57039. */
  57040. dispose(force?: boolean): void;
  57041. private getImpostorHitData;
  57042. private _tick;
  57043. /*** Helpers ***/
  57044. private _prepareCylinder;
  57045. private _intersectsWithCylinder;
  57046. }
  57047. /**
  57048. * Options fot the radial explosion event
  57049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57050. */
  57051. export class PhysicsRadialExplosionEventOptions {
  57052. /**
  57053. * The radius of the sphere for the radial explosion.
  57054. */
  57055. radius: number;
  57056. /**
  57057. * The strenth of the explosion.
  57058. */
  57059. strength: number;
  57060. /**
  57061. * The strenght of the force in correspondence to the distance of the affected object
  57062. */
  57063. falloff: PhysicsRadialImpulseFalloff;
  57064. /**
  57065. * Sphere options for the radial explosion.
  57066. */
  57067. sphere: {
  57068. segments: number;
  57069. diameter: number;
  57070. };
  57071. /**
  57072. * Sphere options for the radial explosion.
  57073. */
  57074. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57075. }
  57076. /**
  57077. * Options fot the updraft event
  57078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57079. */
  57080. export class PhysicsUpdraftEventOptions {
  57081. /**
  57082. * The radius of the cylinder for the vortex
  57083. */
  57084. radius: number;
  57085. /**
  57086. * The strenth of the updraft.
  57087. */
  57088. strength: number;
  57089. /**
  57090. * The height of the cylinder for the updraft.
  57091. */
  57092. height: number;
  57093. /**
  57094. * The mode for the the updraft.
  57095. */
  57096. updraftMode: PhysicsUpdraftMode;
  57097. }
  57098. /**
  57099. * Options fot the vortex event
  57100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57101. */
  57102. export class PhysicsVortexEventOptions {
  57103. /**
  57104. * The radius of the cylinder for the vortex
  57105. */
  57106. radius: number;
  57107. /**
  57108. * The strenth of the vortex.
  57109. */
  57110. strength: number;
  57111. /**
  57112. * The height of the cylinder for the vortex.
  57113. */
  57114. height: number;
  57115. /**
  57116. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57117. */
  57118. centripetalForceThreshold: number;
  57119. /**
  57120. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57121. */
  57122. centripetalForceMultiplier: number;
  57123. /**
  57124. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57125. */
  57126. centrifugalForceMultiplier: number;
  57127. /**
  57128. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57129. */
  57130. updraftForceMultiplier: number;
  57131. }
  57132. /**
  57133. * The strenght of the force in correspondence to the distance of the affected object
  57134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57135. */
  57136. export enum PhysicsRadialImpulseFalloff {
  57137. /** Defines that impulse is constant in strength across it's whole radius */
  57138. Constant = 0,
  57139. /** Defines that impulse gets weaker if it's further from the origin */
  57140. Linear = 1
  57141. }
  57142. /**
  57143. * The strength of the force in correspondence to the distance of the affected object
  57144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57145. */
  57146. export enum PhysicsUpdraftMode {
  57147. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57148. Center = 0,
  57149. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57150. Perpendicular = 1
  57151. }
  57152. /**
  57153. * Interface for a physics hit data
  57154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57155. */
  57156. export interface PhysicsHitData {
  57157. /**
  57158. * The force applied at the contact point
  57159. */
  57160. force: Vector3;
  57161. /**
  57162. * The contact point
  57163. */
  57164. contactPoint: Vector3;
  57165. /**
  57166. * The distance from the origin to the contact point
  57167. */
  57168. distanceFromOrigin: number;
  57169. }
  57170. /**
  57171. * Interface for radial explosion event data
  57172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57173. */
  57174. export interface PhysicsRadialExplosionEventData {
  57175. /**
  57176. * A sphere used for the radial explosion event
  57177. */
  57178. sphere: Mesh;
  57179. }
  57180. /**
  57181. * Interface for gravitational field event data
  57182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57183. */
  57184. export interface PhysicsGravitationalFieldEventData {
  57185. /**
  57186. * A sphere mesh used for the gravitational field event
  57187. */
  57188. sphere: Mesh;
  57189. }
  57190. /**
  57191. * Interface for updraft event data
  57192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57193. */
  57194. export interface PhysicsUpdraftEventData {
  57195. /**
  57196. * A cylinder used for the updraft event
  57197. */
  57198. cylinder: Mesh;
  57199. }
  57200. /**
  57201. * Interface for vortex event data
  57202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57203. */
  57204. export interface PhysicsVortexEventData {
  57205. /**
  57206. * A cylinder used for the vortex event
  57207. */
  57208. cylinder: Mesh;
  57209. }
  57210. /**
  57211. * Interface for an affected physics impostor
  57212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57213. */
  57214. export interface PhysicsAffectedImpostorWithData {
  57215. /**
  57216. * The impostor affected by the effect
  57217. */
  57218. impostor: PhysicsImpostor;
  57219. /**
  57220. * The data about the hit/horce from the explosion
  57221. */
  57222. hitData: PhysicsHitData;
  57223. }
  57224. }
  57225. declare module "babylonjs/Physics/Plugins/index" {
  57226. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57227. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57228. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57229. }
  57230. declare module "babylonjs/Physics/index" {
  57231. export * from "babylonjs/Physics/IPhysicsEngine";
  57232. export * from "babylonjs/Physics/physicsEngine";
  57233. export * from "babylonjs/Physics/physicsEngineComponent";
  57234. export * from "babylonjs/Physics/physicsHelper";
  57235. export * from "babylonjs/Physics/physicsImpostor";
  57236. export * from "babylonjs/Physics/physicsJoint";
  57237. export * from "babylonjs/Physics/Plugins/index";
  57238. }
  57239. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57240. /** @hidden */
  57241. export var blackAndWhitePixelShader: {
  57242. name: string;
  57243. shader: string;
  57244. };
  57245. }
  57246. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57248. import { Camera } from "babylonjs/Cameras/camera";
  57249. import { Engine } from "babylonjs/Engines/engine";
  57250. import "babylonjs/Shaders/blackAndWhite.fragment";
  57251. /**
  57252. * Post process used to render in black and white
  57253. */
  57254. export class BlackAndWhitePostProcess extends PostProcess {
  57255. /**
  57256. * Linear about to convert he result to black and white (default: 1)
  57257. */
  57258. degree: number;
  57259. /**
  57260. * Creates a black and white post process
  57261. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57262. * @param name The name of the effect.
  57263. * @param options The required width/height ratio to downsize to before computing the render pass.
  57264. * @param camera The camera to apply the render pass to.
  57265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57266. * @param engine The engine which the post process will be applied. (default: current engine)
  57267. * @param reusable If the post process can be reused on the same frame. (default: false)
  57268. */
  57269. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57270. }
  57271. }
  57272. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57273. import { Nullable } from "babylonjs/types";
  57274. import { Camera } from "babylonjs/Cameras/camera";
  57275. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57276. import { Engine } from "babylonjs/Engines/engine";
  57277. /**
  57278. * This represents a set of one or more post processes in Babylon.
  57279. * A post process can be used to apply a shader to a texture after it is rendered.
  57280. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57281. */
  57282. export class PostProcessRenderEffect {
  57283. private _postProcesses;
  57284. private _getPostProcesses;
  57285. private _singleInstance;
  57286. private _cameras;
  57287. private _indicesForCamera;
  57288. /**
  57289. * Name of the effect
  57290. * @hidden
  57291. */
  57292. _name: string;
  57293. /**
  57294. * Instantiates a post process render effect.
  57295. * A post process can be used to apply a shader to a texture after it is rendered.
  57296. * @param engine The engine the effect is tied to
  57297. * @param name The name of the effect
  57298. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57299. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57300. */
  57301. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57302. /**
  57303. * Checks if all the post processes in the effect are supported.
  57304. */
  57305. readonly isSupported: boolean;
  57306. /**
  57307. * Updates the current state of the effect
  57308. * @hidden
  57309. */
  57310. _update(): void;
  57311. /**
  57312. * Attaches the effect on cameras
  57313. * @param cameras The camera to attach to.
  57314. * @hidden
  57315. */
  57316. _attachCameras(cameras: Camera): void;
  57317. /**
  57318. * Attaches the effect on cameras
  57319. * @param cameras The camera to attach to.
  57320. * @hidden
  57321. */
  57322. _attachCameras(cameras: Camera[]): void;
  57323. /**
  57324. * Detaches the effect on cameras
  57325. * @param cameras The camera to detatch from.
  57326. * @hidden
  57327. */
  57328. _detachCameras(cameras: Camera): void;
  57329. /**
  57330. * Detatches the effect on cameras
  57331. * @param cameras The camera to detatch from.
  57332. * @hidden
  57333. */
  57334. _detachCameras(cameras: Camera[]): void;
  57335. /**
  57336. * Enables the effect on given cameras
  57337. * @param cameras The camera to enable.
  57338. * @hidden
  57339. */
  57340. _enable(cameras: Camera): void;
  57341. /**
  57342. * Enables the effect on given cameras
  57343. * @param cameras The camera to enable.
  57344. * @hidden
  57345. */
  57346. _enable(cameras: Nullable<Camera[]>): void;
  57347. /**
  57348. * Disables the effect on the given cameras
  57349. * @param cameras The camera to disable.
  57350. * @hidden
  57351. */
  57352. _disable(cameras: Camera): void;
  57353. /**
  57354. * Disables the effect on the given cameras
  57355. * @param cameras The camera to disable.
  57356. * @hidden
  57357. */
  57358. _disable(cameras: Nullable<Camera[]>): void;
  57359. /**
  57360. * Gets a list of the post processes contained in the effect.
  57361. * @param camera The camera to get the post processes on.
  57362. * @returns The list of the post processes in the effect.
  57363. */
  57364. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57365. }
  57366. }
  57367. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57368. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57369. /** @hidden */
  57370. export var extractHighlightsPixelShader: {
  57371. name: string;
  57372. shader: string;
  57373. };
  57374. }
  57375. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57376. import { Nullable } from "babylonjs/types";
  57377. import { Camera } from "babylonjs/Cameras/camera";
  57378. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57379. import { Engine } from "babylonjs/Engines/engine";
  57380. import "babylonjs/Shaders/extractHighlights.fragment";
  57381. /**
  57382. * 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.
  57383. */
  57384. export class ExtractHighlightsPostProcess extends PostProcess {
  57385. /**
  57386. * The luminance threshold, pixels below this value will be set to black.
  57387. */
  57388. threshold: number;
  57389. /** @hidden */
  57390. _exposure: number;
  57391. /**
  57392. * Post process which has the input texture to be used when performing highlight extraction
  57393. * @hidden
  57394. */
  57395. _inputPostProcess: Nullable<PostProcess>;
  57396. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57397. }
  57398. }
  57399. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57400. /** @hidden */
  57401. export var bloomMergePixelShader: {
  57402. name: string;
  57403. shader: string;
  57404. };
  57405. }
  57406. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57407. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57408. import { Nullable } from "babylonjs/types";
  57409. import { Engine } from "babylonjs/Engines/engine";
  57410. import { Camera } from "babylonjs/Cameras/camera";
  57411. import "babylonjs/Shaders/bloomMerge.fragment";
  57412. /**
  57413. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57414. */
  57415. export class BloomMergePostProcess extends PostProcess {
  57416. /** Weight of the bloom to be added to the original input. */
  57417. weight: number;
  57418. /**
  57419. * Creates a new instance of @see BloomMergePostProcess
  57420. * @param name The name of the effect.
  57421. * @param originalFromInput Post process which's input will be used for the merge.
  57422. * @param blurred Blurred highlights post process which's output will be used.
  57423. * @param weight Weight of the bloom to be added to the original input.
  57424. * @param options The required width/height ratio to downsize to before computing the render pass.
  57425. * @param camera The camera to apply the render pass to.
  57426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57427. * @param engine The engine which the post process will be applied. (default: current engine)
  57428. * @param reusable If the post process can be reused on the same frame. (default: false)
  57429. * @param textureType Type of textures used when performing the post process. (default: 0)
  57430. * @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)
  57431. */
  57432. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57433. /** Weight of the bloom to be added to the original input. */
  57434. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57435. }
  57436. }
  57437. declare module "babylonjs/PostProcesses/bloomEffect" {
  57438. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57439. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57440. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57441. import { Camera } from "babylonjs/Cameras/camera";
  57442. import { Scene } from "babylonjs/scene";
  57443. /**
  57444. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57445. */
  57446. export class BloomEffect extends PostProcessRenderEffect {
  57447. private bloomScale;
  57448. /**
  57449. * @hidden Internal
  57450. */
  57451. _effects: Array<PostProcess>;
  57452. /**
  57453. * @hidden Internal
  57454. */
  57455. _downscale: ExtractHighlightsPostProcess;
  57456. private _blurX;
  57457. private _blurY;
  57458. private _merge;
  57459. /**
  57460. * The luminance threshold to find bright areas of the image to bloom.
  57461. */
  57462. threshold: number;
  57463. /**
  57464. * The strength of the bloom.
  57465. */
  57466. weight: number;
  57467. /**
  57468. * Specifies the size of the bloom blur kernel, relative to the final output size
  57469. */
  57470. kernel: number;
  57471. /**
  57472. * Creates a new instance of @see BloomEffect
  57473. * @param scene The scene the effect belongs to.
  57474. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57475. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57476. * @param bloomWeight The the strength of bloom.
  57477. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57478. * @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)
  57479. */
  57480. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57481. /**
  57482. * Disposes each of the internal effects for a given camera.
  57483. * @param camera The camera to dispose the effect on.
  57484. */
  57485. disposeEffects(camera: Camera): void;
  57486. /**
  57487. * @hidden Internal
  57488. */
  57489. _updateEffects(): void;
  57490. /**
  57491. * Internal
  57492. * @returns if all the contained post processes are ready.
  57493. * @hidden
  57494. */
  57495. _isReady(): boolean;
  57496. }
  57497. }
  57498. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57499. /** @hidden */
  57500. export var chromaticAberrationPixelShader: {
  57501. name: string;
  57502. shader: string;
  57503. };
  57504. }
  57505. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57506. import { Vector2 } from "babylonjs/Maths/math";
  57507. import { Nullable } from "babylonjs/types";
  57508. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57509. import { Camera } from "babylonjs/Cameras/camera";
  57510. import { Engine } from "babylonjs/Engines/engine";
  57511. import "babylonjs/Shaders/chromaticAberration.fragment";
  57512. /**
  57513. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57514. */
  57515. export class ChromaticAberrationPostProcess extends PostProcess {
  57516. /**
  57517. * The amount of seperation of rgb channels (default: 30)
  57518. */
  57519. aberrationAmount: number;
  57520. /**
  57521. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57522. */
  57523. radialIntensity: number;
  57524. /**
  57525. * 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))
  57526. */
  57527. direction: Vector2;
  57528. /**
  57529. * 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))
  57530. */
  57531. centerPosition: Vector2;
  57532. /**
  57533. * Creates a new instance ChromaticAberrationPostProcess
  57534. * @param name The name of the effect.
  57535. * @param screenWidth The width of the screen to apply the effect on.
  57536. * @param screenHeight The height of the screen to apply the effect on.
  57537. * @param options The required width/height ratio to downsize to before computing the render pass.
  57538. * @param camera The camera to apply the render pass to.
  57539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57540. * @param engine The engine which the post process will be applied. (default: current engine)
  57541. * @param reusable If the post process can be reused on the same frame. (default: false)
  57542. * @param textureType Type of textures used when performing the post process. (default: 0)
  57543. * @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)
  57544. */
  57545. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57546. }
  57547. }
  57548. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57549. /** @hidden */
  57550. export var circleOfConfusionPixelShader: {
  57551. name: string;
  57552. shader: string;
  57553. };
  57554. }
  57555. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57556. import { Nullable } from "babylonjs/types";
  57557. import { Engine } from "babylonjs/Engines/engine";
  57558. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57559. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57560. import { Camera } from "babylonjs/Cameras/camera";
  57561. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57562. /**
  57563. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57564. */
  57565. export class CircleOfConfusionPostProcess extends PostProcess {
  57566. /**
  57567. * 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.
  57568. */
  57569. lensSize: number;
  57570. /**
  57571. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57572. */
  57573. fStop: number;
  57574. /**
  57575. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57576. */
  57577. focusDistance: number;
  57578. /**
  57579. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57580. */
  57581. focalLength: number;
  57582. private _depthTexture;
  57583. /**
  57584. * Creates a new instance CircleOfConfusionPostProcess
  57585. * @param name The name of the effect.
  57586. * @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.
  57587. * @param options The required width/height ratio to downsize to before computing the render pass.
  57588. * @param camera The camera to apply the render pass to.
  57589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57590. * @param engine The engine which the post process will be applied. (default: current engine)
  57591. * @param reusable If the post process can be reused on the same frame. (default: false)
  57592. * @param textureType Type of textures used when performing the post process. (default: 0)
  57593. * @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)
  57594. */
  57595. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57596. /**
  57597. * 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.
  57598. */
  57599. depthTexture: RenderTargetTexture;
  57600. }
  57601. }
  57602. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57603. /** @hidden */
  57604. export var colorCorrectionPixelShader: {
  57605. name: string;
  57606. shader: string;
  57607. };
  57608. }
  57609. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57610. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57611. import { Engine } from "babylonjs/Engines/engine";
  57612. import { Camera } from "babylonjs/Cameras/camera";
  57613. import "babylonjs/Shaders/colorCorrection.fragment";
  57614. /**
  57615. *
  57616. * This post-process allows the modification of rendered colors by using
  57617. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57618. *
  57619. * The object needs to be provided an url to a texture containing the color
  57620. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57621. * Use an image editing software to tweak the LUT to match your needs.
  57622. *
  57623. * For an example of a color LUT, see here:
  57624. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57625. * For explanations on color grading, see here:
  57626. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57627. *
  57628. */
  57629. export class ColorCorrectionPostProcess extends PostProcess {
  57630. private _colorTableTexture;
  57631. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57632. }
  57633. }
  57634. declare module "babylonjs/Shaders/convolution.fragment" {
  57635. /** @hidden */
  57636. export var convolutionPixelShader: {
  57637. name: string;
  57638. shader: string;
  57639. };
  57640. }
  57641. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  57642. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57643. import { Nullable } from "babylonjs/types";
  57644. import { Camera } from "babylonjs/Cameras/camera";
  57645. import { Engine } from "babylonjs/Engines/engine";
  57646. import "babylonjs/Shaders/convolution.fragment";
  57647. /**
  57648. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57649. * input texture to perform effects such as edge detection or sharpening
  57650. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57651. */
  57652. export class ConvolutionPostProcess extends PostProcess {
  57653. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57654. kernel: number[];
  57655. /**
  57656. * Creates a new instance ConvolutionPostProcess
  57657. * @param name The name of the effect.
  57658. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57659. * @param options The required width/height ratio to downsize to before computing the render pass.
  57660. * @param camera The camera to apply the render pass to.
  57661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57662. * @param engine The engine which the post process will be applied. (default: current engine)
  57663. * @param reusable If the post process can be reused on the same frame. (default: false)
  57664. * @param textureType Type of textures used when performing the post process. (default: 0)
  57665. */
  57666. constructor(name: string,
  57667. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57668. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57669. /**
  57670. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57671. */
  57672. static EdgeDetect0Kernel: number[];
  57673. /**
  57674. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57675. */
  57676. static EdgeDetect1Kernel: number[];
  57677. /**
  57678. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57679. */
  57680. static EdgeDetect2Kernel: number[];
  57681. /**
  57682. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57683. */
  57684. static SharpenKernel: number[];
  57685. /**
  57686. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57687. */
  57688. static EmbossKernel: number[];
  57689. /**
  57690. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57691. */
  57692. static GaussianKernel: number[];
  57693. }
  57694. }
  57695. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  57696. import { Nullable } from "babylonjs/types";
  57697. import { Vector2 } from "babylonjs/Maths/math";
  57698. import { Camera } from "babylonjs/Cameras/camera";
  57699. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57700. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  57701. import { Engine } from "babylonjs/Engines/engine";
  57702. import { Scene } from "babylonjs/scene";
  57703. /**
  57704. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57705. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57706. * based on samples that have a large difference in distance than the center pixel.
  57707. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57708. */
  57709. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57710. direction: Vector2;
  57711. /**
  57712. * Creates a new instance CircleOfConfusionPostProcess
  57713. * @param name The name of the effect.
  57714. * @param scene The scene the effect belongs to.
  57715. * @param direction The direction the blur should be applied.
  57716. * @param kernel The size of the kernel used to blur.
  57717. * @param options The required width/height ratio to downsize to before computing the render pass.
  57718. * @param camera The camera to apply the render pass to.
  57719. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57720. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57722. * @param engine The engine which the post process will be applied. (default: current engine)
  57723. * @param reusable If the post process can be reused on the same frame. (default: false)
  57724. * @param textureType Type of textures used when performing the post process. (default: 0)
  57725. * @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)
  57726. */
  57727. 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);
  57728. }
  57729. }
  57730. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  57731. /** @hidden */
  57732. export var depthOfFieldMergePixelShader: {
  57733. name: string;
  57734. shader: string;
  57735. };
  57736. }
  57737. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  57738. import { Nullable } from "babylonjs/types";
  57739. import { Camera } from "babylonjs/Cameras/camera";
  57740. import { Effect } from "babylonjs/Materials/effect";
  57741. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57742. import { Engine } from "babylonjs/Engines/engine";
  57743. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  57744. /**
  57745. * Options to be set when merging outputs from the default pipeline.
  57746. */
  57747. export class DepthOfFieldMergePostProcessOptions {
  57748. /**
  57749. * The original image to merge on top of
  57750. */
  57751. originalFromInput: PostProcess;
  57752. /**
  57753. * Parameters to perform the merge of the depth of field effect
  57754. */
  57755. depthOfField?: {
  57756. circleOfConfusion: PostProcess;
  57757. blurSteps: Array<PostProcess>;
  57758. };
  57759. /**
  57760. * Parameters to perform the merge of bloom effect
  57761. */
  57762. bloom?: {
  57763. blurred: PostProcess;
  57764. weight: number;
  57765. };
  57766. }
  57767. /**
  57768. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57769. */
  57770. export class DepthOfFieldMergePostProcess extends PostProcess {
  57771. private blurSteps;
  57772. /**
  57773. * Creates a new instance of DepthOfFieldMergePostProcess
  57774. * @param name The name of the effect.
  57775. * @param originalFromInput Post process which's input will be used for the merge.
  57776. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57777. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57778. * @param options The required width/height ratio to downsize to before computing the render pass.
  57779. * @param camera The camera to apply the render pass to.
  57780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57781. * @param engine The engine which the post process will be applied. (default: current engine)
  57782. * @param reusable If the post process can be reused on the same frame. (default: false)
  57783. * @param textureType Type of textures used when performing the post process. (default: 0)
  57784. * @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)
  57785. */
  57786. 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);
  57787. /**
  57788. * Updates the effect with the current post process compile time values and recompiles the shader.
  57789. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57790. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57791. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57792. * @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
  57793. * @param onCompiled Called when the shader has been compiled.
  57794. * @param onError Called if there is an error when compiling a shader.
  57795. */
  57796. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57797. }
  57798. }
  57799. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  57800. import { Nullable } from "babylonjs/types";
  57801. import { Camera } from "babylonjs/Cameras/camera";
  57802. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57803. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57804. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57805. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57806. import { Scene } from "babylonjs/scene";
  57807. /**
  57808. * Specifies the level of max blur that should be applied when using the depth of field effect
  57809. */
  57810. export enum DepthOfFieldEffectBlurLevel {
  57811. /**
  57812. * Subtle blur
  57813. */
  57814. Low = 0,
  57815. /**
  57816. * Medium blur
  57817. */
  57818. Medium = 1,
  57819. /**
  57820. * Large blur
  57821. */
  57822. High = 2
  57823. }
  57824. /**
  57825. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57826. */
  57827. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57828. private _circleOfConfusion;
  57829. /**
  57830. * @hidden Internal, blurs from high to low
  57831. */
  57832. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57833. private _depthOfFieldBlurY;
  57834. private _dofMerge;
  57835. /**
  57836. * @hidden Internal post processes in depth of field effect
  57837. */
  57838. _effects: Array<PostProcess>;
  57839. /**
  57840. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57841. */
  57842. focalLength: number;
  57843. /**
  57844. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57845. */
  57846. fStop: number;
  57847. /**
  57848. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57849. */
  57850. focusDistance: number;
  57851. /**
  57852. * 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.
  57853. */
  57854. lensSize: number;
  57855. /**
  57856. * Creates a new instance DepthOfFieldEffect
  57857. * @param scene The scene the effect belongs to.
  57858. * @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.
  57859. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57860. * @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)
  57861. */
  57862. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57863. /**
  57864. * Get the current class name of the current effet
  57865. * @returns "DepthOfFieldEffect"
  57866. */
  57867. getClassName(): string;
  57868. /**
  57869. * 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.
  57870. */
  57871. depthTexture: RenderTargetTexture;
  57872. /**
  57873. * Disposes each of the internal effects for a given camera.
  57874. * @param camera The camera to dispose the effect on.
  57875. */
  57876. disposeEffects(camera: Camera): void;
  57877. /**
  57878. * @hidden Internal
  57879. */
  57880. _updateEffects(): void;
  57881. /**
  57882. * Internal
  57883. * @returns if all the contained post processes are ready.
  57884. * @hidden
  57885. */
  57886. _isReady(): boolean;
  57887. }
  57888. }
  57889. declare module "babylonjs/Shaders/displayPass.fragment" {
  57890. /** @hidden */
  57891. export var displayPassPixelShader: {
  57892. name: string;
  57893. shader: string;
  57894. };
  57895. }
  57896. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  57897. import { Nullable } from "babylonjs/types";
  57898. import { Camera } from "babylonjs/Cameras/camera";
  57899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57900. import { Engine } from "babylonjs/Engines/engine";
  57901. import "babylonjs/Shaders/displayPass.fragment";
  57902. /**
  57903. * DisplayPassPostProcess which produces an output the same as it's input
  57904. */
  57905. export class DisplayPassPostProcess extends PostProcess {
  57906. /**
  57907. * Creates the DisplayPassPostProcess
  57908. * @param name The name of the effect.
  57909. * @param options The required width/height ratio to downsize to before computing the render pass.
  57910. * @param camera The camera to apply the render pass to.
  57911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57912. * @param engine The engine which the post process will be applied. (default: current engine)
  57913. * @param reusable If the post process can be reused on the same frame. (default: false)
  57914. */
  57915. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57916. }
  57917. }
  57918. declare module "babylonjs/Shaders/filter.fragment" {
  57919. /** @hidden */
  57920. export var filterPixelShader: {
  57921. name: string;
  57922. shader: string;
  57923. };
  57924. }
  57925. declare module "babylonjs/PostProcesses/filterPostProcess" {
  57926. import { Nullable } from "babylonjs/types";
  57927. import { Matrix } from "babylonjs/Maths/math";
  57928. import { Camera } from "babylonjs/Cameras/camera";
  57929. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57930. import { Engine } from "babylonjs/Engines/engine";
  57931. import "babylonjs/Shaders/filter.fragment";
  57932. /**
  57933. * Applies a kernel filter to the image
  57934. */
  57935. export class FilterPostProcess extends PostProcess {
  57936. /** The matrix to be applied to the image */
  57937. kernelMatrix: Matrix;
  57938. /**
  57939. *
  57940. * @param name The name of the effect.
  57941. * @param kernelMatrix The matrix to be applied to the image
  57942. * @param options The required width/height ratio to downsize to before computing the render pass.
  57943. * @param camera The camera to apply the render pass to.
  57944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57945. * @param engine The engine which the post process will be applied. (default: current engine)
  57946. * @param reusable If the post process can be reused on the same frame. (default: false)
  57947. */
  57948. constructor(name: string,
  57949. /** The matrix to be applied to the image */
  57950. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57951. }
  57952. }
  57953. declare module "babylonjs/Shaders/fxaa.fragment" {
  57954. /** @hidden */
  57955. export var fxaaPixelShader: {
  57956. name: string;
  57957. shader: string;
  57958. };
  57959. }
  57960. declare module "babylonjs/Shaders/fxaa.vertex" {
  57961. /** @hidden */
  57962. export var fxaaVertexShader: {
  57963. name: string;
  57964. shader: string;
  57965. };
  57966. }
  57967. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  57968. import { Nullable } from "babylonjs/types";
  57969. import { Camera } from "babylonjs/Cameras/camera";
  57970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57971. import { Engine } from "babylonjs/Engines/engine";
  57972. import "babylonjs/Shaders/fxaa.fragment";
  57973. import "babylonjs/Shaders/fxaa.vertex";
  57974. /**
  57975. * Fxaa post process
  57976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57977. */
  57978. export class FxaaPostProcess extends PostProcess {
  57979. /** @hidden */
  57980. texelWidth: number;
  57981. /** @hidden */
  57982. texelHeight: number;
  57983. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57984. private _getDefines;
  57985. }
  57986. }
  57987. declare module "babylonjs/Shaders/grain.fragment" {
  57988. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57989. /** @hidden */
  57990. export var grainPixelShader: {
  57991. name: string;
  57992. shader: string;
  57993. };
  57994. }
  57995. declare module "babylonjs/PostProcesses/grainPostProcess" {
  57996. import { Nullable } from "babylonjs/types";
  57997. import { Camera } from "babylonjs/Cameras/camera";
  57998. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57999. import { Engine } from "babylonjs/Engines/engine";
  58000. import "babylonjs/Shaders/grain.fragment";
  58001. /**
  58002. * The GrainPostProcess adds noise to the image at mid luminance levels
  58003. */
  58004. export class GrainPostProcess extends PostProcess {
  58005. /**
  58006. * The intensity of the grain added (default: 30)
  58007. */
  58008. intensity: number;
  58009. /**
  58010. * If the grain should be randomized on every frame
  58011. */
  58012. animated: boolean;
  58013. /**
  58014. * Creates a new instance of @see GrainPostProcess
  58015. * @param name The name of the effect.
  58016. * @param options The required width/height ratio to downsize to before computing the render pass.
  58017. * @param camera The camera to apply the render pass to.
  58018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58019. * @param engine The engine which the post process will be applied. (default: current engine)
  58020. * @param reusable If the post process can be reused on the same frame. (default: false)
  58021. * @param textureType Type of textures used when performing the post process. (default: 0)
  58022. * @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)
  58023. */
  58024. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58025. }
  58026. }
  58027. declare module "babylonjs/Shaders/highlights.fragment" {
  58028. /** @hidden */
  58029. export var highlightsPixelShader: {
  58030. name: string;
  58031. shader: string;
  58032. };
  58033. }
  58034. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58035. import { Nullable } from "babylonjs/types";
  58036. import { Camera } from "babylonjs/Cameras/camera";
  58037. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58038. import { Engine } from "babylonjs/Engines/engine";
  58039. import "babylonjs/Shaders/highlights.fragment";
  58040. /**
  58041. * Extracts highlights from the image
  58042. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58043. */
  58044. export class HighlightsPostProcess extends PostProcess {
  58045. /**
  58046. * Extracts highlights from the image
  58047. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58048. * @param name The name of the effect.
  58049. * @param options The required width/height ratio to downsize to before computing the render pass.
  58050. * @param camera The camera to apply the render pass to.
  58051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58052. * @param engine The engine which the post process will be applied. (default: current engine)
  58053. * @param reusable If the post process can be reused on the same frame. (default: false)
  58054. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58055. */
  58056. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58057. }
  58058. }
  58059. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58060. /** @hidden */
  58061. export var mrtFragmentDeclaration: {
  58062. name: string;
  58063. shader: string;
  58064. };
  58065. }
  58066. declare module "babylonjs/Shaders/geometry.fragment" {
  58067. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58068. /** @hidden */
  58069. export var geometryPixelShader: {
  58070. name: string;
  58071. shader: string;
  58072. };
  58073. }
  58074. declare module "babylonjs/Shaders/geometry.vertex" {
  58075. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58076. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58077. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58078. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58079. /** @hidden */
  58080. export var geometryVertexShader: {
  58081. name: string;
  58082. shader: string;
  58083. };
  58084. }
  58085. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58086. import { Matrix } from "babylonjs/Maths/math";
  58087. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58088. import { Mesh } from "babylonjs/Meshes/mesh";
  58089. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58090. import { Effect } from "babylonjs/Materials/effect";
  58091. import { Scene } from "babylonjs/scene";
  58092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58093. import "babylonjs/Shaders/geometry.fragment";
  58094. import "babylonjs/Shaders/geometry.vertex";
  58095. /** @hidden */
  58096. interface ISavedTransformationMatrix {
  58097. world: Matrix;
  58098. viewProjection: Matrix;
  58099. }
  58100. /**
  58101. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58102. */
  58103. export class GeometryBufferRenderer {
  58104. /**
  58105. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58106. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58107. */
  58108. static readonly POSITION_TEXTURE_TYPE: number;
  58109. /**
  58110. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58111. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58112. */
  58113. static readonly VELOCITY_TEXTURE_TYPE: number;
  58114. /**
  58115. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58116. * in order to compute objects velocities when enableVelocity is set to "true"
  58117. * @hidden
  58118. */
  58119. _previousTransformationMatrices: {
  58120. [index: number]: ISavedTransformationMatrix;
  58121. };
  58122. /**
  58123. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58124. * in order to compute objects velocities when enableVelocity is set to "true"
  58125. * @hidden
  58126. */
  58127. _previousBonesTransformationMatrices: {
  58128. [index: number]: Float32Array;
  58129. };
  58130. /**
  58131. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58132. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58133. */
  58134. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58135. private _scene;
  58136. private _multiRenderTarget;
  58137. private _ratio;
  58138. private _enablePosition;
  58139. private _enableVelocity;
  58140. private _positionIndex;
  58141. private _velocityIndex;
  58142. protected _effect: Effect;
  58143. protected _cachedDefines: string;
  58144. /**
  58145. * Set the render list (meshes to be rendered) used in the G buffer.
  58146. */
  58147. renderList: Mesh[];
  58148. /**
  58149. * Gets wether or not G buffer are supported by the running hardware.
  58150. * This requires draw buffer supports
  58151. */
  58152. readonly isSupported: boolean;
  58153. /**
  58154. * Returns the index of the given texture type in the G-Buffer textures array
  58155. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58156. * @returns the index of the given texture type in the G-Buffer textures array
  58157. */
  58158. getTextureIndex(textureType: number): number;
  58159. /**
  58160. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58161. */
  58162. /**
  58163. * Sets whether or not objects positions are enabled for the G buffer.
  58164. */
  58165. enablePosition: boolean;
  58166. /**
  58167. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58168. */
  58169. /**
  58170. * Sets wether or not objects velocities are enabled for the G buffer.
  58171. */
  58172. enableVelocity: boolean;
  58173. /**
  58174. * Gets the scene associated with the buffer.
  58175. */
  58176. readonly scene: Scene;
  58177. /**
  58178. * Gets the ratio used by the buffer during its creation.
  58179. * How big is the buffer related to the main canvas.
  58180. */
  58181. readonly ratio: number;
  58182. /** @hidden */
  58183. static _SceneComponentInitialization: (scene: Scene) => void;
  58184. /**
  58185. * Creates a new G Buffer for the scene
  58186. * @param scene The scene the buffer belongs to
  58187. * @param ratio How big is the buffer related to the main canvas.
  58188. */
  58189. constructor(scene: Scene, ratio?: number);
  58190. /**
  58191. * Checks wether everything is ready to render a submesh to the G buffer.
  58192. * @param subMesh the submesh to check readiness for
  58193. * @param useInstances is the mesh drawn using instance or not
  58194. * @returns true if ready otherwise false
  58195. */
  58196. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58197. /**
  58198. * Gets the current underlying G Buffer.
  58199. * @returns the buffer
  58200. */
  58201. getGBuffer(): MultiRenderTarget;
  58202. /**
  58203. * Gets the number of samples used to render the buffer (anti aliasing).
  58204. */
  58205. /**
  58206. * Sets the number of samples used to render the buffer (anti aliasing).
  58207. */
  58208. samples: number;
  58209. /**
  58210. * Disposes the renderer and frees up associated resources.
  58211. */
  58212. dispose(): void;
  58213. protected _createRenderTargets(): void;
  58214. private _copyBonesTransformationMatrices;
  58215. }
  58216. }
  58217. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58218. import { Nullable } from "babylonjs/types";
  58219. import { Scene } from "babylonjs/scene";
  58220. import { ISceneComponent } from "babylonjs/sceneComponent";
  58221. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58222. module "babylonjs/scene" {
  58223. interface Scene {
  58224. /** @hidden (Backing field) */
  58225. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58226. /**
  58227. * Gets or Sets the current geometry buffer associated to the scene.
  58228. */
  58229. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58230. /**
  58231. * Enables a GeometryBufferRender and associates it with the scene
  58232. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58233. * @returns the GeometryBufferRenderer
  58234. */
  58235. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58236. /**
  58237. * Disables the GeometryBufferRender associated with the scene
  58238. */
  58239. disableGeometryBufferRenderer(): void;
  58240. }
  58241. }
  58242. /**
  58243. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58244. * in several rendering techniques.
  58245. */
  58246. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58247. /**
  58248. * The component name helpful to identify the component in the list of scene components.
  58249. */
  58250. readonly name: string;
  58251. /**
  58252. * The scene the component belongs to.
  58253. */
  58254. scene: Scene;
  58255. /**
  58256. * Creates a new instance of the component for the given scene
  58257. * @param scene Defines the scene to register the component in
  58258. */
  58259. constructor(scene: Scene);
  58260. /**
  58261. * Registers the component in a given scene
  58262. */
  58263. register(): void;
  58264. /**
  58265. * Rebuilds the elements related to this component in case of
  58266. * context lost for instance.
  58267. */
  58268. rebuild(): void;
  58269. /**
  58270. * Disposes the component and the associated ressources
  58271. */
  58272. dispose(): void;
  58273. private _gatherRenderTargets;
  58274. }
  58275. }
  58276. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58277. /** @hidden */
  58278. export var motionBlurPixelShader: {
  58279. name: string;
  58280. shader: string;
  58281. };
  58282. }
  58283. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58284. import { Nullable } from "babylonjs/types";
  58285. import { Camera } from "babylonjs/Cameras/camera";
  58286. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58287. import { Scene } from "babylonjs/scene";
  58288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58289. import "babylonjs/Animations/animatable";
  58290. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58291. import "babylonjs/Shaders/motionBlur.fragment";
  58292. import { Engine } from "babylonjs/Engines/engine";
  58293. /**
  58294. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58295. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58296. * As an example, all you have to do is to create the post-process:
  58297. * var mb = new BABYLON.MotionBlurPostProcess(
  58298. * 'mb', // The name of the effect.
  58299. * scene, // The scene containing the objects to blur according to their velocity.
  58300. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58301. * camera // The camera to apply the render pass to.
  58302. * );
  58303. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58304. */
  58305. export class MotionBlurPostProcess extends PostProcess {
  58306. /**
  58307. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58308. */
  58309. motionStrength: number;
  58310. /**
  58311. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58312. */
  58313. /**
  58314. * Sets the number of iterations to be used for motion blur quality
  58315. */
  58316. motionBlurSamples: number;
  58317. private _motionBlurSamples;
  58318. private _geometryBufferRenderer;
  58319. /**
  58320. * Creates a new instance MotionBlurPostProcess
  58321. * @param name The name of the effect.
  58322. * @param scene The scene containing the objects to blur according to their velocity.
  58323. * @param options The required width/height ratio to downsize to before computing the render pass.
  58324. * @param camera The camera to apply the render pass to.
  58325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58326. * @param engine The engine which the post process will be applied. (default: current engine)
  58327. * @param reusable If the post process can be reused on the same frame. (default: false)
  58328. * @param textureType Type of textures used when performing the post process. (default: 0)
  58329. * @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)
  58330. */
  58331. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58332. /**
  58333. * Excludes the given skinned mesh from computing bones velocities.
  58334. * 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.
  58335. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58336. */
  58337. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58338. /**
  58339. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58340. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58341. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58342. */
  58343. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58344. /**
  58345. * Disposes the post process.
  58346. * @param camera The camera to dispose the post process on.
  58347. */
  58348. dispose(camera?: Camera): void;
  58349. }
  58350. }
  58351. declare module "babylonjs/Shaders/refraction.fragment" {
  58352. /** @hidden */
  58353. export var refractionPixelShader: {
  58354. name: string;
  58355. shader: string;
  58356. };
  58357. }
  58358. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58359. import { Color3 } from "babylonjs/Maths/math";
  58360. import { Camera } from "babylonjs/Cameras/camera";
  58361. import { Texture } from "babylonjs/Materials/Textures/texture";
  58362. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58363. import { Engine } from "babylonjs/Engines/engine";
  58364. import "babylonjs/Shaders/refraction.fragment";
  58365. /**
  58366. * Post process which applies a refractin texture
  58367. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58368. */
  58369. export class RefractionPostProcess extends PostProcess {
  58370. /** the base color of the refraction (used to taint the rendering) */
  58371. color: Color3;
  58372. /** simulated refraction depth */
  58373. depth: number;
  58374. /** the coefficient of the base color (0 to remove base color tainting) */
  58375. colorLevel: number;
  58376. private _refTexture;
  58377. private _ownRefractionTexture;
  58378. /**
  58379. * Gets or sets the refraction texture
  58380. * Please note that you are responsible for disposing the texture if you set it manually
  58381. */
  58382. refractionTexture: Texture;
  58383. /**
  58384. * Initializes the RefractionPostProcess
  58385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58386. * @param name The name of the effect.
  58387. * @param refractionTextureUrl Url of the refraction texture to use
  58388. * @param color the base color of the refraction (used to taint the rendering)
  58389. * @param depth simulated refraction depth
  58390. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58391. * @param camera The camera to apply the render pass to.
  58392. * @param options The required width/height ratio to downsize to before computing the render pass.
  58393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58394. * @param engine The engine which the post process will be applied. (default: current engine)
  58395. * @param reusable If the post process can be reused on the same frame. (default: false)
  58396. */
  58397. constructor(name: string, refractionTextureUrl: string,
  58398. /** the base color of the refraction (used to taint the rendering) */
  58399. color: Color3,
  58400. /** simulated refraction depth */
  58401. depth: number,
  58402. /** the coefficient of the base color (0 to remove base color tainting) */
  58403. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58404. /**
  58405. * Disposes of the post process
  58406. * @param camera Camera to dispose post process on
  58407. */
  58408. dispose(camera: Camera): void;
  58409. }
  58410. }
  58411. declare module "babylonjs/Shaders/sharpen.fragment" {
  58412. /** @hidden */
  58413. export var sharpenPixelShader: {
  58414. name: string;
  58415. shader: string;
  58416. };
  58417. }
  58418. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58419. import { Nullable } from "babylonjs/types";
  58420. import { Camera } from "babylonjs/Cameras/camera";
  58421. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58422. import "babylonjs/Shaders/sharpen.fragment";
  58423. import { Engine } from "babylonjs/Engines/engine";
  58424. /**
  58425. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58426. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58427. */
  58428. export class SharpenPostProcess extends PostProcess {
  58429. /**
  58430. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58431. */
  58432. colorAmount: number;
  58433. /**
  58434. * How much sharpness should be applied (default: 0.3)
  58435. */
  58436. edgeAmount: number;
  58437. /**
  58438. * Creates a new instance ConvolutionPostProcess
  58439. * @param name The name of the effect.
  58440. * @param options The required width/height ratio to downsize to before computing the render pass.
  58441. * @param camera The camera to apply the render pass to.
  58442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58443. * @param engine The engine which the post process will be applied. (default: current engine)
  58444. * @param reusable If the post process can be reused on the same frame. (default: false)
  58445. * @param textureType Type of textures used when performing the post process. (default: 0)
  58446. * @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)
  58447. */
  58448. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58449. }
  58450. }
  58451. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58452. import { Nullable } from "babylonjs/types";
  58453. import { Camera } from "babylonjs/Cameras/camera";
  58454. import { Engine } from "babylonjs/Engines/engine";
  58455. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58456. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58457. /**
  58458. * PostProcessRenderPipeline
  58459. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58460. */
  58461. export class PostProcessRenderPipeline {
  58462. private engine;
  58463. private _renderEffects;
  58464. private _renderEffectsForIsolatedPass;
  58465. /**
  58466. * List of inspectable custom properties (used by the Inspector)
  58467. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58468. */
  58469. inspectableCustomProperties: IInspectable[];
  58470. /**
  58471. * @hidden
  58472. */
  58473. protected _cameras: Camera[];
  58474. /** @hidden */
  58475. _name: string;
  58476. /**
  58477. * Gets pipeline name
  58478. */
  58479. readonly name: string;
  58480. /**
  58481. * Initializes a PostProcessRenderPipeline
  58482. * @param engine engine to add the pipeline to
  58483. * @param name name of the pipeline
  58484. */
  58485. constructor(engine: Engine, name: string);
  58486. /**
  58487. * Gets the class name
  58488. * @returns "PostProcessRenderPipeline"
  58489. */
  58490. getClassName(): string;
  58491. /**
  58492. * If all the render effects in the pipeline are supported
  58493. */
  58494. readonly isSupported: boolean;
  58495. /**
  58496. * Adds an effect to the pipeline
  58497. * @param renderEffect the effect to add
  58498. */
  58499. addEffect(renderEffect: PostProcessRenderEffect): void;
  58500. /** @hidden */
  58501. _rebuild(): void;
  58502. /** @hidden */
  58503. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58504. /** @hidden */
  58505. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58506. /** @hidden */
  58507. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58508. /** @hidden */
  58509. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58510. /** @hidden */
  58511. _attachCameras(cameras: Camera, unique: boolean): void;
  58512. /** @hidden */
  58513. _attachCameras(cameras: Camera[], unique: boolean): void;
  58514. /** @hidden */
  58515. _detachCameras(cameras: Camera): void;
  58516. /** @hidden */
  58517. _detachCameras(cameras: Nullable<Camera[]>): void;
  58518. /** @hidden */
  58519. _update(): void;
  58520. /** @hidden */
  58521. _reset(): void;
  58522. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58523. /**
  58524. * Disposes of the pipeline
  58525. */
  58526. dispose(): void;
  58527. }
  58528. }
  58529. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58530. import { Camera } from "babylonjs/Cameras/camera";
  58531. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58532. /**
  58533. * PostProcessRenderPipelineManager class
  58534. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58535. */
  58536. export class PostProcessRenderPipelineManager {
  58537. private _renderPipelines;
  58538. /**
  58539. * Initializes a PostProcessRenderPipelineManager
  58540. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58541. */
  58542. constructor();
  58543. /**
  58544. * Gets the list of supported render pipelines
  58545. */
  58546. readonly supportedPipelines: PostProcessRenderPipeline[];
  58547. /**
  58548. * Adds a pipeline to the manager
  58549. * @param renderPipeline The pipeline to add
  58550. */
  58551. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58552. /**
  58553. * Attaches a camera to the pipeline
  58554. * @param renderPipelineName The name of the pipeline to attach to
  58555. * @param cameras the camera to attach
  58556. * @param unique if the camera can be attached multiple times to the pipeline
  58557. */
  58558. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58559. /**
  58560. * Detaches a camera from the pipeline
  58561. * @param renderPipelineName The name of the pipeline to detach from
  58562. * @param cameras the camera to detach
  58563. */
  58564. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58565. /**
  58566. * Enables an effect by name on a pipeline
  58567. * @param renderPipelineName the name of the pipeline to enable the effect in
  58568. * @param renderEffectName the name of the effect to enable
  58569. * @param cameras the cameras that the effect should be enabled on
  58570. */
  58571. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58572. /**
  58573. * Disables an effect by name on a pipeline
  58574. * @param renderPipelineName the name of the pipeline to disable the effect in
  58575. * @param renderEffectName the name of the effect to disable
  58576. * @param cameras the cameras that the effect should be disabled on
  58577. */
  58578. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58579. /**
  58580. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58581. */
  58582. update(): void;
  58583. /** @hidden */
  58584. _rebuild(): void;
  58585. /**
  58586. * Disposes of the manager and pipelines
  58587. */
  58588. dispose(): void;
  58589. }
  58590. }
  58591. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58592. import { ISceneComponent } from "babylonjs/sceneComponent";
  58593. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58594. import { Scene } from "babylonjs/scene";
  58595. module "babylonjs/scene" {
  58596. interface Scene {
  58597. /** @hidden (Backing field) */
  58598. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58599. /**
  58600. * Gets the postprocess render pipeline manager
  58601. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58602. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58603. */
  58604. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58605. }
  58606. }
  58607. /**
  58608. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58609. */
  58610. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58611. /**
  58612. * The component name helpfull to identify the component in the list of scene components.
  58613. */
  58614. readonly name: string;
  58615. /**
  58616. * The scene the component belongs to.
  58617. */
  58618. scene: Scene;
  58619. /**
  58620. * Creates a new instance of the component for the given scene
  58621. * @param scene Defines the scene to register the component in
  58622. */
  58623. constructor(scene: Scene);
  58624. /**
  58625. * Registers the component in a given scene
  58626. */
  58627. register(): void;
  58628. /**
  58629. * Rebuilds the elements related to this component in case of
  58630. * context lost for instance.
  58631. */
  58632. rebuild(): void;
  58633. /**
  58634. * Disposes the component and the associated ressources
  58635. */
  58636. dispose(): void;
  58637. private _gatherRenderTargets;
  58638. }
  58639. }
  58640. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  58641. import { Nullable } from "babylonjs/types";
  58642. import { IAnimatable } from "babylonjs/Misc/tools";
  58643. import { Camera } from "babylonjs/Cameras/camera";
  58644. import { IDisposable } from "babylonjs/scene";
  58645. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  58646. import { Scene } from "babylonjs/scene";
  58647. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  58648. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  58649. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  58650. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  58651. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58652. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58653. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  58654. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  58655. import { Animation } from "babylonjs/Animations/animation";
  58656. /**
  58657. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58658. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58659. */
  58660. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58661. private _scene;
  58662. private _camerasToBeAttached;
  58663. /**
  58664. * ID of the sharpen post process,
  58665. */
  58666. private readonly SharpenPostProcessId;
  58667. /**
  58668. * @ignore
  58669. * ID of the image processing post process;
  58670. */
  58671. readonly ImageProcessingPostProcessId: string;
  58672. /**
  58673. * @ignore
  58674. * ID of the Fast Approximate Anti-Aliasing post process;
  58675. */
  58676. readonly FxaaPostProcessId: string;
  58677. /**
  58678. * ID of the chromatic aberration post process,
  58679. */
  58680. private readonly ChromaticAberrationPostProcessId;
  58681. /**
  58682. * ID of the grain post process
  58683. */
  58684. private readonly GrainPostProcessId;
  58685. /**
  58686. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58687. */
  58688. sharpen: SharpenPostProcess;
  58689. private _sharpenEffect;
  58690. private bloom;
  58691. /**
  58692. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58693. */
  58694. depthOfField: DepthOfFieldEffect;
  58695. /**
  58696. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58697. */
  58698. fxaa: FxaaPostProcess;
  58699. /**
  58700. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58701. */
  58702. imageProcessing: ImageProcessingPostProcess;
  58703. /**
  58704. * Chromatic aberration post process which will shift rgb colors in the image
  58705. */
  58706. chromaticAberration: ChromaticAberrationPostProcess;
  58707. private _chromaticAberrationEffect;
  58708. /**
  58709. * Grain post process which add noise to the image
  58710. */
  58711. grain: GrainPostProcess;
  58712. private _grainEffect;
  58713. /**
  58714. * Glow post process which adds a glow to emissive areas of the image
  58715. */
  58716. private _glowLayer;
  58717. /**
  58718. * Animations which can be used to tweak settings over a period of time
  58719. */
  58720. animations: Animation[];
  58721. private _imageProcessingConfigurationObserver;
  58722. private _sharpenEnabled;
  58723. private _bloomEnabled;
  58724. private _depthOfFieldEnabled;
  58725. private _depthOfFieldBlurLevel;
  58726. private _fxaaEnabled;
  58727. private _imageProcessingEnabled;
  58728. private _defaultPipelineTextureType;
  58729. private _bloomScale;
  58730. private _chromaticAberrationEnabled;
  58731. private _grainEnabled;
  58732. private _buildAllowed;
  58733. /**
  58734. * Gets active scene
  58735. */
  58736. readonly scene: Scene;
  58737. /**
  58738. * Enable or disable the sharpen process from the pipeline
  58739. */
  58740. sharpenEnabled: boolean;
  58741. private _resizeObserver;
  58742. private _hardwareScaleLevel;
  58743. private _bloomKernel;
  58744. /**
  58745. * Specifies the size of the bloom blur kernel, relative to the final output size
  58746. */
  58747. bloomKernel: number;
  58748. /**
  58749. * Specifies the weight of the bloom in the final rendering
  58750. */
  58751. private _bloomWeight;
  58752. /**
  58753. * Specifies the luma threshold for the area that will be blurred by the bloom
  58754. */
  58755. private _bloomThreshold;
  58756. private _hdr;
  58757. /**
  58758. * The strength of the bloom.
  58759. */
  58760. bloomWeight: number;
  58761. /**
  58762. * The strength of the bloom.
  58763. */
  58764. bloomThreshold: number;
  58765. /**
  58766. * The scale of the bloom, lower value will provide better performance.
  58767. */
  58768. bloomScale: number;
  58769. /**
  58770. * Enable or disable the bloom from the pipeline
  58771. */
  58772. bloomEnabled: boolean;
  58773. private _rebuildBloom;
  58774. /**
  58775. * If the depth of field is enabled.
  58776. */
  58777. depthOfFieldEnabled: boolean;
  58778. /**
  58779. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58780. */
  58781. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58782. /**
  58783. * If the anti aliasing is enabled.
  58784. */
  58785. fxaaEnabled: boolean;
  58786. private _samples;
  58787. /**
  58788. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58789. */
  58790. samples: number;
  58791. /**
  58792. * If image processing is enabled.
  58793. */
  58794. imageProcessingEnabled: boolean;
  58795. /**
  58796. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58797. */
  58798. glowLayerEnabled: boolean;
  58799. /**
  58800. * Gets the glow layer (or null if not defined)
  58801. */
  58802. readonly glowLayer: Nullable<GlowLayer>;
  58803. /**
  58804. * Enable or disable the chromaticAberration process from the pipeline
  58805. */
  58806. chromaticAberrationEnabled: boolean;
  58807. /**
  58808. * Enable or disable the grain process from the pipeline
  58809. */
  58810. grainEnabled: boolean;
  58811. /**
  58812. * @constructor
  58813. * @param name - The rendering pipeline name (default: "")
  58814. * @param hdr - If high dynamic range textures should be used (default: true)
  58815. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58816. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58817. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58818. */
  58819. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58820. /**
  58821. * Get the class name
  58822. * @returns "DefaultRenderingPipeline"
  58823. */
  58824. getClassName(): string;
  58825. /**
  58826. * Force the compilation of the entire pipeline.
  58827. */
  58828. prepare(): void;
  58829. private _hasCleared;
  58830. private _prevPostProcess;
  58831. private _prevPrevPostProcess;
  58832. private _setAutoClearAndTextureSharing;
  58833. private _depthOfFieldSceneObserver;
  58834. private _buildPipeline;
  58835. private _disposePostProcesses;
  58836. /**
  58837. * Adds a camera to the pipeline
  58838. * @param camera the camera to be added
  58839. */
  58840. addCamera(camera: Camera): void;
  58841. /**
  58842. * Removes a camera from the pipeline
  58843. * @param camera the camera to remove
  58844. */
  58845. removeCamera(camera: Camera): void;
  58846. /**
  58847. * Dispose of the pipeline and stop all post processes
  58848. */
  58849. dispose(): void;
  58850. /**
  58851. * Serialize the rendering pipeline (Used when exporting)
  58852. * @returns the serialized object
  58853. */
  58854. serialize(): any;
  58855. /**
  58856. * Parse the serialized pipeline
  58857. * @param source Source pipeline.
  58858. * @param scene The scene to load the pipeline to.
  58859. * @param rootUrl The URL of the serialized pipeline.
  58860. * @returns An instantiated pipeline from the serialized object.
  58861. */
  58862. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58863. }
  58864. }
  58865. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  58866. /** @hidden */
  58867. export var lensHighlightsPixelShader: {
  58868. name: string;
  58869. shader: string;
  58870. };
  58871. }
  58872. declare module "babylonjs/Shaders/depthOfField.fragment" {
  58873. /** @hidden */
  58874. export var depthOfFieldPixelShader: {
  58875. name: string;
  58876. shader: string;
  58877. };
  58878. }
  58879. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  58880. import { Camera } from "babylonjs/Cameras/camera";
  58881. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58882. import { Scene } from "babylonjs/scene";
  58883. import "babylonjs/Shaders/chromaticAberration.fragment";
  58884. import "babylonjs/Shaders/lensHighlights.fragment";
  58885. import "babylonjs/Shaders/depthOfField.fragment";
  58886. /**
  58887. * BABYLON.JS Chromatic Aberration GLSL Shader
  58888. * Author: Olivier Guyot
  58889. * Separates very slightly R, G and B colors on the edges of the screen
  58890. * Inspired by Francois Tarlier & Martins Upitis
  58891. */
  58892. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58893. /**
  58894. * @ignore
  58895. * The chromatic aberration PostProcess id in the pipeline
  58896. */
  58897. LensChromaticAberrationEffect: string;
  58898. /**
  58899. * @ignore
  58900. * The highlights enhancing PostProcess id in the pipeline
  58901. */
  58902. HighlightsEnhancingEffect: string;
  58903. /**
  58904. * @ignore
  58905. * The depth-of-field PostProcess id in the pipeline
  58906. */
  58907. LensDepthOfFieldEffect: string;
  58908. private _scene;
  58909. private _depthTexture;
  58910. private _grainTexture;
  58911. private _chromaticAberrationPostProcess;
  58912. private _highlightsPostProcess;
  58913. private _depthOfFieldPostProcess;
  58914. private _edgeBlur;
  58915. private _grainAmount;
  58916. private _chromaticAberration;
  58917. private _distortion;
  58918. private _highlightsGain;
  58919. private _highlightsThreshold;
  58920. private _dofDistance;
  58921. private _dofAperture;
  58922. private _dofDarken;
  58923. private _dofPentagon;
  58924. private _blurNoise;
  58925. /**
  58926. * @constructor
  58927. *
  58928. * Effect parameters are as follow:
  58929. * {
  58930. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58931. * edge_blur: number; // from 0 to x (1 for realism)
  58932. * distortion: number; // from 0 to x (1 for realism)
  58933. * grain_amount: number; // from 0 to 1
  58934. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58935. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58936. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58937. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58938. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58939. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58940. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58941. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58942. * }
  58943. * Note: if an effect parameter is unset, effect is disabled
  58944. *
  58945. * @param name The rendering pipeline name
  58946. * @param parameters - An object containing all parameters (see above)
  58947. * @param scene The scene linked to this pipeline
  58948. * @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)
  58949. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58950. */
  58951. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58952. /**
  58953. * Get the class name
  58954. * @returns "LensRenderingPipeline"
  58955. */
  58956. getClassName(): string;
  58957. /**
  58958. * Gets associated scene
  58959. */
  58960. readonly scene: Scene;
  58961. /**
  58962. * Gets or sets the edge blur
  58963. */
  58964. edgeBlur: number;
  58965. /**
  58966. * Gets or sets the grain amount
  58967. */
  58968. grainAmount: number;
  58969. /**
  58970. * Gets or sets the chromatic aberration amount
  58971. */
  58972. chromaticAberration: number;
  58973. /**
  58974. * Gets or sets the depth of field aperture
  58975. */
  58976. dofAperture: number;
  58977. /**
  58978. * Gets or sets the edge distortion
  58979. */
  58980. edgeDistortion: number;
  58981. /**
  58982. * Gets or sets the depth of field distortion
  58983. */
  58984. dofDistortion: number;
  58985. /**
  58986. * Gets or sets the darken out of focus amount
  58987. */
  58988. darkenOutOfFocus: number;
  58989. /**
  58990. * Gets or sets a boolean indicating if blur noise is enabled
  58991. */
  58992. blurNoise: boolean;
  58993. /**
  58994. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58995. */
  58996. pentagonBokeh: boolean;
  58997. /**
  58998. * Gets or sets the highlight grain amount
  58999. */
  59000. highlightsGain: number;
  59001. /**
  59002. * Gets or sets the highlight threshold
  59003. */
  59004. highlightsThreshold: number;
  59005. /**
  59006. * Sets the amount of blur at the edges
  59007. * @param amount blur amount
  59008. */
  59009. setEdgeBlur(amount: number): void;
  59010. /**
  59011. * Sets edge blur to 0
  59012. */
  59013. disableEdgeBlur(): void;
  59014. /**
  59015. * Sets the amout of grain
  59016. * @param amount Amount of grain
  59017. */
  59018. setGrainAmount(amount: number): void;
  59019. /**
  59020. * Set grain amount to 0
  59021. */
  59022. disableGrain(): void;
  59023. /**
  59024. * Sets the chromatic aberration amount
  59025. * @param amount amount of chromatic aberration
  59026. */
  59027. setChromaticAberration(amount: number): void;
  59028. /**
  59029. * Sets chromatic aberration amount to 0
  59030. */
  59031. disableChromaticAberration(): void;
  59032. /**
  59033. * Sets the EdgeDistortion amount
  59034. * @param amount amount of EdgeDistortion
  59035. */
  59036. setEdgeDistortion(amount: number): void;
  59037. /**
  59038. * Sets edge distortion to 0
  59039. */
  59040. disableEdgeDistortion(): void;
  59041. /**
  59042. * Sets the FocusDistance amount
  59043. * @param amount amount of FocusDistance
  59044. */
  59045. setFocusDistance(amount: number): void;
  59046. /**
  59047. * Disables depth of field
  59048. */
  59049. disableDepthOfField(): void;
  59050. /**
  59051. * Sets the Aperture amount
  59052. * @param amount amount of Aperture
  59053. */
  59054. setAperture(amount: number): void;
  59055. /**
  59056. * Sets the DarkenOutOfFocus amount
  59057. * @param amount amount of DarkenOutOfFocus
  59058. */
  59059. setDarkenOutOfFocus(amount: number): void;
  59060. private _pentagonBokehIsEnabled;
  59061. /**
  59062. * Creates a pentagon bokeh effect
  59063. */
  59064. enablePentagonBokeh(): void;
  59065. /**
  59066. * Disables the pentagon bokeh effect
  59067. */
  59068. disablePentagonBokeh(): void;
  59069. /**
  59070. * Enables noise blur
  59071. */
  59072. enableNoiseBlur(): void;
  59073. /**
  59074. * Disables noise blur
  59075. */
  59076. disableNoiseBlur(): void;
  59077. /**
  59078. * Sets the HighlightsGain amount
  59079. * @param amount amount of HighlightsGain
  59080. */
  59081. setHighlightsGain(amount: number): void;
  59082. /**
  59083. * Sets the HighlightsThreshold amount
  59084. * @param amount amount of HighlightsThreshold
  59085. */
  59086. setHighlightsThreshold(amount: number): void;
  59087. /**
  59088. * Disables highlights
  59089. */
  59090. disableHighlights(): void;
  59091. /**
  59092. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59093. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59094. */
  59095. dispose(disableDepthRender?: boolean): void;
  59096. private _createChromaticAberrationPostProcess;
  59097. private _createHighlightsPostProcess;
  59098. private _createDepthOfFieldPostProcess;
  59099. private _createGrainTexture;
  59100. }
  59101. }
  59102. declare module "babylonjs/Shaders/ssao2.fragment" {
  59103. /** @hidden */
  59104. export var ssao2PixelShader: {
  59105. name: string;
  59106. shader: string;
  59107. };
  59108. }
  59109. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59110. /** @hidden */
  59111. export var ssaoCombinePixelShader: {
  59112. name: string;
  59113. shader: string;
  59114. };
  59115. }
  59116. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59117. import { Camera } from "babylonjs/Cameras/camera";
  59118. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59119. import { Scene } from "babylonjs/scene";
  59120. import "babylonjs/Shaders/ssao2.fragment";
  59121. import "babylonjs/Shaders/ssaoCombine.fragment";
  59122. /**
  59123. * Render pipeline to produce ssao effect
  59124. */
  59125. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59126. /**
  59127. * @ignore
  59128. * The PassPostProcess id in the pipeline that contains the original scene color
  59129. */
  59130. SSAOOriginalSceneColorEffect: string;
  59131. /**
  59132. * @ignore
  59133. * The SSAO PostProcess id in the pipeline
  59134. */
  59135. SSAORenderEffect: string;
  59136. /**
  59137. * @ignore
  59138. * The horizontal blur PostProcess id in the pipeline
  59139. */
  59140. SSAOBlurHRenderEffect: string;
  59141. /**
  59142. * @ignore
  59143. * The vertical blur PostProcess id in the pipeline
  59144. */
  59145. SSAOBlurVRenderEffect: string;
  59146. /**
  59147. * @ignore
  59148. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59149. */
  59150. SSAOCombineRenderEffect: string;
  59151. /**
  59152. * The output strength of the SSAO post-process. Default value is 1.0.
  59153. */
  59154. totalStrength: number;
  59155. /**
  59156. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59157. */
  59158. maxZ: number;
  59159. /**
  59160. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59161. */
  59162. minZAspect: number;
  59163. private _samples;
  59164. /**
  59165. * Number of samples used for the SSAO calculations. Default value is 8
  59166. */
  59167. samples: number;
  59168. private _textureSamples;
  59169. /**
  59170. * Number of samples to use for antialiasing
  59171. */
  59172. textureSamples: number;
  59173. /**
  59174. * Ratio object used for SSAO ratio and blur ratio
  59175. */
  59176. private _ratio;
  59177. /**
  59178. * Dynamically generated sphere sampler.
  59179. */
  59180. private _sampleSphere;
  59181. /**
  59182. * Blur filter offsets
  59183. */
  59184. private _samplerOffsets;
  59185. private _expensiveBlur;
  59186. /**
  59187. * If bilateral blur should be used
  59188. */
  59189. expensiveBlur: boolean;
  59190. /**
  59191. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59192. */
  59193. radius: number;
  59194. /**
  59195. * The base color of the SSAO post-process
  59196. * The final result is "base + ssao" between [0, 1]
  59197. */
  59198. base: number;
  59199. /**
  59200. * Support test.
  59201. */
  59202. static readonly IsSupported: boolean;
  59203. private _scene;
  59204. private _depthTexture;
  59205. private _normalTexture;
  59206. private _randomTexture;
  59207. private _originalColorPostProcess;
  59208. private _ssaoPostProcess;
  59209. private _blurHPostProcess;
  59210. private _blurVPostProcess;
  59211. private _ssaoCombinePostProcess;
  59212. private _firstUpdate;
  59213. /**
  59214. * Gets active scene
  59215. */
  59216. readonly scene: Scene;
  59217. /**
  59218. * @constructor
  59219. * @param name The rendering pipeline name
  59220. * @param scene The scene linked to this pipeline
  59221. * @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 }
  59222. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59223. */
  59224. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59225. /**
  59226. * Get the class name
  59227. * @returns "SSAO2RenderingPipeline"
  59228. */
  59229. getClassName(): string;
  59230. /**
  59231. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59232. */
  59233. dispose(disableGeometryBufferRenderer?: boolean): void;
  59234. private _createBlurPostProcess;
  59235. /** @hidden */
  59236. _rebuild(): void;
  59237. private _bits;
  59238. private _radicalInverse_VdC;
  59239. private _hammersley;
  59240. private _hemisphereSample_uniform;
  59241. private _generateHemisphere;
  59242. private _createSSAOPostProcess;
  59243. private _createSSAOCombinePostProcess;
  59244. private _createRandomTexture;
  59245. /**
  59246. * Serialize the rendering pipeline (Used when exporting)
  59247. * @returns the serialized object
  59248. */
  59249. serialize(): any;
  59250. /**
  59251. * Parse the serialized pipeline
  59252. * @param source Source pipeline.
  59253. * @param scene The scene to load the pipeline to.
  59254. * @param rootUrl The URL of the serialized pipeline.
  59255. * @returns An instantiated pipeline from the serialized object.
  59256. */
  59257. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59258. }
  59259. }
  59260. declare module "babylonjs/Shaders/ssao.fragment" {
  59261. /** @hidden */
  59262. export var ssaoPixelShader: {
  59263. name: string;
  59264. shader: string;
  59265. };
  59266. }
  59267. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59268. import { Camera } from "babylonjs/Cameras/camera";
  59269. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59270. import { Scene } from "babylonjs/scene";
  59271. import "babylonjs/Shaders/ssao.fragment";
  59272. import "babylonjs/Shaders/ssaoCombine.fragment";
  59273. /**
  59274. * Render pipeline to produce ssao effect
  59275. */
  59276. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59277. /**
  59278. * @ignore
  59279. * The PassPostProcess id in the pipeline that contains the original scene color
  59280. */
  59281. SSAOOriginalSceneColorEffect: string;
  59282. /**
  59283. * @ignore
  59284. * The SSAO PostProcess id in the pipeline
  59285. */
  59286. SSAORenderEffect: string;
  59287. /**
  59288. * @ignore
  59289. * The horizontal blur PostProcess id in the pipeline
  59290. */
  59291. SSAOBlurHRenderEffect: string;
  59292. /**
  59293. * @ignore
  59294. * The vertical blur PostProcess id in the pipeline
  59295. */
  59296. SSAOBlurVRenderEffect: string;
  59297. /**
  59298. * @ignore
  59299. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59300. */
  59301. SSAOCombineRenderEffect: string;
  59302. /**
  59303. * The output strength of the SSAO post-process. Default value is 1.0.
  59304. */
  59305. totalStrength: number;
  59306. /**
  59307. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59308. */
  59309. radius: number;
  59310. /**
  59311. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59312. * Must not be equal to fallOff and superior to fallOff.
  59313. * Default value is 0.0075
  59314. */
  59315. area: number;
  59316. /**
  59317. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59318. * Must not be equal to area and inferior to area.
  59319. * Default value is 0.000001
  59320. */
  59321. fallOff: number;
  59322. /**
  59323. * The base color of the SSAO post-process
  59324. * The final result is "base + ssao" between [0, 1]
  59325. */
  59326. base: number;
  59327. private _scene;
  59328. private _depthTexture;
  59329. private _randomTexture;
  59330. private _originalColorPostProcess;
  59331. private _ssaoPostProcess;
  59332. private _blurHPostProcess;
  59333. private _blurVPostProcess;
  59334. private _ssaoCombinePostProcess;
  59335. private _firstUpdate;
  59336. /**
  59337. * Gets active scene
  59338. */
  59339. readonly scene: Scene;
  59340. /**
  59341. * @constructor
  59342. * @param name - The rendering pipeline name
  59343. * @param scene - The scene linked to this pipeline
  59344. * @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 }
  59345. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59346. */
  59347. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59348. /**
  59349. * Get the class name
  59350. * @returns "SSAORenderingPipeline"
  59351. */
  59352. getClassName(): string;
  59353. /**
  59354. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59355. */
  59356. dispose(disableDepthRender?: boolean): void;
  59357. private _createBlurPostProcess;
  59358. /** @hidden */
  59359. _rebuild(): void;
  59360. private _createSSAOPostProcess;
  59361. private _createSSAOCombinePostProcess;
  59362. private _createRandomTexture;
  59363. }
  59364. }
  59365. declare module "babylonjs/Shaders/standard.fragment" {
  59366. /** @hidden */
  59367. export var standardPixelShader: {
  59368. name: string;
  59369. shader: string;
  59370. };
  59371. }
  59372. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59373. import { Nullable } from "babylonjs/types";
  59374. import { IAnimatable } from "babylonjs/Misc/tools";
  59375. import { Camera } from "babylonjs/Cameras/camera";
  59376. import { Texture } from "babylonjs/Materials/Textures/texture";
  59377. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59378. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59379. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59380. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59381. import { IDisposable } from "babylonjs/scene";
  59382. import { SpotLight } from "babylonjs/Lights/spotLight";
  59383. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59384. import { Scene } from "babylonjs/scene";
  59385. import { Animation } from "babylonjs/Animations/animation";
  59386. import "babylonjs/Shaders/standard.fragment";
  59387. /**
  59388. * Standard rendering pipeline
  59389. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59390. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59391. */
  59392. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59393. /**
  59394. * Public members
  59395. */
  59396. /**
  59397. * Post-process which contains the original scene color before the pipeline applies all the effects
  59398. */
  59399. originalPostProcess: Nullable<PostProcess>;
  59400. /**
  59401. * Post-process used to down scale an image x4
  59402. */
  59403. downSampleX4PostProcess: Nullable<PostProcess>;
  59404. /**
  59405. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59406. */
  59407. brightPassPostProcess: Nullable<PostProcess>;
  59408. /**
  59409. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59410. */
  59411. blurHPostProcesses: PostProcess[];
  59412. /**
  59413. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59414. */
  59415. blurVPostProcesses: PostProcess[];
  59416. /**
  59417. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59418. */
  59419. textureAdderPostProcess: Nullable<PostProcess>;
  59420. /**
  59421. * Post-process used to create volumetric lighting effect
  59422. */
  59423. volumetricLightPostProcess: Nullable<PostProcess>;
  59424. /**
  59425. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59426. */
  59427. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59428. /**
  59429. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59430. */
  59431. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59432. /**
  59433. * Post-process used to merge the volumetric light effect and the real scene color
  59434. */
  59435. volumetricLightMergePostProces: Nullable<PostProcess>;
  59436. /**
  59437. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59438. */
  59439. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59440. /**
  59441. * Base post-process used to calculate the average luminance of the final image for HDR
  59442. */
  59443. luminancePostProcess: Nullable<PostProcess>;
  59444. /**
  59445. * Post-processes used to create down sample post-processes in order to get
  59446. * the average luminance of the final image for HDR
  59447. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59448. */
  59449. luminanceDownSamplePostProcesses: PostProcess[];
  59450. /**
  59451. * Post-process used to create a HDR effect (light adaptation)
  59452. */
  59453. hdrPostProcess: Nullable<PostProcess>;
  59454. /**
  59455. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59456. */
  59457. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59458. /**
  59459. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59460. */
  59461. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59462. /**
  59463. * Post-process used to merge the final HDR post-process and the real scene color
  59464. */
  59465. hdrFinalPostProcess: Nullable<PostProcess>;
  59466. /**
  59467. * Post-process used to create a lens flare effect
  59468. */
  59469. lensFlarePostProcess: Nullable<PostProcess>;
  59470. /**
  59471. * Post-process that merges the result of the lens flare post-process and the real scene color
  59472. */
  59473. lensFlareComposePostProcess: Nullable<PostProcess>;
  59474. /**
  59475. * Post-process used to create a motion blur effect
  59476. */
  59477. motionBlurPostProcess: Nullable<PostProcess>;
  59478. /**
  59479. * Post-process used to create a depth of field effect
  59480. */
  59481. depthOfFieldPostProcess: Nullable<PostProcess>;
  59482. /**
  59483. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59484. */
  59485. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59486. /**
  59487. * Represents the brightness threshold in order to configure the illuminated surfaces
  59488. */
  59489. brightThreshold: number;
  59490. /**
  59491. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59492. */
  59493. blurWidth: number;
  59494. /**
  59495. * Sets if the blur for highlighted surfaces must be only horizontal
  59496. */
  59497. horizontalBlur: boolean;
  59498. /**
  59499. * Gets the overall exposure used by the pipeline
  59500. */
  59501. /**
  59502. * Sets the overall exposure used by the pipeline
  59503. */
  59504. exposure: number;
  59505. /**
  59506. * Texture used typically to simulate "dirty" on camera lens
  59507. */
  59508. lensTexture: Nullable<Texture>;
  59509. /**
  59510. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59511. */
  59512. volumetricLightCoefficient: number;
  59513. /**
  59514. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59515. */
  59516. volumetricLightPower: number;
  59517. /**
  59518. * Used the set the blur intensity to smooth the volumetric lights
  59519. */
  59520. volumetricLightBlurScale: number;
  59521. /**
  59522. * Light (spot or directional) used to generate the volumetric lights rays
  59523. * The source light must have a shadow generate so the pipeline can get its
  59524. * depth map
  59525. */
  59526. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59527. /**
  59528. * For eye adaptation, represents the minimum luminance the eye can see
  59529. */
  59530. hdrMinimumLuminance: number;
  59531. /**
  59532. * For eye adaptation, represents the decrease luminance speed
  59533. */
  59534. hdrDecreaseRate: number;
  59535. /**
  59536. * For eye adaptation, represents the increase luminance speed
  59537. */
  59538. hdrIncreaseRate: number;
  59539. /**
  59540. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59541. */
  59542. /**
  59543. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59544. */
  59545. hdrAutoExposure: boolean;
  59546. /**
  59547. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59548. */
  59549. lensColorTexture: Nullable<Texture>;
  59550. /**
  59551. * The overall strengh for the lens flare effect
  59552. */
  59553. lensFlareStrength: number;
  59554. /**
  59555. * Dispersion coefficient for lens flare ghosts
  59556. */
  59557. lensFlareGhostDispersal: number;
  59558. /**
  59559. * Main lens flare halo width
  59560. */
  59561. lensFlareHaloWidth: number;
  59562. /**
  59563. * Based on the lens distortion effect, defines how much the lens flare result
  59564. * is distorted
  59565. */
  59566. lensFlareDistortionStrength: number;
  59567. /**
  59568. * Lens star texture must be used to simulate rays on the flares and is available
  59569. * in the documentation
  59570. */
  59571. lensStarTexture: Nullable<Texture>;
  59572. /**
  59573. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59574. * flare effect by taking account of the dirt texture
  59575. */
  59576. lensFlareDirtTexture: Nullable<Texture>;
  59577. /**
  59578. * Represents the focal length for the depth of field effect
  59579. */
  59580. depthOfFieldDistance: number;
  59581. /**
  59582. * Represents the blur intensity for the blurred part of the depth of field effect
  59583. */
  59584. depthOfFieldBlurWidth: number;
  59585. /**
  59586. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59587. */
  59588. /**
  59589. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59590. */
  59591. motionStrength: number;
  59592. /**
  59593. * Gets wether or not the motion blur post-process is object based or screen based.
  59594. */
  59595. /**
  59596. * Sets wether or not the motion blur post-process should be object based or screen based
  59597. */
  59598. objectBasedMotionBlur: boolean;
  59599. /**
  59600. * List of animations for the pipeline (IAnimatable implementation)
  59601. */
  59602. animations: Animation[];
  59603. /**
  59604. * Private members
  59605. */
  59606. private _scene;
  59607. private _currentDepthOfFieldSource;
  59608. private _basePostProcess;
  59609. private _fixedExposure;
  59610. private _currentExposure;
  59611. private _hdrAutoExposure;
  59612. private _hdrCurrentLuminance;
  59613. private _motionStrength;
  59614. private _isObjectBasedMotionBlur;
  59615. private _floatTextureType;
  59616. private _ratio;
  59617. private _bloomEnabled;
  59618. private _depthOfFieldEnabled;
  59619. private _vlsEnabled;
  59620. private _lensFlareEnabled;
  59621. private _hdrEnabled;
  59622. private _motionBlurEnabled;
  59623. private _fxaaEnabled;
  59624. private _motionBlurSamples;
  59625. private _volumetricLightStepsCount;
  59626. private _samples;
  59627. /**
  59628. * @ignore
  59629. * Specifies if the bloom pipeline is enabled
  59630. */
  59631. BloomEnabled: boolean;
  59632. /**
  59633. * @ignore
  59634. * Specifies if the depth of field pipeline is enabed
  59635. */
  59636. DepthOfFieldEnabled: boolean;
  59637. /**
  59638. * @ignore
  59639. * Specifies if the lens flare pipeline is enabed
  59640. */
  59641. LensFlareEnabled: boolean;
  59642. /**
  59643. * @ignore
  59644. * Specifies if the HDR pipeline is enabled
  59645. */
  59646. HDREnabled: boolean;
  59647. /**
  59648. * @ignore
  59649. * Specifies if the volumetric lights scattering effect is enabled
  59650. */
  59651. VLSEnabled: boolean;
  59652. /**
  59653. * @ignore
  59654. * Specifies if the motion blur effect is enabled
  59655. */
  59656. MotionBlurEnabled: boolean;
  59657. /**
  59658. * Specifies if anti-aliasing is enabled
  59659. */
  59660. fxaaEnabled: boolean;
  59661. /**
  59662. * Specifies the number of steps used to calculate the volumetric lights
  59663. * Typically in interval [50, 200]
  59664. */
  59665. volumetricLightStepsCount: number;
  59666. /**
  59667. * Specifies the number of samples used for the motion blur effect
  59668. * Typically in interval [16, 64]
  59669. */
  59670. motionBlurSamples: number;
  59671. /**
  59672. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59673. */
  59674. samples: number;
  59675. /**
  59676. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59677. * @constructor
  59678. * @param name The rendering pipeline name
  59679. * @param scene The scene linked to this pipeline
  59680. * @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)
  59681. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59682. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59683. */
  59684. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59685. private _buildPipeline;
  59686. private _createDownSampleX4PostProcess;
  59687. private _createBrightPassPostProcess;
  59688. private _createBlurPostProcesses;
  59689. private _createTextureAdderPostProcess;
  59690. private _createVolumetricLightPostProcess;
  59691. private _createLuminancePostProcesses;
  59692. private _createHdrPostProcess;
  59693. private _createLensFlarePostProcess;
  59694. private _createDepthOfFieldPostProcess;
  59695. private _createMotionBlurPostProcess;
  59696. private _getDepthTexture;
  59697. private _disposePostProcesses;
  59698. /**
  59699. * Dispose of the pipeline and stop all post processes
  59700. */
  59701. dispose(): void;
  59702. /**
  59703. * Serialize the rendering pipeline (Used when exporting)
  59704. * @returns the serialized object
  59705. */
  59706. serialize(): any;
  59707. /**
  59708. * Parse the serialized pipeline
  59709. * @param source Source pipeline.
  59710. * @param scene The scene to load the pipeline to.
  59711. * @param rootUrl The URL of the serialized pipeline.
  59712. * @returns An instantiated pipeline from the serialized object.
  59713. */
  59714. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59715. /**
  59716. * Luminance steps
  59717. */
  59718. static LuminanceSteps: number;
  59719. }
  59720. }
  59721. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  59722. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  59723. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  59724. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  59725. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  59726. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  59727. }
  59728. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  59729. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  59730. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59731. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59732. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59733. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59734. }
  59735. declare module "babylonjs/Shaders/tonemap.fragment" {
  59736. /** @hidden */
  59737. export var tonemapPixelShader: {
  59738. name: string;
  59739. shader: string;
  59740. };
  59741. }
  59742. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  59743. import { Camera } from "babylonjs/Cameras/camera";
  59744. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59745. import "babylonjs/Shaders/tonemap.fragment";
  59746. import { Engine } from "babylonjs/Engines/engine";
  59747. /** Defines operator used for tonemapping */
  59748. export enum TonemappingOperator {
  59749. /** Hable */
  59750. Hable = 0,
  59751. /** Reinhard */
  59752. Reinhard = 1,
  59753. /** HejiDawson */
  59754. HejiDawson = 2,
  59755. /** Photographic */
  59756. Photographic = 3
  59757. }
  59758. /**
  59759. * Defines a post process to apply tone mapping
  59760. */
  59761. export class TonemapPostProcess extends PostProcess {
  59762. private _operator;
  59763. /** Defines the required exposure adjustement */
  59764. exposureAdjustment: number;
  59765. /**
  59766. * Creates a new TonemapPostProcess
  59767. * @param name defines the name of the postprocess
  59768. * @param _operator defines the operator to use
  59769. * @param exposureAdjustment defines the required exposure adjustement
  59770. * @param camera defines the camera to use (can be null)
  59771. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59772. * @param engine defines the hosting engine (can be ignore if camera is set)
  59773. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59774. */
  59775. constructor(name: string, _operator: TonemappingOperator,
  59776. /** Defines the required exposure adjustement */
  59777. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59778. }
  59779. }
  59780. declare module "babylonjs/Shaders/depth.vertex" {
  59781. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59782. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59783. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59784. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59785. /** @hidden */
  59786. export var depthVertexShader: {
  59787. name: string;
  59788. shader: string;
  59789. };
  59790. }
  59791. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  59792. /** @hidden */
  59793. export var volumetricLightScatteringPixelShader: {
  59794. name: string;
  59795. shader: string;
  59796. };
  59797. }
  59798. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  59799. /** @hidden */
  59800. export var volumetricLightScatteringPassPixelShader: {
  59801. name: string;
  59802. shader: string;
  59803. };
  59804. }
  59805. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  59806. import { Vector3 } from "babylonjs/Maths/math";
  59807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59808. import { Mesh } from "babylonjs/Meshes/mesh";
  59809. import { Camera } from "babylonjs/Cameras/camera";
  59810. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59811. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59812. import { Scene } from "babylonjs/scene";
  59813. import "babylonjs/Meshes/Builders/planeBuilder";
  59814. import "babylonjs/Shaders/depth.vertex";
  59815. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  59816. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  59817. import { Engine } from "babylonjs/Engines/engine";
  59818. /**
  59819. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59820. */
  59821. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59822. private _volumetricLightScatteringPass;
  59823. private _volumetricLightScatteringRTT;
  59824. private _viewPort;
  59825. private _screenCoordinates;
  59826. private _cachedDefines;
  59827. /**
  59828. * If not undefined, the mesh position is computed from the attached node position
  59829. */
  59830. attachedNode: {
  59831. position: Vector3;
  59832. };
  59833. /**
  59834. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59835. */
  59836. customMeshPosition: Vector3;
  59837. /**
  59838. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59839. */
  59840. useCustomMeshPosition: boolean;
  59841. /**
  59842. * If the post-process should inverse the light scattering direction
  59843. */
  59844. invert: boolean;
  59845. /**
  59846. * The internal mesh used by the post-process
  59847. */
  59848. mesh: Mesh;
  59849. /**
  59850. * @hidden
  59851. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59852. */
  59853. useDiffuseColor: boolean;
  59854. /**
  59855. * Array containing the excluded meshes not rendered in the internal pass
  59856. */
  59857. excludedMeshes: AbstractMesh[];
  59858. /**
  59859. * Controls the overall intensity of the post-process
  59860. */
  59861. exposure: number;
  59862. /**
  59863. * Dissipates each sample's contribution in range [0, 1]
  59864. */
  59865. decay: number;
  59866. /**
  59867. * Controls the overall intensity of each sample
  59868. */
  59869. weight: number;
  59870. /**
  59871. * Controls the density of each sample
  59872. */
  59873. density: number;
  59874. /**
  59875. * @constructor
  59876. * @param name The post-process name
  59877. * @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)
  59878. * @param camera The camera that the post-process will be attached to
  59879. * @param mesh The mesh used to create the light scattering
  59880. * @param samples The post-process quality, default 100
  59881. * @param samplingModeThe post-process filtering mode
  59882. * @param engine The babylon engine
  59883. * @param reusable If the post-process is reusable
  59884. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59885. */
  59886. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59887. /**
  59888. * Returns the string "VolumetricLightScatteringPostProcess"
  59889. * @returns "VolumetricLightScatteringPostProcess"
  59890. */
  59891. getClassName(): string;
  59892. private _isReady;
  59893. /**
  59894. * Sets the new light position for light scattering effect
  59895. * @param position The new custom light position
  59896. */
  59897. setCustomMeshPosition(position: Vector3): void;
  59898. /**
  59899. * Returns the light position for light scattering effect
  59900. * @return Vector3 The custom light position
  59901. */
  59902. getCustomMeshPosition(): Vector3;
  59903. /**
  59904. * Disposes the internal assets and detaches the post-process from the camera
  59905. */
  59906. dispose(camera: Camera): void;
  59907. /**
  59908. * Returns the render target texture used by the post-process
  59909. * @return the render target texture used by the post-process
  59910. */
  59911. getPass(): RenderTargetTexture;
  59912. private _meshExcluded;
  59913. private _createPass;
  59914. private _updateMeshScreenCoordinates;
  59915. /**
  59916. * Creates a default mesh for the Volumeric Light Scattering post-process
  59917. * @param name The mesh name
  59918. * @param scene The scene where to create the mesh
  59919. * @return the default mesh
  59920. */
  59921. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59922. }
  59923. }
  59924. declare module "babylonjs/PostProcesses/index" {
  59925. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  59926. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  59927. export * from "babylonjs/PostProcesses/bloomEffect";
  59928. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  59929. export * from "babylonjs/PostProcesses/blurPostProcess";
  59930. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59931. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  59932. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  59933. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  59934. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59935. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  59936. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  59937. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  59938. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59939. export * from "babylonjs/PostProcesses/filterPostProcess";
  59940. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  59941. export * from "babylonjs/PostProcesses/grainPostProcess";
  59942. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  59943. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59944. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  59945. export * from "babylonjs/PostProcesses/passPostProcess";
  59946. export * from "babylonjs/PostProcesses/postProcess";
  59947. export * from "babylonjs/PostProcesses/postProcessManager";
  59948. export * from "babylonjs/PostProcesses/refractionPostProcess";
  59949. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  59950. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  59951. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  59952. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  59953. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  59954. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  59955. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  59956. }
  59957. declare module "babylonjs/Probes/index" {
  59958. export * from "babylonjs/Probes/reflectionProbe";
  59959. }
  59960. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  59961. import { Scene } from "babylonjs/scene";
  59962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59963. import { Color3 } from "babylonjs/Maths/math";
  59964. import { SmartArray } from "babylonjs/Misc/smartArray";
  59965. import { ISceneComponent } from "babylonjs/sceneComponent";
  59966. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  59967. import "babylonjs/Meshes/Builders/boxBuilder";
  59968. import "babylonjs/Shaders/color.fragment";
  59969. import "babylonjs/Shaders/color.vertex";
  59970. module "babylonjs/scene" {
  59971. interface Scene {
  59972. /** @hidden (Backing field) */
  59973. _boundingBoxRenderer: BoundingBoxRenderer;
  59974. /** @hidden (Backing field) */
  59975. _forceShowBoundingBoxes: boolean;
  59976. /**
  59977. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59978. */
  59979. forceShowBoundingBoxes: boolean;
  59980. /**
  59981. * Gets the bounding box renderer associated with the scene
  59982. * @returns a BoundingBoxRenderer
  59983. */
  59984. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59985. }
  59986. }
  59987. module "babylonjs/Meshes/abstractMesh" {
  59988. interface AbstractMesh {
  59989. /** @hidden (Backing field) */
  59990. _showBoundingBox: boolean;
  59991. /**
  59992. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59993. */
  59994. showBoundingBox: boolean;
  59995. }
  59996. }
  59997. /**
  59998. * Component responsible of rendering the bounding box of the meshes in a scene.
  59999. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60000. */
  60001. export class BoundingBoxRenderer implements ISceneComponent {
  60002. /**
  60003. * The component name helpfull to identify the component in the list of scene components.
  60004. */
  60005. readonly name: string;
  60006. /**
  60007. * The scene the component belongs to.
  60008. */
  60009. scene: Scene;
  60010. /**
  60011. * Color of the bounding box lines placed in front of an object
  60012. */
  60013. frontColor: Color3;
  60014. /**
  60015. * Color of the bounding box lines placed behind an object
  60016. */
  60017. backColor: Color3;
  60018. /**
  60019. * Defines if the renderer should show the back lines or not
  60020. */
  60021. showBackLines: boolean;
  60022. /**
  60023. * @hidden
  60024. */
  60025. renderList: SmartArray<BoundingBox>;
  60026. private _colorShader;
  60027. private _vertexBuffers;
  60028. private _indexBuffer;
  60029. private _fillIndexBuffer;
  60030. private _fillIndexData;
  60031. /**
  60032. * Instantiates a new bounding box renderer in a scene.
  60033. * @param scene the scene the renderer renders in
  60034. */
  60035. constructor(scene: Scene);
  60036. /**
  60037. * Registers the component in a given scene
  60038. */
  60039. register(): void;
  60040. private _evaluateSubMesh;
  60041. private _activeMesh;
  60042. private _prepareRessources;
  60043. private _createIndexBuffer;
  60044. /**
  60045. * Rebuilds the elements related to this component in case of
  60046. * context lost for instance.
  60047. */
  60048. rebuild(): void;
  60049. /**
  60050. * @hidden
  60051. */
  60052. reset(): void;
  60053. /**
  60054. * Render the bounding boxes of a specific rendering group
  60055. * @param renderingGroupId defines the rendering group to render
  60056. */
  60057. render(renderingGroupId: number): void;
  60058. /**
  60059. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60060. * @param mesh Define the mesh to render the occlusion bounding box for
  60061. */
  60062. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60063. /**
  60064. * Dispose and release the resources attached to this renderer.
  60065. */
  60066. dispose(): void;
  60067. }
  60068. }
  60069. declare module "babylonjs/Shaders/depth.fragment" {
  60070. /** @hidden */
  60071. export var depthPixelShader: {
  60072. name: string;
  60073. shader: string;
  60074. };
  60075. }
  60076. declare module "babylonjs/Rendering/depthRenderer" {
  60077. import { Nullable } from "babylonjs/types";
  60078. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60079. import { Scene } from "babylonjs/scene";
  60080. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60081. import { Camera } from "babylonjs/Cameras/camera";
  60082. import "babylonjs/Shaders/depth.fragment";
  60083. import "babylonjs/Shaders/depth.vertex";
  60084. /**
  60085. * This represents a depth renderer in Babylon.
  60086. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60087. */
  60088. export class DepthRenderer {
  60089. private _scene;
  60090. private _depthMap;
  60091. private _effect;
  60092. private _cachedDefines;
  60093. private _camera;
  60094. /**
  60095. * Specifiess that the depth renderer will only be used within
  60096. * the camera it is created for.
  60097. * This can help forcing its rendering during the camera processing.
  60098. */
  60099. useOnlyInActiveCamera: boolean;
  60100. /** @hidden */
  60101. static _SceneComponentInitialization: (scene: Scene) => void;
  60102. /**
  60103. * Instantiates a depth renderer
  60104. * @param scene The scene the renderer belongs to
  60105. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60106. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60107. */
  60108. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60109. /**
  60110. * Creates the depth rendering effect and checks if the effect is ready.
  60111. * @param subMesh The submesh to be used to render the depth map of
  60112. * @param useInstances If multiple world instances should be used
  60113. * @returns if the depth renderer is ready to render the depth map
  60114. */
  60115. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60116. /**
  60117. * Gets the texture which the depth map will be written to.
  60118. * @returns The depth map texture
  60119. */
  60120. getDepthMap(): RenderTargetTexture;
  60121. /**
  60122. * Disposes of the depth renderer.
  60123. */
  60124. dispose(): void;
  60125. }
  60126. }
  60127. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60128. import { Nullable } from "babylonjs/types";
  60129. import { Scene } from "babylonjs/scene";
  60130. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60131. import { Camera } from "babylonjs/Cameras/camera";
  60132. import { ISceneComponent } from "babylonjs/sceneComponent";
  60133. module "babylonjs/scene" {
  60134. interface Scene {
  60135. /** @hidden (Backing field) */
  60136. _depthRenderer: {
  60137. [id: string]: DepthRenderer;
  60138. };
  60139. /**
  60140. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60141. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60142. * @returns the created depth renderer
  60143. */
  60144. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60145. /**
  60146. * Disables a depth renderer for a given camera
  60147. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60148. */
  60149. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60150. }
  60151. }
  60152. /**
  60153. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60154. * in several rendering techniques.
  60155. */
  60156. export class DepthRendererSceneComponent implements ISceneComponent {
  60157. /**
  60158. * The component name helpfull to identify the component in the list of scene components.
  60159. */
  60160. readonly name: string;
  60161. /**
  60162. * The scene the component belongs to.
  60163. */
  60164. scene: Scene;
  60165. /**
  60166. * Creates a new instance of the component for the given scene
  60167. * @param scene Defines the scene to register the component in
  60168. */
  60169. constructor(scene: Scene);
  60170. /**
  60171. * Registers the component in a given scene
  60172. */
  60173. register(): void;
  60174. /**
  60175. * Rebuilds the elements related to this component in case of
  60176. * context lost for instance.
  60177. */
  60178. rebuild(): void;
  60179. /**
  60180. * Disposes the component and the associated ressources
  60181. */
  60182. dispose(): void;
  60183. private _gatherRenderTargets;
  60184. private _gatherActiveCameraRenderTargets;
  60185. }
  60186. }
  60187. declare module "babylonjs/Shaders/outline.fragment" {
  60188. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60189. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60190. /** @hidden */
  60191. export var outlinePixelShader: {
  60192. name: string;
  60193. shader: string;
  60194. };
  60195. }
  60196. declare module "babylonjs/Shaders/outline.vertex" {
  60197. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60198. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60199. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60200. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60201. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60202. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60203. /** @hidden */
  60204. export var outlineVertexShader: {
  60205. name: string;
  60206. shader: string;
  60207. };
  60208. }
  60209. declare module "babylonjs/Rendering/outlineRenderer" {
  60210. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60211. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60212. import { Scene } from "babylonjs/scene";
  60213. import { ISceneComponent } from "babylonjs/sceneComponent";
  60214. import "babylonjs/Shaders/outline.fragment";
  60215. import "babylonjs/Shaders/outline.vertex";
  60216. module "babylonjs/scene" {
  60217. interface Scene {
  60218. /** @hidden */
  60219. _outlineRenderer: OutlineRenderer;
  60220. /**
  60221. * Gets the outline renderer associated with the scene
  60222. * @returns a OutlineRenderer
  60223. */
  60224. getOutlineRenderer(): OutlineRenderer;
  60225. }
  60226. }
  60227. module "babylonjs/Meshes/abstractMesh" {
  60228. interface AbstractMesh {
  60229. /** @hidden (Backing field) */
  60230. _renderOutline: boolean;
  60231. /**
  60232. * Gets or sets a boolean indicating if the outline must be rendered as well
  60233. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60234. */
  60235. renderOutline: boolean;
  60236. /** @hidden (Backing field) */
  60237. _renderOverlay: boolean;
  60238. /**
  60239. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60240. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60241. */
  60242. renderOverlay: boolean;
  60243. }
  60244. }
  60245. /**
  60246. * This class is responsible to draw bothe outline/overlay of meshes.
  60247. * It should not be used directly but through the available method on mesh.
  60248. */
  60249. export class OutlineRenderer implements ISceneComponent {
  60250. /**
  60251. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60252. */
  60253. private static _StencilReference;
  60254. /**
  60255. * The name of the component. Each component must have a unique name.
  60256. */
  60257. name: string;
  60258. /**
  60259. * The scene the component belongs to.
  60260. */
  60261. scene: Scene;
  60262. /**
  60263. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60264. */
  60265. zOffset: number;
  60266. private _engine;
  60267. private _effect;
  60268. private _cachedDefines;
  60269. private _savedDepthWrite;
  60270. /**
  60271. * Instantiates a new outline renderer. (There could be only one per scene).
  60272. * @param scene Defines the scene it belongs to
  60273. */
  60274. constructor(scene: Scene);
  60275. /**
  60276. * Register the component to one instance of a scene.
  60277. */
  60278. register(): void;
  60279. /**
  60280. * Rebuilds the elements related to this component in case of
  60281. * context lost for instance.
  60282. */
  60283. rebuild(): void;
  60284. /**
  60285. * Disposes the component and the associated ressources.
  60286. */
  60287. dispose(): void;
  60288. /**
  60289. * Renders the outline in the canvas.
  60290. * @param subMesh Defines the sumesh to render
  60291. * @param batch Defines the batch of meshes in case of instances
  60292. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60293. */
  60294. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60295. /**
  60296. * Returns whether or not the outline renderer is ready for a given submesh.
  60297. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60298. * @param subMesh Defines the submesh to check readyness for
  60299. * @param useInstances Defines wheter wee are trying to render instances or not
  60300. * @returns true if ready otherwise false
  60301. */
  60302. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60303. private _beforeRenderingMesh;
  60304. private _afterRenderingMesh;
  60305. }
  60306. }
  60307. declare module "babylonjs/Rendering/index" {
  60308. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60309. export * from "babylonjs/Rendering/depthRenderer";
  60310. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60311. export * from "babylonjs/Rendering/edgesRenderer";
  60312. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60313. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60314. export * from "babylonjs/Rendering/outlineRenderer";
  60315. export * from "babylonjs/Rendering/renderingGroup";
  60316. export * from "babylonjs/Rendering/renderingManager";
  60317. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60318. }
  60319. declare module "babylonjs/Sprites/index" {
  60320. export * from "babylonjs/Sprites/sprite";
  60321. export * from "babylonjs/Sprites/spriteManager";
  60322. export * from "babylonjs/Sprites/spriteSceneComponent";
  60323. }
  60324. declare module "babylonjs/Misc/assetsManager" {
  60325. import { Scene } from "babylonjs/scene";
  60326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60327. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60328. import { Skeleton } from "babylonjs/Bones/skeleton";
  60329. import { Observable } from "babylonjs/Misc/observable";
  60330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60331. import { Texture } from "babylonjs/Materials/Textures/texture";
  60332. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60333. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60334. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60335. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60336. /**
  60337. * Defines the list of states available for a task inside a AssetsManager
  60338. */
  60339. export enum AssetTaskState {
  60340. /**
  60341. * Initialization
  60342. */
  60343. INIT = 0,
  60344. /**
  60345. * Running
  60346. */
  60347. RUNNING = 1,
  60348. /**
  60349. * Done
  60350. */
  60351. DONE = 2,
  60352. /**
  60353. * Error
  60354. */
  60355. ERROR = 3
  60356. }
  60357. /**
  60358. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60359. */
  60360. export abstract class AbstractAssetTask {
  60361. /**
  60362. * Task name
  60363. */ name: string;
  60364. /**
  60365. * Callback called when the task is successful
  60366. */
  60367. onSuccess: (task: any) => void;
  60368. /**
  60369. * Callback called when the task is not successful
  60370. */
  60371. onError: (task: any, message?: string, exception?: any) => void;
  60372. /**
  60373. * Creates a new AssetsManager
  60374. * @param name defines the name of the task
  60375. */
  60376. constructor(
  60377. /**
  60378. * Task name
  60379. */ name: string);
  60380. private _isCompleted;
  60381. private _taskState;
  60382. private _errorObject;
  60383. /**
  60384. * Get if the task is completed
  60385. */
  60386. readonly isCompleted: boolean;
  60387. /**
  60388. * Gets the current state of the task
  60389. */
  60390. readonly taskState: AssetTaskState;
  60391. /**
  60392. * Gets the current error object (if task is in error)
  60393. */
  60394. readonly errorObject: {
  60395. message?: string;
  60396. exception?: any;
  60397. };
  60398. /**
  60399. * Internal only
  60400. * @hidden
  60401. */
  60402. _setErrorObject(message?: string, exception?: any): void;
  60403. /**
  60404. * Execute the current task
  60405. * @param scene defines the scene where you want your assets to be loaded
  60406. * @param onSuccess is a callback called when the task is successfully executed
  60407. * @param onError is a callback called if an error occurs
  60408. */
  60409. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60410. /**
  60411. * Execute the current task
  60412. * @param scene defines the scene where you want your assets to be loaded
  60413. * @param onSuccess is a callback called when the task is successfully executed
  60414. * @param onError is a callback called if an error occurs
  60415. */
  60416. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60417. /**
  60418. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60419. * This can be used with failed tasks that have the reason for failure fixed.
  60420. */
  60421. reset(): void;
  60422. private onErrorCallback;
  60423. private onDoneCallback;
  60424. }
  60425. /**
  60426. * Define the interface used by progress events raised during assets loading
  60427. */
  60428. export interface IAssetsProgressEvent {
  60429. /**
  60430. * Defines the number of remaining tasks to process
  60431. */
  60432. remainingCount: number;
  60433. /**
  60434. * Defines the total number of tasks
  60435. */
  60436. totalCount: number;
  60437. /**
  60438. * Defines the task that was just processed
  60439. */
  60440. task: AbstractAssetTask;
  60441. }
  60442. /**
  60443. * Class used to share progress information about assets loading
  60444. */
  60445. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60446. /**
  60447. * Defines the number of remaining tasks to process
  60448. */
  60449. remainingCount: number;
  60450. /**
  60451. * Defines the total number of tasks
  60452. */
  60453. totalCount: number;
  60454. /**
  60455. * Defines the task that was just processed
  60456. */
  60457. task: AbstractAssetTask;
  60458. /**
  60459. * Creates a AssetsProgressEvent
  60460. * @param remainingCount defines the number of remaining tasks to process
  60461. * @param totalCount defines the total number of tasks
  60462. * @param task defines the task that was just processed
  60463. */
  60464. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60465. }
  60466. /**
  60467. * Define a task used by AssetsManager to load meshes
  60468. */
  60469. export class MeshAssetTask extends AbstractAssetTask {
  60470. /**
  60471. * Defines the name of the task
  60472. */
  60473. name: string;
  60474. /**
  60475. * Defines the list of mesh's names you want to load
  60476. */
  60477. meshesNames: any;
  60478. /**
  60479. * Defines the root url to use as a base to load your meshes and associated resources
  60480. */
  60481. rootUrl: string;
  60482. /**
  60483. * Defines the filename of the scene to load from
  60484. */
  60485. sceneFilename: string;
  60486. /**
  60487. * Gets the list of loaded meshes
  60488. */
  60489. loadedMeshes: Array<AbstractMesh>;
  60490. /**
  60491. * Gets the list of loaded particle systems
  60492. */
  60493. loadedParticleSystems: Array<IParticleSystem>;
  60494. /**
  60495. * Gets the list of loaded skeletons
  60496. */
  60497. loadedSkeletons: Array<Skeleton>;
  60498. /**
  60499. * Gets the list of loaded animation groups
  60500. */
  60501. loadedAnimationGroups: Array<AnimationGroup>;
  60502. /**
  60503. * Callback called when the task is successful
  60504. */
  60505. onSuccess: (task: MeshAssetTask) => void;
  60506. /**
  60507. * Callback called when the task is successful
  60508. */
  60509. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60510. /**
  60511. * Creates a new MeshAssetTask
  60512. * @param name defines the name of the task
  60513. * @param meshesNames defines the list of mesh's names you want to load
  60514. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60515. * @param sceneFilename defines the filename of the scene to load from
  60516. */
  60517. constructor(
  60518. /**
  60519. * Defines the name of the task
  60520. */
  60521. name: string,
  60522. /**
  60523. * Defines the list of mesh's names you want to load
  60524. */
  60525. meshesNames: any,
  60526. /**
  60527. * Defines the root url to use as a base to load your meshes and associated resources
  60528. */
  60529. rootUrl: string,
  60530. /**
  60531. * Defines the filename of the scene to load from
  60532. */
  60533. sceneFilename: string);
  60534. /**
  60535. * Execute the current task
  60536. * @param scene defines the scene where you want your assets to be loaded
  60537. * @param onSuccess is a callback called when the task is successfully executed
  60538. * @param onError is a callback called if an error occurs
  60539. */
  60540. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60541. }
  60542. /**
  60543. * Define a task used by AssetsManager to load text content
  60544. */
  60545. export class TextFileAssetTask extends AbstractAssetTask {
  60546. /**
  60547. * Defines the name of the task
  60548. */
  60549. name: string;
  60550. /**
  60551. * Defines the location of the file to load
  60552. */
  60553. url: string;
  60554. /**
  60555. * Gets the loaded text string
  60556. */
  60557. text: string;
  60558. /**
  60559. * Callback called when the task is successful
  60560. */
  60561. onSuccess: (task: TextFileAssetTask) => void;
  60562. /**
  60563. * Callback called when the task is successful
  60564. */
  60565. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60566. /**
  60567. * Creates a new TextFileAssetTask object
  60568. * @param name defines the name of the task
  60569. * @param url defines the location of the file to load
  60570. */
  60571. constructor(
  60572. /**
  60573. * Defines the name of the task
  60574. */
  60575. name: string,
  60576. /**
  60577. * Defines the location of the file to load
  60578. */
  60579. url: string);
  60580. /**
  60581. * Execute the current task
  60582. * @param scene defines the scene where you want your assets to be loaded
  60583. * @param onSuccess is a callback called when the task is successfully executed
  60584. * @param onError is a callback called if an error occurs
  60585. */
  60586. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60587. }
  60588. /**
  60589. * Define a task used by AssetsManager to load binary data
  60590. */
  60591. export class BinaryFileAssetTask extends AbstractAssetTask {
  60592. /**
  60593. * Defines the name of the task
  60594. */
  60595. name: string;
  60596. /**
  60597. * Defines the location of the file to load
  60598. */
  60599. url: string;
  60600. /**
  60601. * Gets the lodaded data (as an array buffer)
  60602. */
  60603. data: ArrayBuffer;
  60604. /**
  60605. * Callback called when the task is successful
  60606. */
  60607. onSuccess: (task: BinaryFileAssetTask) => void;
  60608. /**
  60609. * Callback called when the task is successful
  60610. */
  60611. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60612. /**
  60613. * Creates a new BinaryFileAssetTask object
  60614. * @param name defines the name of the new task
  60615. * @param url defines the location of the file to load
  60616. */
  60617. constructor(
  60618. /**
  60619. * Defines the name of the task
  60620. */
  60621. name: string,
  60622. /**
  60623. * Defines the location of the file to load
  60624. */
  60625. url: string);
  60626. /**
  60627. * Execute the current task
  60628. * @param scene defines the scene where you want your assets to be loaded
  60629. * @param onSuccess is a callback called when the task is successfully executed
  60630. * @param onError is a callback called if an error occurs
  60631. */
  60632. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60633. }
  60634. /**
  60635. * Define a task used by AssetsManager to load images
  60636. */
  60637. export class ImageAssetTask extends AbstractAssetTask {
  60638. /**
  60639. * Defines the name of the task
  60640. */
  60641. name: string;
  60642. /**
  60643. * Defines the location of the image to load
  60644. */
  60645. url: string;
  60646. /**
  60647. * Gets the loaded images
  60648. */
  60649. image: HTMLImageElement;
  60650. /**
  60651. * Callback called when the task is successful
  60652. */
  60653. onSuccess: (task: ImageAssetTask) => void;
  60654. /**
  60655. * Callback called when the task is successful
  60656. */
  60657. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60658. /**
  60659. * Creates a new ImageAssetTask
  60660. * @param name defines the name of the task
  60661. * @param url defines the location of the image to load
  60662. */
  60663. constructor(
  60664. /**
  60665. * Defines the name of the task
  60666. */
  60667. name: string,
  60668. /**
  60669. * Defines the location of the image to load
  60670. */
  60671. url: string);
  60672. /**
  60673. * Execute the current task
  60674. * @param scene defines the scene where you want your assets to be loaded
  60675. * @param onSuccess is a callback called when the task is successfully executed
  60676. * @param onError is a callback called if an error occurs
  60677. */
  60678. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60679. }
  60680. /**
  60681. * Defines the interface used by texture loading tasks
  60682. */
  60683. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60684. /**
  60685. * Gets the loaded texture
  60686. */
  60687. texture: TEX;
  60688. }
  60689. /**
  60690. * Define a task used by AssetsManager to load 2D textures
  60691. */
  60692. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60693. /**
  60694. * Defines the name of the task
  60695. */
  60696. name: string;
  60697. /**
  60698. * Defines the location of the file to load
  60699. */
  60700. url: string;
  60701. /**
  60702. * Defines if mipmap should not be generated (default is false)
  60703. */
  60704. noMipmap?: boolean | undefined;
  60705. /**
  60706. * Defines if texture must be inverted on Y axis (default is false)
  60707. */
  60708. invertY?: boolean | undefined;
  60709. /**
  60710. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60711. */
  60712. samplingMode: number;
  60713. /**
  60714. * Gets the loaded texture
  60715. */
  60716. texture: Texture;
  60717. /**
  60718. * Callback called when the task is successful
  60719. */
  60720. onSuccess: (task: TextureAssetTask) => void;
  60721. /**
  60722. * Callback called when the task is successful
  60723. */
  60724. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60725. /**
  60726. * Creates a new TextureAssetTask object
  60727. * @param name defines the name of the task
  60728. * @param url defines the location of the file to load
  60729. * @param noMipmap defines if mipmap should not be generated (default is false)
  60730. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60731. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60732. */
  60733. constructor(
  60734. /**
  60735. * Defines the name of the task
  60736. */
  60737. name: string,
  60738. /**
  60739. * Defines the location of the file to load
  60740. */
  60741. url: string,
  60742. /**
  60743. * Defines if mipmap should not be generated (default is false)
  60744. */
  60745. noMipmap?: boolean | undefined,
  60746. /**
  60747. * Defines if texture must be inverted on Y axis (default is false)
  60748. */
  60749. invertY?: boolean | undefined,
  60750. /**
  60751. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60752. */
  60753. samplingMode?: number);
  60754. /**
  60755. * Execute the current task
  60756. * @param scene defines the scene where you want your assets to be loaded
  60757. * @param onSuccess is a callback called when the task is successfully executed
  60758. * @param onError is a callback called if an error occurs
  60759. */
  60760. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60761. }
  60762. /**
  60763. * Define a task used by AssetsManager to load cube textures
  60764. */
  60765. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60766. /**
  60767. * Defines the name of the task
  60768. */
  60769. name: string;
  60770. /**
  60771. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60772. */
  60773. url: string;
  60774. /**
  60775. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60776. */
  60777. extensions?: string[] | undefined;
  60778. /**
  60779. * Defines if mipmaps should not be generated (default is false)
  60780. */
  60781. noMipmap?: boolean | undefined;
  60782. /**
  60783. * Defines the explicit list of files (undefined by default)
  60784. */
  60785. files?: string[] | undefined;
  60786. /**
  60787. * Gets the loaded texture
  60788. */
  60789. texture: CubeTexture;
  60790. /**
  60791. * Callback called when the task is successful
  60792. */
  60793. onSuccess: (task: CubeTextureAssetTask) => void;
  60794. /**
  60795. * Callback called when the task is successful
  60796. */
  60797. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60798. /**
  60799. * Creates a new CubeTextureAssetTask
  60800. * @param name defines the name of the task
  60801. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60802. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60803. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60804. * @param files defines the explicit list of files (undefined by default)
  60805. */
  60806. constructor(
  60807. /**
  60808. * Defines the name of the task
  60809. */
  60810. name: string,
  60811. /**
  60812. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60813. */
  60814. url: string,
  60815. /**
  60816. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60817. */
  60818. extensions?: string[] | undefined,
  60819. /**
  60820. * Defines if mipmaps should not be generated (default is false)
  60821. */
  60822. noMipmap?: boolean | undefined,
  60823. /**
  60824. * Defines the explicit list of files (undefined by default)
  60825. */
  60826. files?: string[] | undefined);
  60827. /**
  60828. * Execute the current task
  60829. * @param scene defines the scene where you want your assets to be loaded
  60830. * @param onSuccess is a callback called when the task is successfully executed
  60831. * @param onError is a callback called if an error occurs
  60832. */
  60833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60834. }
  60835. /**
  60836. * Define a task used by AssetsManager to load HDR cube textures
  60837. */
  60838. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60839. /**
  60840. * Defines the name of the task
  60841. */
  60842. name: string;
  60843. /**
  60844. * Defines the location of the file to load
  60845. */
  60846. url: string;
  60847. /**
  60848. * Defines the desired size (the more it increases the longer the generation will be)
  60849. */
  60850. size: number;
  60851. /**
  60852. * Defines if mipmaps should not be generated (default is false)
  60853. */
  60854. noMipmap: boolean;
  60855. /**
  60856. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60857. */
  60858. generateHarmonics: boolean;
  60859. /**
  60860. * 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)
  60861. */
  60862. gammaSpace: boolean;
  60863. /**
  60864. * Internal Use Only
  60865. */
  60866. reserved: boolean;
  60867. /**
  60868. * Gets the loaded texture
  60869. */
  60870. texture: HDRCubeTexture;
  60871. /**
  60872. * Callback called when the task is successful
  60873. */
  60874. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60875. /**
  60876. * Callback called when the task is successful
  60877. */
  60878. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60879. /**
  60880. * Creates a new HDRCubeTextureAssetTask object
  60881. * @param name defines the name of the task
  60882. * @param url defines the location of the file to load
  60883. * @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.
  60884. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60885. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60886. * @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)
  60887. * @param reserved Internal use only
  60888. */
  60889. constructor(
  60890. /**
  60891. * Defines the name of the task
  60892. */
  60893. name: string,
  60894. /**
  60895. * Defines the location of the file to load
  60896. */
  60897. url: string,
  60898. /**
  60899. * Defines the desired size (the more it increases the longer the generation will be)
  60900. */
  60901. size: number,
  60902. /**
  60903. * Defines if mipmaps should not be generated (default is false)
  60904. */
  60905. noMipmap?: boolean,
  60906. /**
  60907. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60908. */
  60909. generateHarmonics?: boolean,
  60910. /**
  60911. * 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)
  60912. */
  60913. gammaSpace?: boolean,
  60914. /**
  60915. * Internal Use Only
  60916. */
  60917. reserved?: boolean);
  60918. /**
  60919. * Execute the current task
  60920. * @param scene defines the scene where you want your assets to be loaded
  60921. * @param onSuccess is a callback called when the task is successfully executed
  60922. * @param onError is a callback called if an error occurs
  60923. */
  60924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60925. }
  60926. /**
  60927. * Define a task used by AssetsManager to load Equirectangular cube textures
  60928. */
  60929. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60930. /**
  60931. * Defines the name of the task
  60932. */
  60933. name: string;
  60934. /**
  60935. * Defines the location of the file to load
  60936. */
  60937. url: string;
  60938. /**
  60939. * Defines the desired size (the more it increases the longer the generation will be)
  60940. */
  60941. size: number;
  60942. /**
  60943. * Defines if mipmaps should not be generated (default is false)
  60944. */
  60945. noMipmap: boolean;
  60946. /**
  60947. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60948. * but the standard material would require them in Gamma space) (default is true)
  60949. */
  60950. gammaSpace: boolean;
  60951. /**
  60952. * Gets the loaded texture
  60953. */
  60954. texture: EquiRectangularCubeTexture;
  60955. /**
  60956. * Callback called when the task is successful
  60957. */
  60958. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60959. /**
  60960. * Callback called when the task is successful
  60961. */
  60962. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60963. /**
  60964. * Creates a new EquiRectangularCubeTextureAssetTask object
  60965. * @param name defines the name of the task
  60966. * @param url defines the location of the file to load
  60967. * @param size defines the desired size (the more it increases the longer the generation will be)
  60968. * If the size is omitted this implies you are using a preprocessed cubemap.
  60969. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60970. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60971. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60972. * (default is true)
  60973. */
  60974. constructor(
  60975. /**
  60976. * Defines the name of the task
  60977. */
  60978. name: string,
  60979. /**
  60980. * Defines the location of the file to load
  60981. */
  60982. url: string,
  60983. /**
  60984. * Defines the desired size (the more it increases the longer the generation will be)
  60985. */
  60986. size: number,
  60987. /**
  60988. * Defines if mipmaps should not be generated (default is false)
  60989. */
  60990. noMipmap?: boolean,
  60991. /**
  60992. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60993. * but the standard material would require them in Gamma space) (default is true)
  60994. */
  60995. gammaSpace?: boolean);
  60996. /**
  60997. * Execute the current task
  60998. * @param scene defines the scene where you want your assets to be loaded
  60999. * @param onSuccess is a callback called when the task is successfully executed
  61000. * @param onError is a callback called if an error occurs
  61001. */
  61002. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61003. }
  61004. /**
  61005. * This class can be used to easily import assets into a scene
  61006. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61007. */
  61008. export class AssetsManager {
  61009. private _scene;
  61010. private _isLoading;
  61011. protected _tasks: AbstractAssetTask[];
  61012. protected _waitingTasksCount: number;
  61013. protected _totalTasksCount: number;
  61014. /**
  61015. * Callback called when all tasks are processed
  61016. */
  61017. onFinish: (tasks: AbstractAssetTask[]) => void;
  61018. /**
  61019. * Callback called when a task is successful
  61020. */
  61021. onTaskSuccess: (task: AbstractAssetTask) => void;
  61022. /**
  61023. * Callback called when a task had an error
  61024. */
  61025. onTaskError: (task: AbstractAssetTask) => void;
  61026. /**
  61027. * Callback called when a task is done (whatever the result is)
  61028. */
  61029. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61030. /**
  61031. * Observable called when all tasks are processed
  61032. */
  61033. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61034. /**
  61035. * Observable called when a task had an error
  61036. */
  61037. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61038. /**
  61039. * Observable called when all tasks were executed
  61040. */
  61041. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61042. /**
  61043. * Observable called when a task is done (whatever the result is)
  61044. */
  61045. onProgressObservable: Observable<IAssetsProgressEvent>;
  61046. /**
  61047. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61048. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61049. */
  61050. useDefaultLoadingScreen: boolean;
  61051. /**
  61052. * Creates a new AssetsManager
  61053. * @param scene defines the scene to work on
  61054. */
  61055. constructor(scene: Scene);
  61056. /**
  61057. * Add a MeshAssetTask to the list of active tasks
  61058. * @param taskName defines the name of the new task
  61059. * @param meshesNames defines the name of meshes to load
  61060. * @param rootUrl defines the root url to use to locate files
  61061. * @param sceneFilename defines the filename of the scene file
  61062. * @returns a new MeshAssetTask object
  61063. */
  61064. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61065. /**
  61066. * Add a TextFileAssetTask to the list of active tasks
  61067. * @param taskName defines the name of the new task
  61068. * @param url defines the url of the file to load
  61069. * @returns a new TextFileAssetTask object
  61070. */
  61071. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61072. /**
  61073. * Add a BinaryFileAssetTask to the list of active tasks
  61074. * @param taskName defines the name of the new task
  61075. * @param url defines the url of the file to load
  61076. * @returns a new BinaryFileAssetTask object
  61077. */
  61078. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61079. /**
  61080. * Add a ImageAssetTask to the list of active tasks
  61081. * @param taskName defines the name of the new task
  61082. * @param url defines the url of the file to load
  61083. * @returns a new ImageAssetTask object
  61084. */
  61085. addImageTask(taskName: string, url: string): ImageAssetTask;
  61086. /**
  61087. * Add a TextureAssetTask to the list of active tasks
  61088. * @param taskName defines the name of the new task
  61089. * @param url defines the url of the file to load
  61090. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61091. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61092. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61093. * @returns a new TextureAssetTask object
  61094. */
  61095. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61096. /**
  61097. * Add a CubeTextureAssetTask to the list of active tasks
  61098. * @param taskName defines the name of the new task
  61099. * @param url defines the url of the file to load
  61100. * @param extensions defines the extension to use to load the cube map (can be null)
  61101. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61102. * @param files defines the list of files to load (can be null)
  61103. * @returns a new CubeTextureAssetTask object
  61104. */
  61105. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61106. /**
  61107. *
  61108. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61109. * @param taskName defines the name of the new task
  61110. * @param url defines the url of the file to load
  61111. * @param size defines the size you want for the cubemap (can be null)
  61112. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61113. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61114. * @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)
  61115. * @param reserved Internal use only
  61116. * @returns a new HDRCubeTextureAssetTask object
  61117. */
  61118. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61119. /**
  61120. *
  61121. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61122. * @param taskName defines the name of the new task
  61123. * @param url defines the url of the file to load
  61124. * @param size defines the size you want for the cubemap (can be null)
  61125. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61126. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61127. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61128. * @returns a new EquiRectangularCubeTextureAssetTask object
  61129. */
  61130. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61131. /**
  61132. * Remove a task from the assets manager.
  61133. * @param task the task to remove
  61134. */
  61135. removeTask(task: AbstractAssetTask): void;
  61136. private _decreaseWaitingTasksCount;
  61137. private _runTask;
  61138. /**
  61139. * Reset the AssetsManager and remove all tasks
  61140. * @return the current instance of the AssetsManager
  61141. */
  61142. reset(): AssetsManager;
  61143. /**
  61144. * Start the loading process
  61145. * @return the current instance of the AssetsManager
  61146. */
  61147. load(): AssetsManager;
  61148. /**
  61149. * Start the loading process as an async operation
  61150. * @return a promise returning the list of failed tasks
  61151. */
  61152. loadAsync(): Promise<void>;
  61153. }
  61154. }
  61155. declare module "babylonjs/Misc/deferred" {
  61156. /**
  61157. * Wrapper class for promise with external resolve and reject.
  61158. */
  61159. export class Deferred<T> {
  61160. /**
  61161. * The promise associated with this deferred object.
  61162. */
  61163. readonly promise: Promise<T>;
  61164. private _resolve;
  61165. private _reject;
  61166. /**
  61167. * The resolve method of the promise associated with this deferred object.
  61168. */
  61169. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61170. /**
  61171. * The reject method of the promise associated with this deferred object.
  61172. */
  61173. readonly reject: (reason?: any) => void;
  61174. /**
  61175. * Constructor for this deferred object.
  61176. */
  61177. constructor();
  61178. }
  61179. }
  61180. declare module "babylonjs/Misc/meshExploder" {
  61181. import { Mesh } from "babylonjs/Meshes/mesh";
  61182. /**
  61183. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61184. */
  61185. export class MeshExploder {
  61186. private _centerMesh;
  61187. private _meshes;
  61188. private _meshesOrigins;
  61189. private _toCenterVectors;
  61190. private _scaledDirection;
  61191. private _newPosition;
  61192. private _centerPosition;
  61193. /**
  61194. * Explodes meshes from a center mesh.
  61195. * @param meshes The meshes to explode.
  61196. * @param centerMesh The mesh to be center of explosion.
  61197. */
  61198. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61199. private _setCenterMesh;
  61200. /**
  61201. * Get class name
  61202. * @returns "MeshExploder"
  61203. */
  61204. getClassName(): string;
  61205. /**
  61206. * "Exploded meshes"
  61207. * @returns Array of meshes with the centerMesh at index 0.
  61208. */
  61209. getMeshes(): Array<Mesh>;
  61210. /**
  61211. * Explodes meshes giving a specific direction
  61212. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61213. */
  61214. explode(direction?: number): void;
  61215. }
  61216. }
  61217. declare module "babylonjs/Misc/filesInput" {
  61218. import { Engine } from "babylonjs/Engines/engine";
  61219. import { Scene } from "babylonjs/scene";
  61220. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61221. /**
  61222. * Class used to help managing file picking and drag'n'drop
  61223. */
  61224. export class FilesInput {
  61225. /**
  61226. * List of files ready to be loaded
  61227. */
  61228. static readonly FilesToLoad: {
  61229. [key: string]: File;
  61230. };
  61231. /**
  61232. * Callback called when a file is processed
  61233. */
  61234. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61235. private _engine;
  61236. private _currentScene;
  61237. private _sceneLoadedCallback;
  61238. private _progressCallback;
  61239. private _additionalRenderLoopLogicCallback;
  61240. private _textureLoadingCallback;
  61241. private _startingProcessingFilesCallback;
  61242. private _onReloadCallback;
  61243. private _errorCallback;
  61244. private _elementToMonitor;
  61245. private _sceneFileToLoad;
  61246. private _filesToLoad;
  61247. /**
  61248. * Creates a new FilesInput
  61249. * @param engine defines the rendering engine
  61250. * @param scene defines the hosting scene
  61251. * @param sceneLoadedCallback callback called when scene is loaded
  61252. * @param progressCallback callback called to track progress
  61253. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61254. * @param textureLoadingCallback callback called when a texture is loading
  61255. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61256. * @param onReloadCallback callback called when a reload is requested
  61257. * @param errorCallback callback call if an error occurs
  61258. */
  61259. 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);
  61260. private _dragEnterHandler;
  61261. private _dragOverHandler;
  61262. private _dropHandler;
  61263. /**
  61264. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61265. * @param elementToMonitor defines the DOM element to track
  61266. */
  61267. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61268. /**
  61269. * Release all associated resources
  61270. */
  61271. dispose(): void;
  61272. private renderFunction;
  61273. private drag;
  61274. private drop;
  61275. private _traverseFolder;
  61276. private _processFiles;
  61277. /**
  61278. * Load files from a drop event
  61279. * @param event defines the drop event to use as source
  61280. */
  61281. loadFiles(event: any): void;
  61282. private _processReload;
  61283. /**
  61284. * Reload the current scene from the loaded files
  61285. */
  61286. reload(): void;
  61287. }
  61288. }
  61289. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61290. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61291. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61292. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61293. }
  61294. declare module "babylonjs/Misc/sceneOptimizer" {
  61295. import { Scene, IDisposable } from "babylonjs/scene";
  61296. import { Observable } from "babylonjs/Misc/observable";
  61297. /**
  61298. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61299. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61300. */
  61301. export class SceneOptimization {
  61302. /**
  61303. * Defines the priority of this optimization (0 by default which means first in the list)
  61304. */
  61305. priority: number;
  61306. /**
  61307. * Gets a string describing the action executed by the current optimization
  61308. * @returns description string
  61309. */
  61310. getDescription(): string;
  61311. /**
  61312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61313. * @param scene defines the current scene where to apply this optimization
  61314. * @param optimizer defines the current optimizer
  61315. * @returns true if everything that can be done was applied
  61316. */
  61317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61318. /**
  61319. * Creates the SceneOptimization object
  61320. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61321. * @param desc defines the description associated with the optimization
  61322. */
  61323. constructor(
  61324. /**
  61325. * Defines the priority of this optimization (0 by default which means first in the list)
  61326. */
  61327. priority?: number);
  61328. }
  61329. /**
  61330. * Defines an optimization used to reduce the size of render target textures
  61331. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61332. */
  61333. export class TextureOptimization extends SceneOptimization {
  61334. /**
  61335. * Defines the priority of this optimization (0 by default which means first in the list)
  61336. */
  61337. priority: number;
  61338. /**
  61339. * 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
  61340. */
  61341. maximumSize: number;
  61342. /**
  61343. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61344. */
  61345. step: number;
  61346. /**
  61347. * Gets a string describing the action executed by the current optimization
  61348. * @returns description string
  61349. */
  61350. getDescription(): string;
  61351. /**
  61352. * Creates the TextureOptimization object
  61353. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61354. * @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
  61355. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61356. */
  61357. constructor(
  61358. /**
  61359. * Defines the priority of this optimization (0 by default which means first in the list)
  61360. */
  61361. priority?: number,
  61362. /**
  61363. * 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
  61364. */
  61365. maximumSize?: number,
  61366. /**
  61367. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61368. */
  61369. step?: number);
  61370. /**
  61371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61372. * @param scene defines the current scene where to apply this optimization
  61373. * @param optimizer defines the current optimizer
  61374. * @returns true if everything that can be done was applied
  61375. */
  61376. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61377. }
  61378. /**
  61379. * Defines an optimization used to increase or decrease the rendering resolution
  61380. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61381. */
  61382. export class HardwareScalingOptimization extends SceneOptimization {
  61383. /**
  61384. * Defines the priority of this optimization (0 by default which means first in the list)
  61385. */
  61386. priority: number;
  61387. /**
  61388. * Defines the maximum scale to use (2 by default)
  61389. */
  61390. maximumScale: number;
  61391. /**
  61392. * Defines the step to use between two passes (0.5 by default)
  61393. */
  61394. step: number;
  61395. private _currentScale;
  61396. private _directionOffset;
  61397. /**
  61398. * Gets a string describing the action executed by the current optimization
  61399. * @return description string
  61400. */
  61401. getDescription(): string;
  61402. /**
  61403. * Creates the HardwareScalingOptimization object
  61404. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61405. * @param maximumScale defines the maximum scale to use (2 by default)
  61406. * @param step defines the step to use between two passes (0.5 by default)
  61407. */
  61408. constructor(
  61409. /**
  61410. * Defines the priority of this optimization (0 by default which means first in the list)
  61411. */
  61412. priority?: number,
  61413. /**
  61414. * Defines the maximum scale to use (2 by default)
  61415. */
  61416. maximumScale?: number,
  61417. /**
  61418. * Defines the step to use between two passes (0.5 by default)
  61419. */
  61420. step?: number);
  61421. /**
  61422. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61423. * @param scene defines the current scene where to apply this optimization
  61424. * @param optimizer defines the current optimizer
  61425. * @returns true if everything that can be done was applied
  61426. */
  61427. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61428. }
  61429. /**
  61430. * Defines an optimization used to remove shadows
  61431. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61432. */
  61433. export class ShadowsOptimization extends SceneOptimization {
  61434. /**
  61435. * Gets a string describing the action executed by the current optimization
  61436. * @return description string
  61437. */
  61438. getDescription(): string;
  61439. /**
  61440. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61441. * @param scene defines the current scene where to apply this optimization
  61442. * @param optimizer defines the current optimizer
  61443. * @returns true if everything that can be done was applied
  61444. */
  61445. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61446. }
  61447. /**
  61448. * Defines an optimization used to turn post-processes off
  61449. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61450. */
  61451. export class PostProcessesOptimization extends SceneOptimization {
  61452. /**
  61453. * Gets a string describing the action executed by the current optimization
  61454. * @return description string
  61455. */
  61456. getDescription(): string;
  61457. /**
  61458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61459. * @param scene defines the current scene where to apply this optimization
  61460. * @param optimizer defines the current optimizer
  61461. * @returns true if everything that can be done was applied
  61462. */
  61463. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61464. }
  61465. /**
  61466. * Defines an optimization used to turn lens flares off
  61467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61468. */
  61469. export class LensFlaresOptimization extends SceneOptimization {
  61470. /**
  61471. * Gets a string describing the action executed by the current optimization
  61472. * @return description string
  61473. */
  61474. getDescription(): string;
  61475. /**
  61476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61477. * @param scene defines the current scene where to apply this optimization
  61478. * @param optimizer defines the current optimizer
  61479. * @returns true if everything that can be done was applied
  61480. */
  61481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61482. }
  61483. /**
  61484. * Defines an optimization based on user defined callback.
  61485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61486. */
  61487. export class CustomOptimization extends SceneOptimization {
  61488. /**
  61489. * Callback called to apply the custom optimization.
  61490. */
  61491. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61492. /**
  61493. * Callback called to get custom description
  61494. */
  61495. onGetDescription: () => string;
  61496. /**
  61497. * Gets a string describing the action executed by the current optimization
  61498. * @returns description string
  61499. */
  61500. getDescription(): string;
  61501. /**
  61502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61503. * @param scene defines the current scene where to apply this optimization
  61504. * @param optimizer defines the current optimizer
  61505. * @returns true if everything that can be done was applied
  61506. */
  61507. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61508. }
  61509. /**
  61510. * Defines an optimization used to turn particles off
  61511. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61512. */
  61513. export class ParticlesOptimization extends SceneOptimization {
  61514. /**
  61515. * Gets a string describing the action executed by the current optimization
  61516. * @return description string
  61517. */
  61518. getDescription(): string;
  61519. /**
  61520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61521. * @param scene defines the current scene where to apply this optimization
  61522. * @param optimizer defines the current optimizer
  61523. * @returns true if everything that can be done was applied
  61524. */
  61525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61526. }
  61527. /**
  61528. * Defines an optimization used to turn render targets off
  61529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61530. */
  61531. export class RenderTargetsOptimization extends SceneOptimization {
  61532. /**
  61533. * Gets a string describing the action executed by the current optimization
  61534. * @return description string
  61535. */
  61536. getDescription(): string;
  61537. /**
  61538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61539. * @param scene defines the current scene where to apply this optimization
  61540. * @param optimizer defines the current optimizer
  61541. * @returns true if everything that can be done was applied
  61542. */
  61543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61544. }
  61545. /**
  61546. * Defines an optimization used to merge meshes with compatible materials
  61547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61548. */
  61549. export class MergeMeshesOptimization extends SceneOptimization {
  61550. private static _UpdateSelectionTree;
  61551. /**
  61552. * Gets or sets a boolean which defines if optimization octree has to be updated
  61553. */
  61554. /**
  61555. * Gets or sets a boolean which defines if optimization octree has to be updated
  61556. */
  61557. static UpdateSelectionTree: boolean;
  61558. /**
  61559. * Gets a string describing the action executed by the current optimization
  61560. * @return description string
  61561. */
  61562. getDescription(): string;
  61563. private _canBeMerged;
  61564. /**
  61565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61566. * @param scene defines the current scene where to apply this optimization
  61567. * @param optimizer defines the current optimizer
  61568. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61569. * @returns true if everything that can be done was applied
  61570. */
  61571. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61572. }
  61573. /**
  61574. * Defines a list of options used by SceneOptimizer
  61575. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61576. */
  61577. export class SceneOptimizerOptions {
  61578. /**
  61579. * Defines the target frame rate to reach (60 by default)
  61580. */
  61581. targetFrameRate: number;
  61582. /**
  61583. * Defines the interval between two checkes (2000ms by default)
  61584. */
  61585. trackerDuration: number;
  61586. /**
  61587. * Gets the list of optimizations to apply
  61588. */
  61589. optimizations: SceneOptimization[];
  61590. /**
  61591. * Creates a new list of options used by SceneOptimizer
  61592. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61593. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61594. */
  61595. constructor(
  61596. /**
  61597. * Defines the target frame rate to reach (60 by default)
  61598. */
  61599. targetFrameRate?: number,
  61600. /**
  61601. * Defines the interval between two checkes (2000ms by default)
  61602. */
  61603. trackerDuration?: number);
  61604. /**
  61605. * Add a new optimization
  61606. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61607. * @returns the current SceneOptimizerOptions
  61608. */
  61609. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61610. /**
  61611. * Add a new custom optimization
  61612. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61613. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61614. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61615. * @returns the current SceneOptimizerOptions
  61616. */
  61617. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61618. /**
  61619. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61620. * @param targetFrameRate defines the target frame rate (60 by default)
  61621. * @returns a SceneOptimizerOptions object
  61622. */
  61623. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61624. /**
  61625. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61626. * @param targetFrameRate defines the target frame rate (60 by default)
  61627. * @returns a SceneOptimizerOptions object
  61628. */
  61629. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61630. /**
  61631. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61632. * @param targetFrameRate defines the target frame rate (60 by default)
  61633. * @returns a SceneOptimizerOptions object
  61634. */
  61635. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61636. }
  61637. /**
  61638. * Class used to run optimizations in order to reach a target frame rate
  61639. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61640. */
  61641. export class SceneOptimizer implements IDisposable {
  61642. private _isRunning;
  61643. private _options;
  61644. private _scene;
  61645. private _currentPriorityLevel;
  61646. private _targetFrameRate;
  61647. private _trackerDuration;
  61648. private _currentFrameRate;
  61649. private _sceneDisposeObserver;
  61650. private _improvementMode;
  61651. /**
  61652. * Defines an observable called when the optimizer reaches the target frame rate
  61653. */
  61654. onSuccessObservable: Observable<SceneOptimizer>;
  61655. /**
  61656. * Defines an observable called when the optimizer enables an optimization
  61657. */
  61658. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61659. /**
  61660. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61661. */
  61662. onFailureObservable: Observable<SceneOptimizer>;
  61663. /**
  61664. * Gets a boolean indicating if the optimizer is in improvement mode
  61665. */
  61666. readonly isInImprovementMode: boolean;
  61667. /**
  61668. * Gets the current priority level (0 at start)
  61669. */
  61670. readonly currentPriorityLevel: number;
  61671. /**
  61672. * Gets the current frame rate checked by the SceneOptimizer
  61673. */
  61674. readonly currentFrameRate: number;
  61675. /**
  61676. * Gets or sets the current target frame rate (60 by default)
  61677. */
  61678. /**
  61679. * Gets or sets the current target frame rate (60 by default)
  61680. */
  61681. targetFrameRate: number;
  61682. /**
  61683. * Gets or sets the current interval between two checks (every 2000ms by default)
  61684. */
  61685. /**
  61686. * Gets or sets the current interval between two checks (every 2000ms by default)
  61687. */
  61688. trackerDuration: number;
  61689. /**
  61690. * Gets the list of active optimizations
  61691. */
  61692. readonly optimizations: SceneOptimization[];
  61693. /**
  61694. * Creates a new SceneOptimizer
  61695. * @param scene defines the scene to work on
  61696. * @param options defines the options to use with the SceneOptimizer
  61697. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61698. * @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)
  61699. */
  61700. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61701. /**
  61702. * Stops the current optimizer
  61703. */
  61704. stop(): void;
  61705. /**
  61706. * Reset the optimizer to initial step (current priority level = 0)
  61707. */
  61708. reset(): void;
  61709. /**
  61710. * Start the optimizer. By default it will try to reach a specific framerate
  61711. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61712. */
  61713. start(): void;
  61714. private _checkCurrentState;
  61715. /**
  61716. * Release all resources
  61717. */
  61718. dispose(): void;
  61719. /**
  61720. * Helper function to create a SceneOptimizer with one single line of code
  61721. * @param scene defines the scene to work on
  61722. * @param options defines the options to use with the SceneOptimizer
  61723. * @param onSuccess defines a callback to call on success
  61724. * @param onFailure defines a callback to call on failure
  61725. * @returns the new SceneOptimizer object
  61726. */
  61727. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61728. }
  61729. }
  61730. declare module "babylonjs/Misc/sceneSerializer" {
  61731. import { Scene } from "babylonjs/scene";
  61732. /**
  61733. * Class used to serialize a scene into a string
  61734. */
  61735. export class SceneSerializer {
  61736. /**
  61737. * Clear cache used by a previous serialization
  61738. */
  61739. static ClearCache(): void;
  61740. /**
  61741. * Serialize a scene into a JSON compatible object
  61742. * @param scene defines the scene to serialize
  61743. * @returns a JSON compatible object
  61744. */
  61745. static Serialize(scene: Scene): any;
  61746. /**
  61747. * Serialize a mesh into a JSON compatible object
  61748. * @param toSerialize defines the mesh to serialize
  61749. * @param withParents defines if parents must be serialized as well
  61750. * @param withChildren defines if children must be serialized as well
  61751. * @returns a JSON compatible object
  61752. */
  61753. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61754. }
  61755. }
  61756. declare module "babylonjs/Misc/textureTools" {
  61757. import { Texture } from "babylonjs/Materials/Textures/texture";
  61758. /**
  61759. * Class used to host texture specific utilities
  61760. */
  61761. export class TextureTools {
  61762. /**
  61763. * Uses the GPU to create a copy texture rescaled at a given size
  61764. * @param texture Texture to copy from
  61765. * @param width defines the desired width
  61766. * @param height defines the desired height
  61767. * @param useBilinearMode defines if bilinear mode has to be used
  61768. * @return the generated texture
  61769. */
  61770. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61771. }
  61772. }
  61773. declare module "babylonjs/Misc/videoRecorder" {
  61774. import { Nullable } from "babylonjs/types";
  61775. import { Engine } from "babylonjs/Engines/engine";
  61776. /**
  61777. * This represents the different options avilable for the video capture.
  61778. */
  61779. export interface VideoRecorderOptions {
  61780. /** Defines the mime type of the video */
  61781. mimeType: string;
  61782. /** Defines the video the video should be recorded at */
  61783. fps: number;
  61784. /** Defines the chunk size for the recording data */
  61785. recordChunckSize: number;
  61786. /** The audio tracks to attach to the record */
  61787. audioTracks?: MediaStreamTrack[];
  61788. }
  61789. /**
  61790. * This can helps recording videos from BabylonJS.
  61791. * This is based on the available WebRTC functionalities of the browser.
  61792. *
  61793. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61794. */
  61795. export class VideoRecorder {
  61796. private static readonly _defaultOptions;
  61797. /**
  61798. * Returns wehther or not the VideoRecorder is available in your browser.
  61799. * @param engine Defines the Babylon Engine to check the support for
  61800. * @returns true if supported otherwise false
  61801. */
  61802. static IsSupported(engine: Engine): boolean;
  61803. private readonly _options;
  61804. private _canvas;
  61805. private _mediaRecorder;
  61806. private _recordedChunks;
  61807. private _fileName;
  61808. private _resolve;
  61809. private _reject;
  61810. /**
  61811. * True wether a recording is already in progress.
  61812. */
  61813. readonly isRecording: boolean;
  61814. /**
  61815. * Create a new VideoCapture object which can help converting what you see in Babylon to
  61816. * a video file.
  61817. * @param engine Defines the BabylonJS Engine you wish to record
  61818. * @param options Defines options that can be used to customized the capture
  61819. */
  61820. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61821. /**
  61822. * Stops the current recording before the default capture timeout passed in the startRecording
  61823. * functions.
  61824. */
  61825. stopRecording(): void;
  61826. /**
  61827. * Starts recording the canvas for a max duration specified in parameters.
  61828. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  61829. * @param maxDuration Defines the maximum recording time in seconds.
  61830. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61831. * @return a promise callback at the end of the recording with the video data in Blob.
  61832. */
  61833. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61834. /**
  61835. * Releases internal resources used during the recording.
  61836. */
  61837. dispose(): void;
  61838. private _handleDataAvailable;
  61839. private _handleError;
  61840. private _handleStop;
  61841. }
  61842. }
  61843. declare module "babylonjs/Misc/screenshotTools" {
  61844. import { Camera } from "babylonjs/Cameras/camera";
  61845. import { Engine } from "babylonjs/Engines/engine";
  61846. /**
  61847. * Class containing a set of static utilities functions for screenshots
  61848. */
  61849. export class ScreenshotTools {
  61850. /**
  61851. * Captures a screenshot of the current rendering
  61852. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61853. * @param engine defines the rendering engine
  61854. * @param camera defines the source camera
  61855. * @param size This parameter can be set to a single number or to an object with the
  61856. * following (optional) properties: precision, width, height. If a single number is passed,
  61857. * it will be used for both width and height. If an object is passed, the screenshot size
  61858. * will be derived from the parameters. The precision property is a multiplier allowing
  61859. * rendering at a higher or lower resolution
  61860. * @param successCallback defines the callback receives a single parameter which contains the
  61861. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61862. * src parameter of an <img> to display it
  61863. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61864. * Check your browser for supported MIME types
  61865. */
  61866. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  61867. /**
  61868. * Generates an image screenshot from the specified camera.
  61869. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61870. * @param engine The engine to use for rendering
  61871. * @param camera The camera to use for rendering
  61872. * @param size This parameter can be set to a single number or to an object with the
  61873. * following (optional) properties: precision, width, height. If a single number is passed,
  61874. * it will be used for both width and height. If an object is passed, the screenshot size
  61875. * will be derived from the parameters. The precision property is a multiplier allowing
  61876. * rendering at a higher or lower resolution
  61877. * @param successCallback The callback receives a single parameter which contains the
  61878. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61879. * src parameter of an <img> to display it
  61880. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61881. * Check your browser for supported MIME types
  61882. * @param samples Texture samples (default: 1)
  61883. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61884. * @param fileName A name for for the downloaded file.
  61885. */
  61886. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61887. }
  61888. }
  61889. declare module "babylonjs/Misc/index" {
  61890. export * from "babylonjs/Misc/andOrNotEvaluator";
  61891. export * from "babylonjs/Misc/assetsManager";
  61892. export * from "babylonjs/Misc/dds";
  61893. export * from "babylonjs/Misc/decorators";
  61894. export * from "babylonjs/Misc/deferred";
  61895. export * from "babylonjs/Misc/environmentTextureTools";
  61896. export * from "babylonjs/Misc/meshExploder";
  61897. export * from "babylonjs/Misc/filesInput";
  61898. export * from "babylonjs/Misc/HighDynamicRange/index";
  61899. export * from "babylonjs/Misc/khronosTextureContainer";
  61900. export * from "babylonjs/Misc/observable";
  61901. export * from "babylonjs/Misc/performanceMonitor";
  61902. export * from "babylonjs/Misc/promise";
  61903. export * from "babylonjs/Misc/sceneOptimizer";
  61904. export * from "babylonjs/Misc/sceneSerializer";
  61905. export * from "babylonjs/Misc/smartArray";
  61906. export * from "babylonjs/Misc/stringDictionary";
  61907. export * from "babylonjs/Misc/tags";
  61908. export * from "babylonjs/Misc/textureTools";
  61909. export * from "babylonjs/Misc/tga";
  61910. export * from "babylonjs/Misc/tools";
  61911. export * from "babylonjs/Misc/videoRecorder";
  61912. export * from "babylonjs/Misc/virtualJoystick";
  61913. export * from "babylonjs/Misc/workerPool";
  61914. export * from "babylonjs/Misc/logger";
  61915. export * from "babylonjs/Misc/typeStore";
  61916. export * from "babylonjs/Misc/filesInputStore";
  61917. export * from "babylonjs/Misc/deepCopier";
  61918. export * from "babylonjs/Misc/pivotTools";
  61919. export * from "babylonjs/Misc/precisionDate";
  61920. export * from "babylonjs/Misc/screenshotTools";
  61921. export * from "babylonjs/Misc/typeStore";
  61922. export * from "babylonjs/Misc/webRequest";
  61923. export * from "babylonjs/Misc/iInspectable";
  61924. export * from "babylonjs/Misc/brdfTextureTools";
  61925. }
  61926. declare module "babylonjs/index" {
  61927. export * from "babylonjs/abstractScene";
  61928. export * from "babylonjs/Actions/index";
  61929. export * from "babylonjs/Animations/index";
  61930. export * from "babylonjs/assetContainer";
  61931. export * from "babylonjs/Audio/index";
  61932. export * from "babylonjs/Behaviors/index";
  61933. export * from "babylonjs/Bones/index";
  61934. export * from "babylonjs/Cameras/index";
  61935. export * from "babylonjs/Collisions/index";
  61936. export * from "babylonjs/Culling/index";
  61937. export * from "babylonjs/Debug/index";
  61938. export * from "babylonjs/Engines/index";
  61939. export * from "babylonjs/Events/index";
  61940. export * from "babylonjs/Gamepads/index";
  61941. export * from "babylonjs/Gizmos/index";
  61942. export * from "babylonjs/Helpers/index";
  61943. export * from "babylonjs/Instrumentation/index";
  61944. export * from "babylonjs/Layers/index";
  61945. export * from "babylonjs/LensFlares/index";
  61946. export * from "babylonjs/Lights/index";
  61947. export * from "babylonjs/Loading/index";
  61948. export * from "babylonjs/Materials/index";
  61949. export * from "babylonjs/Maths/index";
  61950. export * from "babylonjs/Meshes/index";
  61951. export * from "babylonjs/Morph/index";
  61952. export * from "babylonjs/node";
  61953. export * from "babylonjs/Offline/index";
  61954. export * from "babylonjs/Particles/index";
  61955. export * from "babylonjs/Physics/index";
  61956. export * from "babylonjs/PostProcesses/index";
  61957. export * from "babylonjs/Probes/index";
  61958. export * from "babylonjs/Rendering/index";
  61959. export * from "babylonjs/scene";
  61960. export * from "babylonjs/sceneComponent";
  61961. export * from "babylonjs/Sprites/index";
  61962. export * from "babylonjs/States/index";
  61963. export * from "babylonjs/Misc/index";
  61964. export * from "babylonjs/types";
  61965. }
  61966. declare module "babylonjs/Animations/pathCursor" {
  61967. import { Path2, Vector3 } from "babylonjs/Maths/math";
  61968. /**
  61969. * A cursor which tracks a point on a path
  61970. */
  61971. export class PathCursor {
  61972. private path;
  61973. /**
  61974. * Stores path cursor callbacks for when an onchange event is triggered
  61975. */
  61976. private _onchange;
  61977. /**
  61978. * The value of the path cursor
  61979. */
  61980. value: number;
  61981. /**
  61982. * The animation array of the path cursor
  61983. */
  61984. animations: Animation[];
  61985. /**
  61986. * Initializes the path cursor
  61987. * @param path The path to track
  61988. */
  61989. constructor(path: Path2);
  61990. /**
  61991. * Gets the cursor point on the path
  61992. * @returns A point on the path cursor at the cursor location
  61993. */
  61994. getPoint(): Vector3;
  61995. /**
  61996. * Moves the cursor ahead by the step amount
  61997. * @param step The amount to move the cursor forward
  61998. * @returns This path cursor
  61999. */
  62000. moveAhead(step?: number): PathCursor;
  62001. /**
  62002. * Moves the cursor behind by the step amount
  62003. * @param step The amount to move the cursor back
  62004. * @returns This path cursor
  62005. */
  62006. moveBack(step?: number): PathCursor;
  62007. /**
  62008. * Moves the cursor by the step amount
  62009. * If the step amount is greater than one, an exception is thrown
  62010. * @param step The amount to move the cursor
  62011. * @returns This path cursor
  62012. */
  62013. move(step: number): PathCursor;
  62014. /**
  62015. * Ensures that the value is limited between zero and one
  62016. * @returns This path cursor
  62017. */
  62018. private ensureLimits;
  62019. /**
  62020. * Runs onchange callbacks on change (used by the animation engine)
  62021. * @returns This path cursor
  62022. */
  62023. private raiseOnChange;
  62024. /**
  62025. * Executes a function on change
  62026. * @param f A path cursor onchange callback
  62027. * @returns This path cursor
  62028. */
  62029. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62030. }
  62031. }
  62032. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62033. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62034. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62035. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62036. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62037. }
  62038. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62039. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62040. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62041. }
  62042. declare module "babylonjs/Engines/Processors/index" {
  62043. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62044. export * from "babylonjs/Engines/Processors/Expressions/index";
  62045. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62046. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62047. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62048. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62049. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62050. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62051. }
  62052. declare module "babylonjs/Legacy/legacy" {
  62053. import * as Babylon from "babylonjs/index";
  62054. export * from "babylonjs/index";
  62055. }
  62056. declare module "babylonjs/Shaders/blur.fragment" {
  62057. /** @hidden */
  62058. export var blurPixelShader: {
  62059. name: string;
  62060. shader: string;
  62061. };
  62062. }
  62063. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  62064. /** @hidden */
  62065. export var bones300Declaration: {
  62066. name: string;
  62067. shader: string;
  62068. };
  62069. }
  62070. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  62071. /** @hidden */
  62072. export var instances300Declaration: {
  62073. name: string;
  62074. shader: string;
  62075. };
  62076. }
  62077. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62078. /** @hidden */
  62079. export var pointCloudVertexDeclaration: {
  62080. name: string;
  62081. shader: string;
  62082. };
  62083. }
  62084. // Mixins
  62085. interface Window {
  62086. mozIndexedDB: IDBFactory;
  62087. webkitIndexedDB: IDBFactory;
  62088. msIndexedDB: IDBFactory;
  62089. webkitURL: typeof URL;
  62090. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62091. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62092. WebGLRenderingContext: WebGLRenderingContext;
  62093. MSGesture: MSGesture;
  62094. CANNON: any;
  62095. AudioContext: AudioContext;
  62096. webkitAudioContext: AudioContext;
  62097. PointerEvent: any;
  62098. Math: Math;
  62099. Uint8Array: Uint8ArrayConstructor;
  62100. Float32Array: Float32ArrayConstructor;
  62101. mozURL: typeof URL;
  62102. msURL: typeof URL;
  62103. VRFrameData: any; // WebVR, from specs 1.1
  62104. DracoDecoderModule: any;
  62105. setImmediate(handler: (...args: any[]) => void): number;
  62106. }
  62107. interface HTMLCanvasElement {
  62108. requestPointerLock(): void;
  62109. msRequestPointerLock?(): void;
  62110. mozRequestPointerLock?(): void;
  62111. webkitRequestPointerLock?(): void;
  62112. /** Track wether a record is in progress */
  62113. isRecording: boolean;
  62114. /** Capture Stream method defined by some browsers */
  62115. captureStream(fps?: number): MediaStream;
  62116. }
  62117. interface CanvasRenderingContext2D {
  62118. msImageSmoothingEnabled: boolean;
  62119. }
  62120. interface MouseEvent {
  62121. mozMovementX: number;
  62122. mozMovementY: number;
  62123. webkitMovementX: number;
  62124. webkitMovementY: number;
  62125. msMovementX: number;
  62126. msMovementY: number;
  62127. }
  62128. interface Navigator {
  62129. mozGetVRDevices: (any: any) => any;
  62130. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62131. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62132. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62133. webkitGetGamepads(): Gamepad[];
  62134. msGetGamepads(): Gamepad[];
  62135. webkitGamepads(): Gamepad[];
  62136. }
  62137. interface HTMLVideoElement {
  62138. mozSrcObject: any;
  62139. }
  62140. interface Math {
  62141. fround(x: number): number;
  62142. imul(a: number, b: number): number;
  62143. }
  62144. interface WebGLRenderingContext {
  62145. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62146. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62147. vertexAttribDivisor(index: number, divisor: number): void;
  62148. createVertexArray(): any;
  62149. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62150. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62151. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62152. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62153. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62154. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62155. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62156. // Queries
  62157. createQuery(): WebGLQuery;
  62158. deleteQuery(query: WebGLQuery): void;
  62159. beginQuery(target: number, query: WebGLQuery): void;
  62160. endQuery(target: number): void;
  62161. getQueryParameter(query: WebGLQuery, pname: number): any;
  62162. getQuery(target: number, pname: number): any;
  62163. MAX_SAMPLES: number;
  62164. RGBA8: number;
  62165. READ_FRAMEBUFFER: number;
  62166. DRAW_FRAMEBUFFER: number;
  62167. UNIFORM_BUFFER: number;
  62168. HALF_FLOAT_OES: number;
  62169. RGBA16F: number;
  62170. RGBA32F: number;
  62171. R32F: number;
  62172. RG32F: number;
  62173. RGB32F: number;
  62174. R16F: number;
  62175. RG16F: number;
  62176. RGB16F: number;
  62177. RED: number;
  62178. RG: number;
  62179. R8: number;
  62180. RG8: number;
  62181. UNSIGNED_INT_24_8: number;
  62182. DEPTH24_STENCIL8: number;
  62183. /* Multiple Render Targets */
  62184. drawBuffers(buffers: number[]): void;
  62185. readBuffer(src: number): void;
  62186. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62187. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62188. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62189. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62190. // Occlusion Query
  62191. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62192. ANY_SAMPLES_PASSED: number;
  62193. QUERY_RESULT_AVAILABLE: number;
  62194. QUERY_RESULT: number;
  62195. }
  62196. interface WebGLProgram {
  62197. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62198. }
  62199. interface EXT_disjoint_timer_query {
  62200. QUERY_COUNTER_BITS_EXT: number;
  62201. TIME_ELAPSED_EXT: number;
  62202. TIMESTAMP_EXT: number;
  62203. GPU_DISJOINT_EXT: number;
  62204. QUERY_RESULT_EXT: number;
  62205. QUERY_RESULT_AVAILABLE_EXT: number;
  62206. queryCounterEXT(query: WebGLQuery, target: number): void;
  62207. createQueryEXT(): WebGLQuery;
  62208. beginQueryEXT(target: number, query: WebGLQuery): void;
  62209. endQueryEXT(target: number): void;
  62210. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62211. deleteQueryEXT(query: WebGLQuery): void;
  62212. }
  62213. interface WebGLUniformLocation {
  62214. _currentState: any;
  62215. }
  62216. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62217. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62218. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62219. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62220. interface WebGLRenderingContext {
  62221. readonly RASTERIZER_DISCARD: number;
  62222. readonly DEPTH_COMPONENT24: number;
  62223. readonly TEXTURE_3D: number;
  62224. readonly TEXTURE_2D_ARRAY: number;
  62225. readonly TEXTURE_COMPARE_FUNC: number;
  62226. readonly TEXTURE_COMPARE_MODE: number;
  62227. readonly COMPARE_REF_TO_TEXTURE: number;
  62228. readonly TEXTURE_WRAP_R: number;
  62229. readonly HALF_FLOAT: number;
  62230. readonly RGB8: number;
  62231. readonly RED_INTEGER: number;
  62232. readonly RG_INTEGER: number;
  62233. readonly RGB_INTEGER: number;
  62234. readonly RGBA_INTEGER: number;
  62235. readonly R8_SNORM: number;
  62236. readonly RG8_SNORM: number;
  62237. readonly RGB8_SNORM: number;
  62238. readonly RGBA8_SNORM: number;
  62239. readonly R8I: number;
  62240. readonly RG8I: number;
  62241. readonly RGB8I: number;
  62242. readonly RGBA8I: number;
  62243. readonly R8UI: number;
  62244. readonly RG8UI: number;
  62245. readonly RGB8UI: number;
  62246. readonly RGBA8UI: number;
  62247. readonly R16I: number;
  62248. readonly RG16I: number;
  62249. readonly RGB16I: number;
  62250. readonly RGBA16I: number;
  62251. readonly R16UI: number;
  62252. readonly RG16UI: number;
  62253. readonly RGB16UI: number;
  62254. readonly RGBA16UI: number;
  62255. readonly R32I: number;
  62256. readonly RG32I: number;
  62257. readonly RGB32I: number;
  62258. readonly RGBA32I: number;
  62259. readonly R32UI: number;
  62260. readonly RG32UI: number;
  62261. readonly RGB32UI: number;
  62262. readonly RGBA32UI: number;
  62263. readonly RGB10_A2UI: number;
  62264. readonly R11F_G11F_B10F: number;
  62265. readonly RGB9_E5: number;
  62266. readonly RGB10_A2: number;
  62267. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62268. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62269. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62270. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62271. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62272. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62273. 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;
  62274. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62275. readonly TRANSFORM_FEEDBACK: number;
  62276. readonly INTERLEAVED_ATTRIBS: number;
  62277. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62278. createTransformFeedback(): WebGLTransformFeedback;
  62279. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62280. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62281. beginTransformFeedback(primitiveMode: number): void;
  62282. endTransformFeedback(): void;
  62283. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62284. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62285. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62286. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62287. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62288. }
  62289. interface ImageBitmap {
  62290. readonly width: number;
  62291. readonly height: number;
  62292. close(): void;
  62293. }
  62294. interface WebGLQuery extends WebGLObject {
  62295. }
  62296. declare var WebGLQuery: {
  62297. prototype: WebGLQuery;
  62298. new(): WebGLQuery;
  62299. };
  62300. interface WebGLSampler extends WebGLObject {
  62301. }
  62302. declare var WebGLSampler: {
  62303. prototype: WebGLSampler;
  62304. new(): WebGLSampler;
  62305. };
  62306. interface WebGLSync extends WebGLObject {
  62307. }
  62308. declare var WebGLSync: {
  62309. prototype: WebGLSync;
  62310. new(): WebGLSync;
  62311. };
  62312. interface WebGLTransformFeedback extends WebGLObject {
  62313. }
  62314. declare var WebGLTransformFeedback: {
  62315. prototype: WebGLTransformFeedback;
  62316. new(): WebGLTransformFeedback;
  62317. };
  62318. interface WebGLVertexArrayObject extends WebGLObject {
  62319. }
  62320. declare var WebGLVertexArrayObject: {
  62321. prototype: WebGLVertexArrayObject;
  62322. new(): WebGLVertexArrayObject;
  62323. };
  62324. // Type definitions for WebVR API
  62325. // Project: https://w3c.github.io/webvr/
  62326. // Definitions by: six a <https://github.com/lostfictions>
  62327. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62328. interface VRDisplay extends EventTarget {
  62329. /**
  62330. * Dictionary of capabilities describing the VRDisplay.
  62331. */
  62332. readonly capabilities: VRDisplayCapabilities;
  62333. /**
  62334. * z-depth defining the far plane of the eye view frustum
  62335. * enables mapping of values in the render target depth
  62336. * attachment to scene coordinates. Initially set to 10000.0.
  62337. */
  62338. depthFar: number;
  62339. /**
  62340. * z-depth defining the near plane of the eye view frustum
  62341. * enables mapping of values in the render target depth
  62342. * attachment to scene coordinates. Initially set to 0.01.
  62343. */
  62344. depthNear: number;
  62345. /**
  62346. * An identifier for this distinct VRDisplay. Used as an
  62347. * association point in the Gamepad API.
  62348. */
  62349. readonly displayId: number;
  62350. /**
  62351. * A display name, a user-readable name identifying it.
  62352. */
  62353. readonly displayName: string;
  62354. readonly isConnected: boolean;
  62355. readonly isPresenting: boolean;
  62356. /**
  62357. * If this VRDisplay supports room-scale experiences, the optional
  62358. * stage attribute contains details on the room-scale parameters.
  62359. */
  62360. readonly stageParameters: VRStageParameters | null;
  62361. /**
  62362. * Passing the value returned by `requestAnimationFrame` to
  62363. * `cancelAnimationFrame` will unregister the callback.
  62364. * @param handle Define the hanle of the request to cancel
  62365. */
  62366. cancelAnimationFrame(handle: number): void;
  62367. /**
  62368. * Stops presenting to the VRDisplay.
  62369. * @returns a promise to know when it stopped
  62370. */
  62371. exitPresent(): Promise<void>;
  62372. /**
  62373. * Return the current VREyeParameters for the given eye.
  62374. * @param whichEye Define the eye we want the parameter for
  62375. * @returns the eye parameters
  62376. */
  62377. getEyeParameters(whichEye: string): VREyeParameters;
  62378. /**
  62379. * Populates the passed VRFrameData with the information required to render
  62380. * the current frame.
  62381. * @param frameData Define the data structure to populate
  62382. * @returns true if ok otherwise false
  62383. */
  62384. getFrameData(frameData: VRFrameData): boolean;
  62385. /**
  62386. * Get the layers currently being presented.
  62387. * @returns the list of VR layers
  62388. */
  62389. getLayers(): VRLayer[];
  62390. /**
  62391. * Return a VRPose containing the future predicted pose of the VRDisplay
  62392. * when the current frame will be presented. The value returned will not
  62393. * change until JavaScript has returned control to the browser.
  62394. *
  62395. * The VRPose will contain the position, orientation, velocity,
  62396. * and acceleration of each of these properties.
  62397. * @returns the pose object
  62398. */
  62399. getPose(): VRPose;
  62400. /**
  62401. * Return the current instantaneous pose of the VRDisplay, with no
  62402. * prediction applied.
  62403. * @returns the current instantaneous pose
  62404. */
  62405. getImmediatePose(): VRPose;
  62406. /**
  62407. * The callback passed to `requestAnimationFrame` will be called
  62408. * any time a new frame should be rendered. When the VRDisplay is
  62409. * presenting the callback will be called at the native refresh
  62410. * rate of the HMD. When not presenting this function acts
  62411. * identically to how window.requestAnimationFrame acts. Content should
  62412. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62413. * asynchronously from other displays and at differing refresh rates.
  62414. * @param callback Define the eaction to run next frame
  62415. * @returns the request handle it
  62416. */
  62417. requestAnimationFrame(callback: FrameRequestCallback): number;
  62418. /**
  62419. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62420. * Repeat calls while already presenting will update the VRLayers being displayed.
  62421. * @param layers Define the list of layer to present
  62422. * @returns a promise to know when the request has been fulfilled
  62423. */
  62424. requestPresent(layers: VRLayer[]): Promise<void>;
  62425. /**
  62426. * Reset the pose for this display, treating its current position and
  62427. * orientation as the "origin/zero" values. VRPose.position,
  62428. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62429. * updated when calling resetPose(). This should be called in only
  62430. * sitting-space experiences.
  62431. */
  62432. resetPose(): void;
  62433. /**
  62434. * The VRLayer provided to the VRDisplay will be captured and presented
  62435. * in the HMD. Calling this function has the same effect on the source
  62436. * canvas as any other operation that uses its source image, and canvases
  62437. * created without preserveDrawingBuffer set to true will be cleared.
  62438. * @param pose Define the pose to submit
  62439. */
  62440. submitFrame(pose?: VRPose): void;
  62441. }
  62442. declare var VRDisplay: {
  62443. prototype: VRDisplay;
  62444. new(): VRDisplay;
  62445. };
  62446. interface VRLayer {
  62447. leftBounds?: number[] | Float32Array | null;
  62448. rightBounds?: number[] | Float32Array | null;
  62449. source?: HTMLCanvasElement | null;
  62450. }
  62451. interface VRDisplayCapabilities {
  62452. readonly canPresent: boolean;
  62453. readonly hasExternalDisplay: boolean;
  62454. readonly hasOrientation: boolean;
  62455. readonly hasPosition: boolean;
  62456. readonly maxLayers: number;
  62457. }
  62458. interface VREyeParameters {
  62459. /** @deprecated */
  62460. readonly fieldOfView: VRFieldOfView;
  62461. readonly offset: Float32Array;
  62462. readonly renderHeight: number;
  62463. readonly renderWidth: number;
  62464. }
  62465. interface VRFieldOfView {
  62466. readonly downDegrees: number;
  62467. readonly leftDegrees: number;
  62468. readonly rightDegrees: number;
  62469. readonly upDegrees: number;
  62470. }
  62471. interface VRFrameData {
  62472. readonly leftProjectionMatrix: Float32Array;
  62473. readonly leftViewMatrix: Float32Array;
  62474. readonly pose: VRPose;
  62475. readonly rightProjectionMatrix: Float32Array;
  62476. readonly rightViewMatrix: Float32Array;
  62477. readonly timestamp: number;
  62478. }
  62479. interface VRPose {
  62480. readonly angularAcceleration: Float32Array | null;
  62481. readonly angularVelocity: Float32Array | null;
  62482. readonly linearAcceleration: Float32Array | null;
  62483. readonly linearVelocity: Float32Array | null;
  62484. readonly orientation: Float32Array | null;
  62485. readonly position: Float32Array | null;
  62486. readonly timestamp: number;
  62487. }
  62488. interface VRStageParameters {
  62489. sittingToStandingTransform?: Float32Array;
  62490. sizeX?: number;
  62491. sizeY?: number;
  62492. }
  62493. interface Navigator {
  62494. getVRDisplays(): Promise<VRDisplay[]>;
  62495. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62496. }
  62497. interface Window {
  62498. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62499. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62500. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62501. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62502. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62503. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62504. }
  62505. interface Gamepad {
  62506. readonly displayId: number;
  62507. }
  62508. interface XRDevice {
  62509. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62510. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62511. }
  62512. interface XRSession {
  62513. getInputSources(): Array<any>;
  62514. baseLayer: XRWebGLLayer;
  62515. requestFrameOfReference(type: string): Promise<void>;
  62516. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62517. end(): Promise<void>;
  62518. requestAnimationFrame: Function;
  62519. addEventListener: Function;
  62520. }
  62521. interface XRSessionCreationOptions {
  62522. outputContext?: WebGLRenderingContext | null;
  62523. immersive?: boolean;
  62524. environmentIntegration?: boolean;
  62525. }
  62526. interface XRLayer {
  62527. getViewport: Function;
  62528. framebufferWidth: number;
  62529. framebufferHeight: number;
  62530. }
  62531. interface XRView {
  62532. projectionMatrix: Float32Array;
  62533. }
  62534. interface XRFrame {
  62535. getDevicePose: Function;
  62536. getInputPose: Function;
  62537. views: Array<XRView>;
  62538. baseLayer: XRLayer;
  62539. }
  62540. interface XRFrameOfReference {
  62541. }
  62542. interface XRWebGLLayer extends XRLayer {
  62543. framebuffer: WebGLFramebuffer;
  62544. }
  62545. declare var XRWebGLLayer: {
  62546. prototype: XRWebGLLayer;
  62547. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62548. };
  62549. declare module "babylonjs" {
  62550. export * from "babylonjs/Legacy/legacy";
  62551. }
  62552. declare module BABYLON {
  62553. /** Alias type for value that can be null */
  62554. export type Nullable<T> = T | null;
  62555. /**
  62556. * Alias type for number that are floats
  62557. * @ignorenaming
  62558. */
  62559. export type float = number;
  62560. /**
  62561. * Alias type for number that are doubles.
  62562. * @ignorenaming
  62563. */
  62564. export type double = number;
  62565. /**
  62566. * Alias type for number that are integer
  62567. * @ignorenaming
  62568. */
  62569. export type int = number;
  62570. /** Alias type for number array or Float32Array */
  62571. export type FloatArray = number[] | Float32Array;
  62572. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62573. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62574. /**
  62575. * Alias for types that can be used by a Buffer or VertexBuffer.
  62576. */
  62577. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62578. /**
  62579. * Alias type for primitive types
  62580. * @ignorenaming
  62581. */
  62582. type Primitive = undefined | null | boolean | string | number | Function;
  62583. /**
  62584. * Type modifier to make all the properties of an object Readonly
  62585. */
  62586. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62587. /**
  62588. * Type modifier to make all the properties of an object Readonly recursively
  62589. */
  62590. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62591. /** @hidden */
  62592. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62593. }
  62594. /** @hidden */
  62595. /** @hidden */
  62596. type DeepImmutableObject<T> = {
  62597. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62598. };
  62599. }
  62600. declare module BABYLON {
  62601. /**
  62602. * Class containing a set of static utilities functions for arrays.
  62603. */
  62604. export class ArrayTools {
  62605. /**
  62606. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62607. * @param size the number of element to construct and put in the array
  62608. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62609. * @returns a new array filled with new objects
  62610. */
  62611. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62612. }
  62613. }
  62614. declare module BABYLON {
  62615. /**
  62616. * Scalar computation library
  62617. */
  62618. export class Scalar {
  62619. /**
  62620. * Two pi constants convenient for computation.
  62621. */
  62622. static TwoPi: number;
  62623. /**
  62624. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62625. * @param a number
  62626. * @param b number
  62627. * @param epsilon (default = 1.401298E-45)
  62628. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62629. */
  62630. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62631. /**
  62632. * Returns a string : the upper case translation of the number i to hexadecimal.
  62633. * @param i number
  62634. * @returns the upper case translation of the number i to hexadecimal.
  62635. */
  62636. static ToHex(i: number): string;
  62637. /**
  62638. * Returns -1 if value is negative and +1 is value is positive.
  62639. * @param value the value
  62640. * @returns the value itself if it's equal to zero.
  62641. */
  62642. static Sign(value: number): number;
  62643. /**
  62644. * Returns the value itself if it's between min and max.
  62645. * Returns min if the value is lower than min.
  62646. * Returns max if the value is greater than max.
  62647. * @param value the value to clmap
  62648. * @param min the min value to clamp to (default: 0)
  62649. * @param max the max value to clamp to (default: 1)
  62650. * @returns the clamped value
  62651. */
  62652. static Clamp(value: number, min?: number, max?: number): number;
  62653. /**
  62654. * the log2 of value.
  62655. * @param value the value to compute log2 of
  62656. * @returns the log2 of value.
  62657. */
  62658. static Log2(value: number): number;
  62659. /**
  62660. * Loops the value, so that it is never larger than length and never smaller than 0.
  62661. *
  62662. * This is similar to the modulo operator but it works with floating point numbers.
  62663. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62664. * With t = 5 and length = 2.5, the result would be 0.0.
  62665. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62666. * @param value the value
  62667. * @param length the length
  62668. * @returns the looped value
  62669. */
  62670. static Repeat(value: number, length: number): number;
  62671. /**
  62672. * Normalize the value between 0.0 and 1.0 using min and max values
  62673. * @param value value to normalize
  62674. * @param min max to normalize between
  62675. * @param max min to normalize between
  62676. * @returns the normalized value
  62677. */
  62678. static Normalize(value: number, min: number, max: number): number;
  62679. /**
  62680. * Denormalize the value from 0.0 and 1.0 using min and max values
  62681. * @param normalized value to denormalize
  62682. * @param min max to denormalize between
  62683. * @param max min to denormalize between
  62684. * @returns the denormalized value
  62685. */
  62686. static Denormalize(normalized: number, min: number, max: number): number;
  62687. /**
  62688. * Calculates the shortest difference between two given angles given in degrees.
  62689. * @param current current angle in degrees
  62690. * @param target target angle in degrees
  62691. * @returns the delta
  62692. */
  62693. static DeltaAngle(current: number, target: number): number;
  62694. /**
  62695. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62696. * @param tx value
  62697. * @param length length
  62698. * @returns The returned value will move back and forth between 0 and length
  62699. */
  62700. static PingPong(tx: number, length: number): number;
  62701. /**
  62702. * Interpolates between min and max with smoothing at the limits.
  62703. *
  62704. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62705. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62706. * @param from from
  62707. * @param to to
  62708. * @param tx value
  62709. * @returns the smooth stepped value
  62710. */
  62711. static SmoothStep(from: number, to: number, tx: number): number;
  62712. /**
  62713. * Moves a value current towards target.
  62714. *
  62715. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62716. * Negative values of maxDelta pushes the value away from target.
  62717. * @param current current value
  62718. * @param target target value
  62719. * @param maxDelta max distance to move
  62720. * @returns resulting value
  62721. */
  62722. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62723. /**
  62724. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62725. *
  62726. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62727. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62728. * @param current current value
  62729. * @param target target value
  62730. * @param maxDelta max distance to move
  62731. * @returns resulting angle
  62732. */
  62733. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62734. /**
  62735. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62736. * @param start start value
  62737. * @param end target value
  62738. * @param amount amount to lerp between
  62739. * @returns the lerped value
  62740. */
  62741. static Lerp(start: number, end: number, amount: number): number;
  62742. /**
  62743. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62744. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62745. * @param start start value
  62746. * @param end target value
  62747. * @param amount amount to lerp between
  62748. * @returns the lerped value
  62749. */
  62750. static LerpAngle(start: number, end: number, amount: number): number;
  62751. /**
  62752. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62753. * @param a start value
  62754. * @param b target value
  62755. * @param value value between a and b
  62756. * @returns the inverseLerp value
  62757. */
  62758. static InverseLerp(a: number, b: number, value: number): number;
  62759. /**
  62760. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62761. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62762. * @param value1 spline value
  62763. * @param tangent1 spline value
  62764. * @param value2 spline value
  62765. * @param tangent2 spline value
  62766. * @param amount input value
  62767. * @returns hermite result
  62768. */
  62769. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62770. /**
  62771. * Returns a random float number between and min and max values
  62772. * @param min min value of random
  62773. * @param max max value of random
  62774. * @returns random value
  62775. */
  62776. static RandomRange(min: number, max: number): number;
  62777. /**
  62778. * This function returns percentage of a number in a given range.
  62779. *
  62780. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62781. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62782. * @param number to convert to percentage
  62783. * @param min min range
  62784. * @param max max range
  62785. * @returns the percentage
  62786. */
  62787. static RangeToPercent(number: number, min: number, max: number): number;
  62788. /**
  62789. * This function returns number that corresponds to the percentage in a given range.
  62790. *
  62791. * PercentToRange(0.34,0,100) will return 34.
  62792. * @param percent to convert to number
  62793. * @param min min range
  62794. * @param max max range
  62795. * @returns the number
  62796. */
  62797. static PercentToRange(percent: number, min: number, max: number): number;
  62798. /**
  62799. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62800. * @param angle The angle to normalize in radian.
  62801. * @return The converted angle.
  62802. */
  62803. static NormalizeRadians(angle: number): number;
  62804. }
  62805. }
  62806. declare module BABYLON {
  62807. /**
  62808. * Constant used to convert a value to gamma space
  62809. * @ignorenaming
  62810. */
  62811. export const ToGammaSpace: number;
  62812. /**
  62813. * Constant used to convert a value to linear space
  62814. * @ignorenaming
  62815. */
  62816. export const ToLinearSpace = 2.2;
  62817. /**
  62818. * Constant used to define the minimal number value in Babylon.js
  62819. * @ignorenaming
  62820. */
  62821. let Epsilon: number;
  62822. /**
  62823. * Class used to hold a RBG color
  62824. */
  62825. export class Color3 {
  62826. /**
  62827. * Defines the red component (between 0 and 1, default is 0)
  62828. */
  62829. r: number;
  62830. /**
  62831. * Defines the green component (between 0 and 1, default is 0)
  62832. */
  62833. g: number;
  62834. /**
  62835. * Defines the blue component (between 0 and 1, default is 0)
  62836. */
  62837. b: number;
  62838. /**
  62839. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62840. * @param r defines the red component (between 0 and 1, default is 0)
  62841. * @param g defines the green component (between 0 and 1, default is 0)
  62842. * @param b defines the blue component (between 0 and 1, default is 0)
  62843. */
  62844. constructor(
  62845. /**
  62846. * Defines the red component (between 0 and 1, default is 0)
  62847. */
  62848. r?: number,
  62849. /**
  62850. * Defines the green component (between 0 and 1, default is 0)
  62851. */
  62852. g?: number,
  62853. /**
  62854. * Defines the blue component (between 0 and 1, default is 0)
  62855. */
  62856. b?: number);
  62857. /**
  62858. * Creates a string with the Color3 current values
  62859. * @returns the string representation of the Color3 object
  62860. */
  62861. toString(): string;
  62862. /**
  62863. * Returns the string "Color3"
  62864. * @returns "Color3"
  62865. */
  62866. getClassName(): string;
  62867. /**
  62868. * Compute the Color3 hash code
  62869. * @returns an unique number that can be used to hash Color3 objects
  62870. */
  62871. getHashCode(): number;
  62872. /**
  62873. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62874. * @param array defines the array where to store the r,g,b components
  62875. * @param index defines an optional index in the target array to define where to start storing values
  62876. * @returns the current Color3 object
  62877. */
  62878. toArray(array: FloatArray, index?: number): Color3;
  62879. /**
  62880. * Returns a new Color4 object from the current Color3 and the given alpha
  62881. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62882. * @returns a new Color4 object
  62883. */
  62884. toColor4(alpha?: number): Color4;
  62885. /**
  62886. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62887. * @returns the new array
  62888. */
  62889. asArray(): number[];
  62890. /**
  62891. * Returns the luminance value
  62892. * @returns a float value
  62893. */
  62894. toLuminance(): number;
  62895. /**
  62896. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62897. * @param otherColor defines the second operand
  62898. * @returns the new Color3 object
  62899. */
  62900. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62901. /**
  62902. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62903. * @param otherColor defines the second operand
  62904. * @param result defines the Color3 object where to store the result
  62905. * @returns the current Color3
  62906. */
  62907. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62908. /**
  62909. * Determines equality between Color3 objects
  62910. * @param otherColor defines the second operand
  62911. * @returns true if the rgb values are equal to the given ones
  62912. */
  62913. equals(otherColor: DeepImmutable<Color3>): boolean;
  62914. /**
  62915. * Determines equality between the current Color3 object and a set of r,b,g values
  62916. * @param r defines the red component to check
  62917. * @param g defines the green component to check
  62918. * @param b defines the blue component to check
  62919. * @returns true if the rgb values are equal to the given ones
  62920. */
  62921. equalsFloats(r: number, g: number, b: number): boolean;
  62922. /**
  62923. * Multiplies in place each rgb value by scale
  62924. * @param scale defines the scaling factor
  62925. * @returns the updated Color3
  62926. */
  62927. scale(scale: number): Color3;
  62928. /**
  62929. * Multiplies the rgb values by scale and stores the result into "result"
  62930. * @param scale defines the scaling factor
  62931. * @param result defines the Color3 object where to store the result
  62932. * @returns the unmodified current Color3
  62933. */
  62934. scaleToRef(scale: number, result: Color3): Color3;
  62935. /**
  62936. * Scale the current Color3 values by a factor and add the result to a given Color3
  62937. * @param scale defines the scale factor
  62938. * @param result defines color to store the result into
  62939. * @returns the unmodified current Color3
  62940. */
  62941. scaleAndAddToRef(scale: number, result: Color3): Color3;
  62942. /**
  62943. * Clamps the rgb values by the min and max values and stores the result into "result"
  62944. * @param min defines minimum clamping value (default is 0)
  62945. * @param max defines maximum clamping value (default is 1)
  62946. * @param result defines color to store the result into
  62947. * @returns the original Color3
  62948. */
  62949. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  62950. /**
  62951. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  62952. * @param otherColor defines the second operand
  62953. * @returns the new Color3
  62954. */
  62955. add(otherColor: DeepImmutable<Color3>): Color3;
  62956. /**
  62957. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  62958. * @param otherColor defines the second operand
  62959. * @param result defines Color3 object to store the result into
  62960. * @returns the unmodified current Color3
  62961. */
  62962. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62963. /**
  62964. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  62965. * @param otherColor defines the second operand
  62966. * @returns the new Color3
  62967. */
  62968. subtract(otherColor: DeepImmutable<Color3>): Color3;
  62969. /**
  62970. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  62971. * @param otherColor defines the second operand
  62972. * @param result defines Color3 object to store the result into
  62973. * @returns the unmodified current Color3
  62974. */
  62975. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62976. /**
  62977. * Copy the current object
  62978. * @returns a new Color3 copied the current one
  62979. */
  62980. clone(): Color3;
  62981. /**
  62982. * Copies the rgb values from the source in the current Color3
  62983. * @param source defines the source Color3 object
  62984. * @returns the updated Color3 object
  62985. */
  62986. copyFrom(source: DeepImmutable<Color3>): Color3;
  62987. /**
  62988. * Updates the Color3 rgb values from the given floats
  62989. * @param r defines the red component to read from
  62990. * @param g defines the green component to read from
  62991. * @param b defines the blue component to read from
  62992. * @returns the current Color3 object
  62993. */
  62994. copyFromFloats(r: number, g: number, b: number): Color3;
  62995. /**
  62996. * Updates the Color3 rgb values from the given floats
  62997. * @param r defines the red component to read from
  62998. * @param g defines the green component to read from
  62999. * @param b defines the blue component to read from
  63000. * @returns the current Color3 object
  63001. */
  63002. set(r: number, g: number, b: number): Color3;
  63003. /**
  63004. * Compute the Color3 hexadecimal code as a string
  63005. * @returns a string containing the hexadecimal representation of the Color3 object
  63006. */
  63007. toHexString(): string;
  63008. /**
  63009. * Computes a new Color3 converted from the current one to linear space
  63010. * @returns a new Color3 object
  63011. */
  63012. toLinearSpace(): Color3;
  63013. /**
  63014. * Converts current color in rgb space to HSV values
  63015. * @returns a new color3 representing the HSV values
  63016. */
  63017. toHSV(): Color3;
  63018. /**
  63019. * Converts current color in rgb space to HSV values
  63020. * @param result defines the Color3 where to store the HSV values
  63021. */
  63022. toHSVToRef(result: Color3): void;
  63023. /**
  63024. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63025. * @param convertedColor defines the Color3 object where to store the linear space version
  63026. * @returns the unmodified Color3
  63027. */
  63028. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63029. /**
  63030. * Computes a new Color3 converted from the current one to gamma space
  63031. * @returns a new Color3 object
  63032. */
  63033. toGammaSpace(): Color3;
  63034. /**
  63035. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63036. * @param convertedColor defines the Color3 object where to store the gamma space version
  63037. * @returns the unmodified Color3
  63038. */
  63039. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63040. private static _BlackReadOnly;
  63041. /**
  63042. * Convert Hue, saturation and value to a Color3 (RGB)
  63043. * @param hue defines the hue
  63044. * @param saturation defines the saturation
  63045. * @param value defines the value
  63046. * @param result defines the Color3 where to store the RGB values
  63047. */
  63048. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63049. /**
  63050. * Creates a new Color3 from the string containing valid hexadecimal values
  63051. * @param hex defines a string containing valid hexadecimal values
  63052. * @returns a new Color3 object
  63053. */
  63054. static FromHexString(hex: string): Color3;
  63055. /**
  63056. * Creates a new Color3 from the starting index of the given array
  63057. * @param array defines the source array
  63058. * @param offset defines an offset in the source array
  63059. * @returns a new Color3 object
  63060. */
  63061. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63062. /**
  63063. * Creates a new Color3 from integer values (< 256)
  63064. * @param r defines the red component to read from (value between 0 and 255)
  63065. * @param g defines the green component to read from (value between 0 and 255)
  63066. * @param b defines the blue component to read from (value between 0 and 255)
  63067. * @returns a new Color3 object
  63068. */
  63069. static FromInts(r: number, g: number, b: number): Color3;
  63070. /**
  63071. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63072. * @param start defines the start Color3 value
  63073. * @param end defines the end Color3 value
  63074. * @param amount defines the gradient value between start and end
  63075. * @returns a new Color3 object
  63076. */
  63077. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63078. /**
  63079. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63080. * @param left defines the start value
  63081. * @param right defines the end value
  63082. * @param amount defines the gradient factor
  63083. * @param result defines the Color3 object where to store the result
  63084. */
  63085. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63086. /**
  63087. * Returns a Color3 value containing a red color
  63088. * @returns a new Color3 object
  63089. */
  63090. static Red(): Color3;
  63091. /**
  63092. * Returns a Color3 value containing a green color
  63093. * @returns a new Color3 object
  63094. */
  63095. static Green(): Color3;
  63096. /**
  63097. * Returns a Color3 value containing a blue color
  63098. * @returns a new Color3 object
  63099. */
  63100. static Blue(): Color3;
  63101. /**
  63102. * Returns a Color3 value containing a black color
  63103. * @returns a new Color3 object
  63104. */
  63105. static Black(): Color3;
  63106. /**
  63107. * Gets a Color3 value containing a black color that must not be updated
  63108. */
  63109. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63110. /**
  63111. * Returns a Color3 value containing a white color
  63112. * @returns a new Color3 object
  63113. */
  63114. static White(): Color3;
  63115. /**
  63116. * Returns a Color3 value containing a purple color
  63117. * @returns a new Color3 object
  63118. */
  63119. static Purple(): Color3;
  63120. /**
  63121. * Returns a Color3 value containing a magenta color
  63122. * @returns a new Color3 object
  63123. */
  63124. static Magenta(): Color3;
  63125. /**
  63126. * Returns a Color3 value containing a yellow color
  63127. * @returns a new Color3 object
  63128. */
  63129. static Yellow(): Color3;
  63130. /**
  63131. * Returns a Color3 value containing a gray color
  63132. * @returns a new Color3 object
  63133. */
  63134. static Gray(): Color3;
  63135. /**
  63136. * Returns a Color3 value containing a teal color
  63137. * @returns a new Color3 object
  63138. */
  63139. static Teal(): Color3;
  63140. /**
  63141. * Returns a Color3 value containing a random color
  63142. * @returns a new Color3 object
  63143. */
  63144. static Random(): Color3;
  63145. }
  63146. /**
  63147. * Class used to hold a RBGA color
  63148. */
  63149. export class Color4 {
  63150. /**
  63151. * Defines the red component (between 0 and 1, default is 0)
  63152. */
  63153. r: number;
  63154. /**
  63155. * Defines the green component (between 0 and 1, default is 0)
  63156. */
  63157. g: number;
  63158. /**
  63159. * Defines the blue component (between 0 and 1, default is 0)
  63160. */
  63161. b: number;
  63162. /**
  63163. * Defines the alpha component (between 0 and 1, default is 1)
  63164. */
  63165. a: number;
  63166. /**
  63167. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63168. * @param r defines the red component (between 0 and 1, default is 0)
  63169. * @param g defines the green component (between 0 and 1, default is 0)
  63170. * @param b defines the blue component (between 0 and 1, default is 0)
  63171. * @param a defines the alpha component (between 0 and 1, default is 1)
  63172. */
  63173. constructor(
  63174. /**
  63175. * Defines the red component (between 0 and 1, default is 0)
  63176. */
  63177. r?: number,
  63178. /**
  63179. * Defines the green component (between 0 and 1, default is 0)
  63180. */
  63181. g?: number,
  63182. /**
  63183. * Defines the blue component (between 0 and 1, default is 0)
  63184. */
  63185. b?: number,
  63186. /**
  63187. * Defines the alpha component (between 0 and 1, default is 1)
  63188. */
  63189. a?: number);
  63190. /**
  63191. * Adds in place the given Color4 values to the current Color4 object
  63192. * @param right defines the second operand
  63193. * @returns the current updated Color4 object
  63194. */
  63195. addInPlace(right: DeepImmutable<Color4>): Color4;
  63196. /**
  63197. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63198. * @returns the new array
  63199. */
  63200. asArray(): number[];
  63201. /**
  63202. * Stores from the starting index in the given array the Color4 successive values
  63203. * @param array defines the array where to store the r,g,b components
  63204. * @param index defines an optional index in the target array to define where to start storing values
  63205. * @returns the current Color4 object
  63206. */
  63207. toArray(array: number[], index?: number): Color4;
  63208. /**
  63209. * Determines equality between Color4 objects
  63210. * @param otherColor defines the second operand
  63211. * @returns true if the rgba values are equal to the given ones
  63212. */
  63213. equals(otherColor: DeepImmutable<Color4>): boolean;
  63214. /**
  63215. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63216. * @param right defines the second operand
  63217. * @returns a new Color4 object
  63218. */
  63219. add(right: DeepImmutable<Color4>): Color4;
  63220. /**
  63221. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63222. * @param right defines the second operand
  63223. * @returns a new Color4 object
  63224. */
  63225. subtract(right: DeepImmutable<Color4>): Color4;
  63226. /**
  63227. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63228. * @param right defines the second operand
  63229. * @param result defines the Color4 object where to store the result
  63230. * @returns the current Color4 object
  63231. */
  63232. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63233. /**
  63234. * Creates a new Color4 with the current Color4 values multiplied by scale
  63235. * @param scale defines the scaling factor to apply
  63236. * @returns a new Color4 object
  63237. */
  63238. scale(scale: number): Color4;
  63239. /**
  63240. * Multiplies the current Color4 values by scale and stores the result in "result"
  63241. * @param scale defines the scaling factor to apply
  63242. * @param result defines the Color4 object where to store the result
  63243. * @returns the current unmodified Color4
  63244. */
  63245. scaleToRef(scale: number, result: Color4): Color4;
  63246. /**
  63247. * Scale the current Color4 values by a factor and add the result to a given Color4
  63248. * @param scale defines the scale factor
  63249. * @param result defines the Color4 object where to store the result
  63250. * @returns the unmodified current Color4
  63251. */
  63252. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63253. /**
  63254. * Clamps the rgb values by the min and max values and stores the result into "result"
  63255. * @param min defines minimum clamping value (default is 0)
  63256. * @param max defines maximum clamping value (default is 1)
  63257. * @param result defines color to store the result into.
  63258. * @returns the cuurent Color4
  63259. */
  63260. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63261. /**
  63262. * Multipy an Color4 value by another and return a new Color4 object
  63263. * @param color defines the Color4 value to multiply by
  63264. * @returns a new Color4 object
  63265. */
  63266. multiply(color: Color4): Color4;
  63267. /**
  63268. * Multipy a Color4 value by another and push the result in a reference value
  63269. * @param color defines the Color4 value to multiply by
  63270. * @param result defines the Color4 to fill the result in
  63271. * @returns the result Color4
  63272. */
  63273. multiplyToRef(color: Color4, result: Color4): Color4;
  63274. /**
  63275. * Creates a string with the Color4 current values
  63276. * @returns the string representation of the Color4 object
  63277. */
  63278. toString(): string;
  63279. /**
  63280. * Returns the string "Color4"
  63281. * @returns "Color4"
  63282. */
  63283. getClassName(): string;
  63284. /**
  63285. * Compute the Color4 hash code
  63286. * @returns an unique number that can be used to hash Color4 objects
  63287. */
  63288. getHashCode(): number;
  63289. /**
  63290. * Creates a new Color4 copied from the current one
  63291. * @returns a new Color4 object
  63292. */
  63293. clone(): Color4;
  63294. /**
  63295. * Copies the given Color4 values into the current one
  63296. * @param source defines the source Color4 object
  63297. * @returns the current updated Color4 object
  63298. */
  63299. copyFrom(source: Color4): Color4;
  63300. /**
  63301. * Copies the given float values into the current one
  63302. * @param r defines the red component to read from
  63303. * @param g defines the green component to read from
  63304. * @param b defines the blue component to read from
  63305. * @param a defines the alpha component to read from
  63306. * @returns the current updated Color4 object
  63307. */
  63308. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63309. /**
  63310. * Copies the given float values into the current one
  63311. * @param r defines the red component to read from
  63312. * @param g defines the green component to read from
  63313. * @param b defines the blue component to read from
  63314. * @param a defines the alpha component to read from
  63315. * @returns the current updated Color4 object
  63316. */
  63317. set(r: number, g: number, b: number, a: number): Color4;
  63318. /**
  63319. * Compute the Color4 hexadecimal code as a string
  63320. * @returns a string containing the hexadecimal representation of the Color4 object
  63321. */
  63322. toHexString(): string;
  63323. /**
  63324. * Computes a new Color4 converted from the current one to linear space
  63325. * @returns a new Color4 object
  63326. */
  63327. toLinearSpace(): Color4;
  63328. /**
  63329. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63330. * @param convertedColor defines the Color4 object where to store the linear space version
  63331. * @returns the unmodified Color4
  63332. */
  63333. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63334. /**
  63335. * Computes a new Color4 converted from the current one to gamma space
  63336. * @returns a new Color4 object
  63337. */
  63338. toGammaSpace(): Color4;
  63339. /**
  63340. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63341. * @param convertedColor defines the Color4 object where to store the gamma space version
  63342. * @returns the unmodified Color4
  63343. */
  63344. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63345. /**
  63346. * Creates a new Color4 from the string containing valid hexadecimal values
  63347. * @param hex defines a string containing valid hexadecimal values
  63348. * @returns a new Color4 object
  63349. */
  63350. static FromHexString(hex: string): Color4;
  63351. /**
  63352. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63353. * @param left defines the start value
  63354. * @param right defines the end value
  63355. * @param amount defines the gradient factor
  63356. * @returns a new Color4 object
  63357. */
  63358. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63359. /**
  63360. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63361. * @param left defines the start value
  63362. * @param right defines the end value
  63363. * @param amount defines the gradient factor
  63364. * @param result defines the Color4 object where to store data
  63365. */
  63366. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63367. /**
  63368. * Creates a new Color4 from a Color3 and an alpha value
  63369. * @param color3 defines the source Color3 to read from
  63370. * @param alpha defines the alpha component (1.0 by default)
  63371. * @returns a new Color4 object
  63372. */
  63373. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63374. /**
  63375. * Creates a new Color4 from the starting index element of the given array
  63376. * @param array defines the source array to read from
  63377. * @param offset defines the offset in the source array
  63378. * @returns a new Color4 object
  63379. */
  63380. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63381. /**
  63382. * Creates a new Color3 from integer values (< 256)
  63383. * @param r defines the red component to read from (value between 0 and 255)
  63384. * @param g defines the green component to read from (value between 0 and 255)
  63385. * @param b defines the blue component to read from (value between 0 and 255)
  63386. * @param a defines the alpha component to read from (value between 0 and 255)
  63387. * @returns a new Color3 object
  63388. */
  63389. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63390. /**
  63391. * Check the content of a given array and convert it to an array containing RGBA data
  63392. * If the original array was already containing count * 4 values then it is returned directly
  63393. * @param colors defines the array to check
  63394. * @param count defines the number of RGBA data to expect
  63395. * @returns an array containing count * 4 values (RGBA)
  63396. */
  63397. static CheckColors4(colors: number[], count: number): number[];
  63398. }
  63399. /**
  63400. * Class representing a vector containing 2 coordinates
  63401. */
  63402. export class Vector2 {
  63403. /** defines the first coordinate */
  63404. x: number;
  63405. /** defines the second coordinate */
  63406. y: number;
  63407. /**
  63408. * Creates a new Vector2 from the given x and y coordinates
  63409. * @param x defines the first coordinate
  63410. * @param y defines the second coordinate
  63411. */
  63412. constructor(
  63413. /** defines the first coordinate */
  63414. x?: number,
  63415. /** defines the second coordinate */
  63416. y?: number);
  63417. /**
  63418. * Gets a string with the Vector2 coordinates
  63419. * @returns a string with the Vector2 coordinates
  63420. */
  63421. toString(): string;
  63422. /**
  63423. * Gets class name
  63424. * @returns the string "Vector2"
  63425. */
  63426. getClassName(): string;
  63427. /**
  63428. * Gets current vector hash code
  63429. * @returns the Vector2 hash code as a number
  63430. */
  63431. getHashCode(): number;
  63432. /**
  63433. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63434. * @param array defines the source array
  63435. * @param index defines the offset in source array
  63436. * @returns the current Vector2
  63437. */
  63438. toArray(array: FloatArray, index?: number): Vector2;
  63439. /**
  63440. * Copy the current vector to an array
  63441. * @returns a new array with 2 elements: the Vector2 coordinates.
  63442. */
  63443. asArray(): number[];
  63444. /**
  63445. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63446. * @param source defines the source Vector2
  63447. * @returns the current updated Vector2
  63448. */
  63449. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63450. /**
  63451. * Sets the Vector2 coordinates with the given floats
  63452. * @param x defines the first coordinate
  63453. * @param y defines the second coordinate
  63454. * @returns the current updated Vector2
  63455. */
  63456. copyFromFloats(x: number, y: number): Vector2;
  63457. /**
  63458. * Sets the Vector2 coordinates with the given floats
  63459. * @param x defines the first coordinate
  63460. * @param y defines the second coordinate
  63461. * @returns the current updated Vector2
  63462. */
  63463. set(x: number, y: number): Vector2;
  63464. /**
  63465. * Add another vector with the current one
  63466. * @param otherVector defines the other vector
  63467. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63468. */
  63469. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63470. /**
  63471. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63472. * @param otherVector defines the other vector
  63473. * @param result defines the target vector
  63474. * @returns the unmodified current Vector2
  63475. */
  63476. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63477. /**
  63478. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63479. * @param otherVector defines the other vector
  63480. * @returns the current updated Vector2
  63481. */
  63482. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63483. /**
  63484. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63485. * @param otherVector defines the other vector
  63486. * @returns a new Vector2
  63487. */
  63488. addVector3(otherVector: Vector3): Vector2;
  63489. /**
  63490. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63491. * @param otherVector defines the other vector
  63492. * @returns a new Vector2
  63493. */
  63494. subtract(otherVector: Vector2): Vector2;
  63495. /**
  63496. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63497. * @param otherVector defines the other vector
  63498. * @param result defines the target vector
  63499. * @returns the unmodified current Vector2
  63500. */
  63501. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63502. /**
  63503. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63504. * @param otherVector defines the other vector
  63505. * @returns the current updated Vector2
  63506. */
  63507. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63508. /**
  63509. * Multiplies in place the current Vector2 coordinates by the given ones
  63510. * @param otherVector defines the other vector
  63511. * @returns the current updated Vector2
  63512. */
  63513. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63514. /**
  63515. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63516. * @param otherVector defines the other vector
  63517. * @returns a new Vector2
  63518. */
  63519. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63520. /**
  63521. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63522. * @param otherVector defines the other vector
  63523. * @param result defines the target vector
  63524. * @returns the unmodified current Vector2
  63525. */
  63526. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63527. /**
  63528. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63529. * @param x defines the first coordinate
  63530. * @param y defines the second coordinate
  63531. * @returns a new Vector2
  63532. */
  63533. multiplyByFloats(x: number, y: number): Vector2;
  63534. /**
  63535. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63536. * @param otherVector defines the other vector
  63537. * @returns a new Vector2
  63538. */
  63539. divide(otherVector: Vector2): Vector2;
  63540. /**
  63541. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63542. * @param otherVector defines the other vector
  63543. * @param result defines the target vector
  63544. * @returns the unmodified current Vector2
  63545. */
  63546. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63547. /**
  63548. * Divides the current Vector2 coordinates by the given ones
  63549. * @param otherVector defines the other vector
  63550. * @returns the current updated Vector2
  63551. */
  63552. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63553. /**
  63554. * Gets a new Vector2 with current Vector2 negated coordinates
  63555. * @returns a new Vector2
  63556. */
  63557. negate(): Vector2;
  63558. /**
  63559. * Multiply the Vector2 coordinates by scale
  63560. * @param scale defines the scaling factor
  63561. * @returns the current updated Vector2
  63562. */
  63563. scaleInPlace(scale: number): Vector2;
  63564. /**
  63565. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63566. * @param scale defines the scaling factor
  63567. * @returns a new Vector2
  63568. */
  63569. scale(scale: number): Vector2;
  63570. /**
  63571. * Scale the current Vector2 values by a factor to a given Vector2
  63572. * @param scale defines the scale factor
  63573. * @param result defines the Vector2 object where to store the result
  63574. * @returns the unmodified current Vector2
  63575. */
  63576. scaleToRef(scale: number, result: Vector2): Vector2;
  63577. /**
  63578. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63579. * @param scale defines the scale factor
  63580. * @param result defines the Vector2 object where to store the result
  63581. * @returns the unmodified current Vector2
  63582. */
  63583. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63584. /**
  63585. * Gets a boolean if two vectors are equals
  63586. * @param otherVector defines the other vector
  63587. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63588. */
  63589. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63590. /**
  63591. * Gets a boolean if two vectors are equals (using an epsilon value)
  63592. * @param otherVector defines the other vector
  63593. * @param epsilon defines the minimal distance to consider equality
  63594. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63595. */
  63596. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63597. /**
  63598. * Gets a new Vector2 from current Vector2 floored values
  63599. * @returns a new Vector2
  63600. */
  63601. floor(): Vector2;
  63602. /**
  63603. * Gets a new Vector2 from current Vector2 floored values
  63604. * @returns a new Vector2
  63605. */
  63606. fract(): Vector2;
  63607. /**
  63608. * Gets the length of the vector
  63609. * @returns the vector length (float)
  63610. */
  63611. length(): number;
  63612. /**
  63613. * Gets the vector squared length
  63614. * @returns the vector squared length (float)
  63615. */
  63616. lengthSquared(): number;
  63617. /**
  63618. * Normalize the vector
  63619. * @returns the current updated Vector2
  63620. */
  63621. normalize(): Vector2;
  63622. /**
  63623. * Gets a new Vector2 copied from the Vector2
  63624. * @returns a new Vector2
  63625. */
  63626. clone(): Vector2;
  63627. /**
  63628. * Gets a new Vector2(0, 0)
  63629. * @returns a new Vector2
  63630. */
  63631. static Zero(): Vector2;
  63632. /**
  63633. * Gets a new Vector2(1, 1)
  63634. * @returns a new Vector2
  63635. */
  63636. static One(): Vector2;
  63637. /**
  63638. * Gets a new Vector2 set from the given index element of the given array
  63639. * @param array defines the data source
  63640. * @param offset defines the offset in the data source
  63641. * @returns a new Vector2
  63642. */
  63643. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63644. /**
  63645. * Sets "result" from the given index element of the given array
  63646. * @param array defines the data source
  63647. * @param offset defines the offset in the data source
  63648. * @param result defines the target vector
  63649. */
  63650. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63651. /**
  63652. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63653. * @param value1 defines 1st point of control
  63654. * @param value2 defines 2nd point of control
  63655. * @param value3 defines 3rd point of control
  63656. * @param value4 defines 4th point of control
  63657. * @param amount defines the interpolation factor
  63658. * @returns a new Vector2
  63659. */
  63660. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63661. /**
  63662. * 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".
  63663. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63664. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63665. * @param value defines the value to clamp
  63666. * @param min defines the lower limit
  63667. * @param max defines the upper limit
  63668. * @returns a new Vector2
  63669. */
  63670. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63671. /**
  63672. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63673. * @param value1 defines the 1st control point
  63674. * @param tangent1 defines the outgoing tangent
  63675. * @param value2 defines the 2nd control point
  63676. * @param tangent2 defines the incoming tangent
  63677. * @param amount defines the interpolation factor
  63678. * @returns a new Vector2
  63679. */
  63680. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63681. /**
  63682. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63683. * @param start defines the start vector
  63684. * @param end defines the end vector
  63685. * @param amount defines the interpolation factor
  63686. * @returns a new Vector2
  63687. */
  63688. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63689. /**
  63690. * Gets the dot product of the vector "left" and the vector "right"
  63691. * @param left defines first vector
  63692. * @param right defines second vector
  63693. * @returns the dot product (float)
  63694. */
  63695. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63696. /**
  63697. * Returns a new Vector2 equal to the normalized given vector
  63698. * @param vector defines the vector to normalize
  63699. * @returns a new Vector2
  63700. */
  63701. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63702. /**
  63703. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63704. * @param left defines 1st vector
  63705. * @param right defines 2nd vector
  63706. * @returns a new Vector2
  63707. */
  63708. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63709. /**
  63710. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63711. * @param left defines 1st vector
  63712. * @param right defines 2nd vector
  63713. * @returns a new Vector2
  63714. */
  63715. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63716. /**
  63717. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63718. * @param vector defines the vector to transform
  63719. * @param transformation defines the matrix to apply
  63720. * @returns a new Vector2
  63721. */
  63722. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63723. /**
  63724. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63725. * @param vector defines the vector to transform
  63726. * @param transformation defines the matrix to apply
  63727. * @param result defines the target vector
  63728. */
  63729. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63730. /**
  63731. * Determines if a given vector is included in a triangle
  63732. * @param p defines the vector to test
  63733. * @param p0 defines 1st triangle point
  63734. * @param p1 defines 2nd triangle point
  63735. * @param p2 defines 3rd triangle point
  63736. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63737. */
  63738. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63739. /**
  63740. * Gets the distance between the vectors "value1" and "value2"
  63741. * @param value1 defines first vector
  63742. * @param value2 defines second vector
  63743. * @returns the distance between vectors
  63744. */
  63745. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63746. /**
  63747. * Returns the squared distance between the vectors "value1" and "value2"
  63748. * @param value1 defines first vector
  63749. * @param value2 defines second vector
  63750. * @returns the squared distance between vectors
  63751. */
  63752. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63753. /**
  63754. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63755. * @param value1 defines first vector
  63756. * @param value2 defines second vector
  63757. * @returns a new Vector2
  63758. */
  63759. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63760. /**
  63761. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63762. * @param p defines the middle point
  63763. * @param segA defines one point of the segment
  63764. * @param segB defines the other point of the segment
  63765. * @returns the shortest distance
  63766. */
  63767. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63768. }
  63769. /**
  63770. * Classed used to store (x,y,z) vector representation
  63771. * A Vector3 is the main object used in 3D geometry
  63772. * It can represent etiher the coordinates of a point the space, either a direction
  63773. * Reminder: js uses a left handed forward facing system
  63774. */
  63775. export class Vector3 {
  63776. /**
  63777. * Defines the first coordinates (on X axis)
  63778. */
  63779. x: number;
  63780. /**
  63781. * Defines the second coordinates (on Y axis)
  63782. */
  63783. y: number;
  63784. /**
  63785. * Defines the third coordinates (on Z axis)
  63786. */
  63787. z: number;
  63788. private static _UpReadOnly;
  63789. private static _ZeroReadOnly;
  63790. /**
  63791. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63792. * @param x defines the first coordinates (on X axis)
  63793. * @param y defines the second coordinates (on Y axis)
  63794. * @param z defines the third coordinates (on Z axis)
  63795. */
  63796. constructor(
  63797. /**
  63798. * Defines the first coordinates (on X axis)
  63799. */
  63800. x?: number,
  63801. /**
  63802. * Defines the second coordinates (on Y axis)
  63803. */
  63804. y?: number,
  63805. /**
  63806. * Defines the third coordinates (on Z axis)
  63807. */
  63808. z?: number);
  63809. /**
  63810. * Creates a string representation of the Vector3
  63811. * @returns a string with the Vector3 coordinates.
  63812. */
  63813. toString(): string;
  63814. /**
  63815. * Gets the class name
  63816. * @returns the string "Vector3"
  63817. */
  63818. getClassName(): string;
  63819. /**
  63820. * Creates the Vector3 hash code
  63821. * @returns a number which tends to be unique between Vector3 instances
  63822. */
  63823. getHashCode(): number;
  63824. /**
  63825. * Creates an array containing three elements : the coordinates of the Vector3
  63826. * @returns a new array of numbers
  63827. */
  63828. asArray(): number[];
  63829. /**
  63830. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63831. * @param array defines the destination array
  63832. * @param index defines the offset in the destination array
  63833. * @returns the current Vector3
  63834. */
  63835. toArray(array: FloatArray, index?: number): Vector3;
  63836. /**
  63837. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63838. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63839. */
  63840. toQuaternion(): Quaternion;
  63841. /**
  63842. * Adds the given vector to the current Vector3
  63843. * @param otherVector defines the second operand
  63844. * @returns the current updated Vector3
  63845. */
  63846. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63847. /**
  63848. * Adds the given coordinates to the current Vector3
  63849. * @param x defines the x coordinate of the operand
  63850. * @param y defines the y coordinate of the operand
  63851. * @param z defines the z coordinate of the operand
  63852. * @returns the current updated Vector3
  63853. */
  63854. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63855. /**
  63856. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63857. * @param otherVector defines the second operand
  63858. * @returns the resulting Vector3
  63859. */
  63860. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63861. /**
  63862. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63863. * @param otherVector defines the second operand
  63864. * @param result defines the Vector3 object where to store the result
  63865. * @returns the current Vector3
  63866. */
  63867. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63868. /**
  63869. * Subtract the given vector from the current Vector3
  63870. * @param otherVector defines the second operand
  63871. * @returns the current updated Vector3
  63872. */
  63873. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63874. /**
  63875. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63876. * @param otherVector defines the second operand
  63877. * @returns the resulting Vector3
  63878. */
  63879. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63880. /**
  63881. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63882. * @param otherVector defines the second operand
  63883. * @param result defines the Vector3 object where to store the result
  63884. * @returns the current Vector3
  63885. */
  63886. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63887. /**
  63888. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63889. * @param x defines the x coordinate of the operand
  63890. * @param y defines the y coordinate of the operand
  63891. * @param z defines the z coordinate of the operand
  63892. * @returns the resulting Vector3
  63893. */
  63894. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63895. /**
  63896. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63897. * @param x defines the x coordinate of the operand
  63898. * @param y defines the y coordinate of the operand
  63899. * @param z defines the z coordinate of the operand
  63900. * @param result defines the Vector3 object where to store the result
  63901. * @returns the current Vector3
  63902. */
  63903. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63904. /**
  63905. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63906. * @returns a new Vector3
  63907. */
  63908. negate(): Vector3;
  63909. /**
  63910. * Multiplies the Vector3 coordinates by the float "scale"
  63911. * @param scale defines the multiplier factor
  63912. * @returns the current updated Vector3
  63913. */
  63914. scaleInPlace(scale: number): Vector3;
  63915. /**
  63916. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63917. * @param scale defines the multiplier factor
  63918. * @returns a new Vector3
  63919. */
  63920. scale(scale: number): Vector3;
  63921. /**
  63922. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63923. * @param scale defines the multiplier factor
  63924. * @param result defines the Vector3 object where to store the result
  63925. * @returns the current Vector3
  63926. */
  63927. scaleToRef(scale: number, result: Vector3): Vector3;
  63928. /**
  63929. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63930. * @param scale defines the scale factor
  63931. * @param result defines the Vector3 object where to store the result
  63932. * @returns the unmodified current Vector3
  63933. */
  63934. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63935. /**
  63936. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63937. * @param otherVector defines the second operand
  63938. * @returns true if both vectors are equals
  63939. */
  63940. equals(otherVector: DeepImmutable<Vector3>): boolean;
  63941. /**
  63942. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  63943. * @param otherVector defines the second operand
  63944. * @param epsilon defines the minimal distance to define values as equals
  63945. * @returns true if both vectors are distant less than epsilon
  63946. */
  63947. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  63948. /**
  63949. * Returns true if the current Vector3 coordinates equals the given floats
  63950. * @param x defines the x coordinate of the operand
  63951. * @param y defines the y coordinate of the operand
  63952. * @param z defines the z coordinate of the operand
  63953. * @returns true if both vectors are equals
  63954. */
  63955. equalsToFloats(x: number, y: number, z: number): boolean;
  63956. /**
  63957. * Multiplies the current Vector3 coordinates by the given ones
  63958. * @param otherVector defines the second operand
  63959. * @returns the current updated Vector3
  63960. */
  63961. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63962. /**
  63963. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  63964. * @param otherVector defines the second operand
  63965. * @returns the new Vector3
  63966. */
  63967. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  63968. /**
  63969. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  63970. * @param otherVector defines the second operand
  63971. * @param result defines the Vector3 object where to store the result
  63972. * @returns the current Vector3
  63973. */
  63974. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63975. /**
  63976. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  63977. * @param x defines the x coordinate of the operand
  63978. * @param y defines the y coordinate of the operand
  63979. * @param z defines the z coordinate of the operand
  63980. * @returns the new Vector3
  63981. */
  63982. multiplyByFloats(x: number, y: number, z: number): Vector3;
  63983. /**
  63984. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  63985. * @param otherVector defines the second operand
  63986. * @returns the new Vector3
  63987. */
  63988. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  63989. /**
  63990. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  63991. * @param otherVector defines the second operand
  63992. * @param result defines the Vector3 object where to store the result
  63993. * @returns the current Vector3
  63994. */
  63995. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63996. /**
  63997. * Divides the current Vector3 coordinates by the given ones.
  63998. * @param otherVector defines the second operand
  63999. * @returns the current updated Vector3
  64000. */
  64001. divideInPlace(otherVector: Vector3): Vector3;
  64002. /**
  64003. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64004. * @param other defines the second operand
  64005. * @returns the current updated Vector3
  64006. */
  64007. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64008. /**
  64009. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64010. * @param other defines the second operand
  64011. * @returns the current updated Vector3
  64012. */
  64013. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64014. /**
  64015. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64016. * @param x defines the x coordinate of the operand
  64017. * @param y defines the y coordinate of the operand
  64018. * @param z defines the z coordinate of the operand
  64019. * @returns the current updated Vector3
  64020. */
  64021. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64022. /**
  64023. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64024. * @param x defines the x coordinate of the operand
  64025. * @param y defines the y coordinate of the operand
  64026. * @param z defines the z coordinate of the operand
  64027. * @returns the current updated Vector3
  64028. */
  64029. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64030. /**
  64031. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64032. * Check if is non uniform within a certain amount of decimal places to account for this
  64033. * @param epsilon the amount the values can differ
  64034. * @returns if the the vector is non uniform to a certain number of decimal places
  64035. */
  64036. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64037. /**
  64038. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64039. */
  64040. readonly isNonUniform: boolean;
  64041. /**
  64042. * Gets a new Vector3 from current Vector3 floored values
  64043. * @returns a new Vector3
  64044. */
  64045. floor(): Vector3;
  64046. /**
  64047. * Gets a new Vector3 from current Vector3 floored values
  64048. * @returns a new Vector3
  64049. */
  64050. fract(): Vector3;
  64051. /**
  64052. * Gets the length of the Vector3
  64053. * @returns the length of the Vector3
  64054. */
  64055. length(): number;
  64056. /**
  64057. * Gets the squared length of the Vector3
  64058. * @returns squared length of the Vector3
  64059. */
  64060. lengthSquared(): number;
  64061. /**
  64062. * Normalize the current Vector3.
  64063. * Please note that this is an in place operation.
  64064. * @returns the current updated Vector3
  64065. */
  64066. normalize(): Vector3;
  64067. /**
  64068. * Reorders the x y z properties of the vector in place
  64069. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64070. * @returns the current updated vector
  64071. */
  64072. reorderInPlace(order: string): this;
  64073. /**
  64074. * Rotates the vector around 0,0,0 by a quaternion
  64075. * @param quaternion the rotation quaternion
  64076. * @param result vector to store the result
  64077. * @returns the resulting vector
  64078. */
  64079. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64080. /**
  64081. * Rotates a vector around a given point
  64082. * @param quaternion the rotation quaternion
  64083. * @param point the point to rotate around
  64084. * @param result vector to store the result
  64085. * @returns the resulting vector
  64086. */
  64087. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64088. /**
  64089. * Normalize the current Vector3 with the given input length.
  64090. * Please note that this is an in place operation.
  64091. * @param len the length of the vector
  64092. * @returns the current updated Vector3
  64093. */
  64094. normalizeFromLength(len: number): Vector3;
  64095. /**
  64096. * Normalize the current Vector3 to a new vector
  64097. * @returns the new Vector3
  64098. */
  64099. normalizeToNew(): Vector3;
  64100. /**
  64101. * Normalize the current Vector3 to the reference
  64102. * @param reference define the Vector3 to update
  64103. * @returns the updated Vector3
  64104. */
  64105. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64106. /**
  64107. * Creates a new Vector3 copied from the current Vector3
  64108. * @returns the new Vector3
  64109. */
  64110. clone(): Vector3;
  64111. /**
  64112. * Copies the given vector coordinates to the current Vector3 ones
  64113. * @param source defines the source Vector3
  64114. * @returns the current updated Vector3
  64115. */
  64116. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64117. /**
  64118. * Copies the given floats to the current Vector3 coordinates
  64119. * @param x defines the x coordinate of the operand
  64120. * @param y defines the y coordinate of the operand
  64121. * @param z defines the z coordinate of the operand
  64122. * @returns the current updated Vector3
  64123. */
  64124. copyFromFloats(x: number, y: number, z: number): Vector3;
  64125. /**
  64126. * Copies the given floats to the current Vector3 coordinates
  64127. * @param x defines the x coordinate of the operand
  64128. * @param y defines the y coordinate of the operand
  64129. * @param z defines the z coordinate of the operand
  64130. * @returns the current updated Vector3
  64131. */
  64132. set(x: number, y: number, z: number): Vector3;
  64133. /**
  64134. * Copies the given float to the current Vector3 coordinates
  64135. * @param v defines the x, y and z coordinates of the operand
  64136. * @returns the current updated Vector3
  64137. */
  64138. setAll(v: number): Vector3;
  64139. /**
  64140. * Get the clip factor between two vectors
  64141. * @param vector0 defines the first operand
  64142. * @param vector1 defines the second operand
  64143. * @param axis defines the axis to use
  64144. * @param size defines the size along the axis
  64145. * @returns the clip factor
  64146. */
  64147. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64148. /**
  64149. * Get angle between two vectors
  64150. * @param vector0 angle between vector0 and vector1
  64151. * @param vector1 angle between vector0 and vector1
  64152. * @param normal direction of the normal
  64153. * @return the angle between vector0 and vector1
  64154. */
  64155. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64156. /**
  64157. * Returns a new Vector3 set from the index "offset" of the given array
  64158. * @param array defines the source array
  64159. * @param offset defines the offset in the source array
  64160. * @returns the new Vector3
  64161. */
  64162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64163. /**
  64164. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64165. * This function is deprecated. Use FromArray instead
  64166. * @param array defines the source array
  64167. * @param offset defines the offset in the source array
  64168. * @returns the new Vector3
  64169. */
  64170. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64171. /**
  64172. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64173. * @param array defines the source array
  64174. * @param offset defines the offset in the source array
  64175. * @param result defines the Vector3 where to store the result
  64176. */
  64177. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64178. /**
  64179. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64180. * This function is deprecated. Use FromArrayToRef instead.
  64181. * @param array defines the source array
  64182. * @param offset defines the offset in the source array
  64183. * @param result defines the Vector3 where to store the result
  64184. */
  64185. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64186. /**
  64187. * Sets the given vector "result" with the given floats.
  64188. * @param x defines the x coordinate of the source
  64189. * @param y defines the y coordinate of the source
  64190. * @param z defines the z coordinate of the source
  64191. * @param result defines the Vector3 where to store the result
  64192. */
  64193. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64194. /**
  64195. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64196. * @returns a new empty Vector3
  64197. */
  64198. static Zero(): Vector3;
  64199. /**
  64200. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64201. * @returns a new unit Vector3
  64202. */
  64203. static One(): Vector3;
  64204. /**
  64205. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64206. * @returns a new up Vector3
  64207. */
  64208. static Up(): Vector3;
  64209. /**
  64210. * Gets a up Vector3 that must not be updated
  64211. */
  64212. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64213. /**
  64214. * Gets a zero Vector3 that must not be updated
  64215. */
  64216. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64217. /**
  64218. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64219. * @returns a new down Vector3
  64220. */
  64221. static Down(): Vector3;
  64222. /**
  64223. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64224. * @returns a new forward Vector3
  64225. */
  64226. static Forward(): Vector3;
  64227. /**
  64228. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64229. * @returns a new forward Vector3
  64230. */
  64231. static Backward(): Vector3;
  64232. /**
  64233. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64234. * @returns a new right Vector3
  64235. */
  64236. static Right(): Vector3;
  64237. /**
  64238. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64239. * @returns a new left Vector3
  64240. */
  64241. static Left(): Vector3;
  64242. /**
  64243. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64244. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64245. * @param vector defines the Vector3 to transform
  64246. * @param transformation defines the transformation matrix
  64247. * @returns the transformed Vector3
  64248. */
  64249. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64250. /**
  64251. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64252. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64253. * @param vector defines the Vector3 to transform
  64254. * @param transformation defines the transformation matrix
  64255. * @param result defines the Vector3 where to store the result
  64256. */
  64257. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64258. /**
  64259. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64260. * This method computes tranformed coordinates only, not transformed direction vectors
  64261. * @param x define the x coordinate of the source vector
  64262. * @param y define the y coordinate of the source vector
  64263. * @param z define the z coordinate of the source vector
  64264. * @param transformation defines the transformation matrix
  64265. * @param result defines the Vector3 where to store the result
  64266. */
  64267. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64268. /**
  64269. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64270. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64271. * @param vector defines the Vector3 to transform
  64272. * @param transformation defines the transformation matrix
  64273. * @returns the new Vector3
  64274. */
  64275. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64276. /**
  64277. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64278. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64279. * @param vector defines the Vector3 to transform
  64280. * @param transformation defines the transformation matrix
  64281. * @param result defines the Vector3 where to store the result
  64282. */
  64283. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64284. /**
  64285. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64286. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64287. * @param x define the x coordinate of the source vector
  64288. * @param y define the y coordinate of the source vector
  64289. * @param z define the z coordinate of the source vector
  64290. * @param transformation defines the transformation matrix
  64291. * @param result defines the Vector3 where to store the result
  64292. */
  64293. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64294. /**
  64295. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64296. * @param value1 defines the first control point
  64297. * @param value2 defines the second control point
  64298. * @param value3 defines the third control point
  64299. * @param value4 defines the fourth control point
  64300. * @param amount defines the amount on the spline to use
  64301. * @returns the new Vector3
  64302. */
  64303. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64304. /**
  64305. * 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"
  64306. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64307. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64308. * @param value defines the current value
  64309. * @param min defines the lower range value
  64310. * @param max defines the upper range value
  64311. * @returns the new Vector3
  64312. */
  64313. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64314. /**
  64315. * 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"
  64316. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64317. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64318. * @param value defines the current value
  64319. * @param min defines the lower range value
  64320. * @param max defines the upper range value
  64321. * @param result defines the Vector3 where to store the result
  64322. */
  64323. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64324. /**
  64325. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64326. * @param value1 defines the first control point
  64327. * @param tangent1 defines the first tangent vector
  64328. * @param value2 defines the second control point
  64329. * @param tangent2 defines the second tangent vector
  64330. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64331. * @returns the new Vector3
  64332. */
  64333. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64334. /**
  64335. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64336. * @param start defines the start value
  64337. * @param end defines the end value
  64338. * @param amount max defines amount between both (between 0 and 1)
  64339. * @returns the new Vector3
  64340. */
  64341. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64342. /**
  64343. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64344. * @param start defines the start value
  64345. * @param end defines the end value
  64346. * @param amount max defines amount between both (between 0 and 1)
  64347. * @param result defines the Vector3 where to store the result
  64348. */
  64349. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64350. /**
  64351. * Returns the dot product (float) between the vectors "left" and "right"
  64352. * @param left defines the left operand
  64353. * @param right defines the right operand
  64354. * @returns the dot product
  64355. */
  64356. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64357. /**
  64358. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64359. * The cross product is then orthogonal to both "left" and "right"
  64360. * @param left defines the left operand
  64361. * @param right defines the right operand
  64362. * @returns the cross product
  64363. */
  64364. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64365. /**
  64366. * Sets the given vector "result" with the cross product of "left" and "right"
  64367. * The cross product is then orthogonal to both "left" and "right"
  64368. * @param left defines the left operand
  64369. * @param right defines the right operand
  64370. * @param result defines the Vector3 where to store the result
  64371. */
  64372. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64373. /**
  64374. * Returns a new Vector3 as the normalization of the given vector
  64375. * @param vector defines the Vector3 to normalize
  64376. * @returns the new Vector3
  64377. */
  64378. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64379. /**
  64380. * Sets the given vector "result" with the normalization of the given first vector
  64381. * @param vector defines the Vector3 to normalize
  64382. * @param result defines the Vector3 where to store the result
  64383. */
  64384. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64385. /**
  64386. * Project a Vector3 onto screen space
  64387. * @param vector defines the Vector3 to project
  64388. * @param world defines the world matrix to use
  64389. * @param transform defines the transform (view x projection) matrix to use
  64390. * @param viewport defines the screen viewport to use
  64391. * @returns the new Vector3
  64392. */
  64393. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64394. /** @hidden */
  64395. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64396. /**
  64397. * Unproject from screen space to object space
  64398. * @param source defines the screen space Vector3 to use
  64399. * @param viewportWidth defines the current width of the viewport
  64400. * @param viewportHeight defines the current height of the viewport
  64401. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64402. * @param transform defines the transform (view x projection) matrix to use
  64403. * @returns the new Vector3
  64404. */
  64405. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64406. /**
  64407. * Unproject from screen space to object space
  64408. * @param source defines the screen space Vector3 to use
  64409. * @param viewportWidth defines the current width of the viewport
  64410. * @param viewportHeight defines the current height of the viewport
  64411. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64412. * @param view defines the view matrix to use
  64413. * @param projection defines the projection matrix to use
  64414. * @returns the new Vector3
  64415. */
  64416. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64417. /**
  64418. * Unproject from screen space to object space
  64419. * @param source defines the screen space Vector3 to use
  64420. * @param viewportWidth defines the current width of the viewport
  64421. * @param viewportHeight defines the current height of the viewport
  64422. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64423. * @param view defines the view matrix to use
  64424. * @param projection defines the projection matrix to use
  64425. * @param result defines the Vector3 where to store the result
  64426. */
  64427. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64428. /**
  64429. * Unproject from screen space to object space
  64430. * @param sourceX defines the screen space x coordinate to use
  64431. * @param sourceY defines the screen space y coordinate to use
  64432. * @param sourceZ defines the screen space z coordinate to use
  64433. * @param viewportWidth defines the current width of the viewport
  64434. * @param viewportHeight defines the current height of the viewport
  64435. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64436. * @param view defines the view matrix to use
  64437. * @param projection defines the projection matrix to use
  64438. * @param result defines the Vector3 where to store the result
  64439. */
  64440. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64441. /**
  64442. * Gets the minimal coordinate values between two Vector3
  64443. * @param left defines the first operand
  64444. * @param right defines the second operand
  64445. * @returns the new Vector3
  64446. */
  64447. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64448. /**
  64449. * Gets the maximal coordinate values between two Vector3
  64450. * @param left defines the first operand
  64451. * @param right defines the second operand
  64452. * @returns the new Vector3
  64453. */
  64454. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64455. /**
  64456. * Returns the distance between the vectors "value1" and "value2"
  64457. * @param value1 defines the first operand
  64458. * @param value2 defines the second operand
  64459. * @returns the distance
  64460. */
  64461. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64462. /**
  64463. * Returns the squared distance between the vectors "value1" and "value2"
  64464. * @param value1 defines the first operand
  64465. * @param value2 defines the second operand
  64466. * @returns the squared distance
  64467. */
  64468. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64469. /**
  64470. * Returns a new Vector3 located at the center between "value1" and "value2"
  64471. * @param value1 defines the first operand
  64472. * @param value2 defines the second operand
  64473. * @returns the new Vector3
  64474. */
  64475. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64476. /**
  64477. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64478. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64479. * to something in order to rotate it from its local system to the given target system
  64480. * Note: axis1, axis2 and axis3 are normalized during this operation
  64481. * @param axis1 defines the first axis
  64482. * @param axis2 defines the second axis
  64483. * @param axis3 defines the third axis
  64484. * @returns a new Vector3
  64485. */
  64486. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64487. /**
  64488. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64489. * @param axis1 defines the first axis
  64490. * @param axis2 defines the second axis
  64491. * @param axis3 defines the third axis
  64492. * @param ref defines the Vector3 where to store the result
  64493. */
  64494. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64495. }
  64496. /**
  64497. * Vector4 class created for EulerAngle class conversion to Quaternion
  64498. */
  64499. export class Vector4 {
  64500. /** x value of the vector */
  64501. x: number;
  64502. /** y value of the vector */
  64503. y: number;
  64504. /** z value of the vector */
  64505. z: number;
  64506. /** w value of the vector */
  64507. w: number;
  64508. /**
  64509. * Creates a Vector4 object from the given floats.
  64510. * @param x x value of the vector
  64511. * @param y y value of the vector
  64512. * @param z z value of the vector
  64513. * @param w w value of the vector
  64514. */
  64515. constructor(
  64516. /** x value of the vector */
  64517. x: number,
  64518. /** y value of the vector */
  64519. y: number,
  64520. /** z value of the vector */
  64521. z: number,
  64522. /** w value of the vector */
  64523. w: number);
  64524. /**
  64525. * Returns the string with the Vector4 coordinates.
  64526. * @returns a string containing all the vector values
  64527. */
  64528. toString(): string;
  64529. /**
  64530. * Returns the string "Vector4".
  64531. * @returns "Vector4"
  64532. */
  64533. getClassName(): string;
  64534. /**
  64535. * Returns the Vector4 hash code.
  64536. * @returns a unique hash code
  64537. */
  64538. getHashCode(): number;
  64539. /**
  64540. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64541. * @returns the resulting array
  64542. */
  64543. asArray(): number[];
  64544. /**
  64545. * Populates the given array from the given index with the Vector4 coordinates.
  64546. * @param array array to populate
  64547. * @param index index of the array to start at (default: 0)
  64548. * @returns the Vector4.
  64549. */
  64550. toArray(array: FloatArray, index?: number): Vector4;
  64551. /**
  64552. * Adds the given vector to the current Vector4.
  64553. * @param otherVector the vector to add
  64554. * @returns the updated Vector4.
  64555. */
  64556. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64557. /**
  64558. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64559. * @param otherVector the vector to add
  64560. * @returns the resulting vector
  64561. */
  64562. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64563. /**
  64564. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64565. * @param otherVector the vector to add
  64566. * @param result the vector to store the result
  64567. * @returns the current Vector4.
  64568. */
  64569. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64570. /**
  64571. * Subtract in place the given vector from the current Vector4.
  64572. * @param otherVector the vector to subtract
  64573. * @returns the updated Vector4.
  64574. */
  64575. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64576. /**
  64577. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64578. * @param otherVector the vector to add
  64579. * @returns the new vector with the result
  64580. */
  64581. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64582. /**
  64583. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64584. * @param otherVector the vector to subtract
  64585. * @param result the vector to store the result
  64586. * @returns the current Vector4.
  64587. */
  64588. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64589. /**
  64590. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64591. */
  64592. /**
  64593. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64594. * @param x value to subtract
  64595. * @param y value to subtract
  64596. * @param z value to subtract
  64597. * @param w value to subtract
  64598. * @returns new vector containing the result
  64599. */
  64600. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64601. /**
  64602. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64603. * @param x value to subtract
  64604. * @param y value to subtract
  64605. * @param z value to subtract
  64606. * @param w value to subtract
  64607. * @param result the vector to store the result in
  64608. * @returns the current Vector4.
  64609. */
  64610. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64611. /**
  64612. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64613. * @returns a new vector with the negated values
  64614. */
  64615. negate(): Vector4;
  64616. /**
  64617. * Multiplies the current Vector4 coordinates by scale (float).
  64618. * @param scale the number to scale with
  64619. * @returns the updated Vector4.
  64620. */
  64621. scaleInPlace(scale: number): Vector4;
  64622. /**
  64623. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64624. * @param scale the number to scale with
  64625. * @returns a new vector with the result
  64626. */
  64627. scale(scale: number): Vector4;
  64628. /**
  64629. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64630. * @param scale the number to scale with
  64631. * @param result a vector to store the result in
  64632. * @returns the current Vector4.
  64633. */
  64634. scaleToRef(scale: number, result: Vector4): Vector4;
  64635. /**
  64636. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64637. * @param scale defines the scale factor
  64638. * @param result defines the Vector4 object where to store the result
  64639. * @returns the unmodified current Vector4
  64640. */
  64641. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64642. /**
  64643. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64644. * @param otherVector the vector to compare against
  64645. * @returns true if they are equal
  64646. */
  64647. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64648. /**
  64649. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64650. * @param otherVector vector to compare against
  64651. * @param epsilon (Default: very small number)
  64652. * @returns true if they are equal
  64653. */
  64654. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64655. /**
  64656. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64657. * @param x x value to compare against
  64658. * @param y y value to compare against
  64659. * @param z z value to compare against
  64660. * @param w w value to compare against
  64661. * @returns true if equal
  64662. */
  64663. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64664. /**
  64665. * Multiplies in place the current Vector4 by the given one.
  64666. * @param otherVector vector to multiple with
  64667. * @returns the updated Vector4.
  64668. */
  64669. multiplyInPlace(otherVector: Vector4): Vector4;
  64670. /**
  64671. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64672. * @param otherVector vector to multiple with
  64673. * @returns resulting new vector
  64674. */
  64675. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64676. /**
  64677. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64678. * @param otherVector vector to multiple with
  64679. * @param result vector to store the result
  64680. * @returns the current Vector4.
  64681. */
  64682. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64683. /**
  64684. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64685. * @param x x value multiply with
  64686. * @param y y value multiply with
  64687. * @param z z value multiply with
  64688. * @param w w value multiply with
  64689. * @returns resulting new vector
  64690. */
  64691. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64692. /**
  64693. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64694. * @param otherVector vector to devide with
  64695. * @returns resulting new vector
  64696. */
  64697. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64698. /**
  64699. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64700. * @param otherVector vector to devide with
  64701. * @param result vector to store the result
  64702. * @returns the current Vector4.
  64703. */
  64704. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64705. /**
  64706. * Divides the current Vector3 coordinates by the given ones.
  64707. * @param otherVector vector to devide with
  64708. * @returns the updated Vector3.
  64709. */
  64710. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64711. /**
  64712. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64713. * @param other defines the second operand
  64714. * @returns the current updated Vector4
  64715. */
  64716. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64717. /**
  64718. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64719. * @param other defines the second operand
  64720. * @returns the current updated Vector4
  64721. */
  64722. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64723. /**
  64724. * Gets a new Vector4 from current Vector4 floored values
  64725. * @returns a new Vector4
  64726. */
  64727. floor(): Vector4;
  64728. /**
  64729. * Gets a new Vector4 from current Vector3 floored values
  64730. * @returns a new Vector4
  64731. */
  64732. fract(): Vector4;
  64733. /**
  64734. * Returns the Vector4 length (float).
  64735. * @returns the length
  64736. */
  64737. length(): number;
  64738. /**
  64739. * Returns the Vector4 squared length (float).
  64740. * @returns the length squared
  64741. */
  64742. lengthSquared(): number;
  64743. /**
  64744. * Normalizes in place the Vector4.
  64745. * @returns the updated Vector4.
  64746. */
  64747. normalize(): Vector4;
  64748. /**
  64749. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64750. * @returns this converted to a new vector3
  64751. */
  64752. toVector3(): Vector3;
  64753. /**
  64754. * Returns a new Vector4 copied from the current one.
  64755. * @returns the new cloned vector
  64756. */
  64757. clone(): Vector4;
  64758. /**
  64759. * Updates the current Vector4 with the given one coordinates.
  64760. * @param source the source vector to copy from
  64761. * @returns the updated Vector4.
  64762. */
  64763. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64764. /**
  64765. * Updates the current Vector4 coordinates with the given floats.
  64766. * @param x float to copy from
  64767. * @param y float to copy from
  64768. * @param z float to copy from
  64769. * @param w float to copy from
  64770. * @returns the updated Vector4.
  64771. */
  64772. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64773. /**
  64774. * Updates the current Vector4 coordinates with the given floats.
  64775. * @param x float to set from
  64776. * @param y float to set from
  64777. * @param z float to set from
  64778. * @param w float to set from
  64779. * @returns the updated Vector4.
  64780. */
  64781. set(x: number, y: number, z: number, w: number): Vector4;
  64782. /**
  64783. * Copies the given float to the current Vector3 coordinates
  64784. * @param v defines the x, y, z and w coordinates of the operand
  64785. * @returns the current updated Vector3
  64786. */
  64787. setAll(v: number): Vector4;
  64788. /**
  64789. * Returns a new Vector4 set from the starting index of the given array.
  64790. * @param array the array to pull values from
  64791. * @param offset the offset into the array to start at
  64792. * @returns the new vector
  64793. */
  64794. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64795. /**
  64796. * Updates the given vector "result" from the starting index of the given array.
  64797. * @param array the array to pull values from
  64798. * @param offset the offset into the array to start at
  64799. * @param result the vector to store the result in
  64800. */
  64801. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64802. /**
  64803. * Updates the given vector "result" from the starting index of the given Float32Array.
  64804. * @param array the array to pull values from
  64805. * @param offset the offset into the array to start at
  64806. * @param result the vector to store the result in
  64807. */
  64808. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64809. /**
  64810. * Updates the given vector "result" coordinates from the given floats.
  64811. * @param x float to set from
  64812. * @param y float to set from
  64813. * @param z float to set from
  64814. * @param w float to set from
  64815. * @param result the vector to the floats in
  64816. */
  64817. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64818. /**
  64819. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64820. * @returns the new vector
  64821. */
  64822. static Zero(): Vector4;
  64823. /**
  64824. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64825. * @returns the new vector
  64826. */
  64827. static One(): Vector4;
  64828. /**
  64829. * Returns a new normalized Vector4 from the given one.
  64830. * @param vector the vector to normalize
  64831. * @returns the vector
  64832. */
  64833. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64834. /**
  64835. * Updates the given vector "result" from the normalization of the given one.
  64836. * @param vector the vector to normalize
  64837. * @param result the vector to store the result in
  64838. */
  64839. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64840. /**
  64841. * Returns a vector with the minimum values from the left and right vectors
  64842. * @param left left vector to minimize
  64843. * @param right right vector to minimize
  64844. * @returns a new vector with the minimum of the left and right vector values
  64845. */
  64846. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64847. /**
  64848. * Returns a vector with the maximum values from the left and right vectors
  64849. * @param left left vector to maximize
  64850. * @param right right vector to maximize
  64851. * @returns a new vector with the maximum of the left and right vector values
  64852. */
  64853. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64854. /**
  64855. * Returns the distance (float) between the vectors "value1" and "value2".
  64856. * @param value1 value to calulate the distance between
  64857. * @param value2 value to calulate the distance between
  64858. * @return the distance between the two vectors
  64859. */
  64860. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64861. /**
  64862. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64863. * @param value1 value to calulate the distance between
  64864. * @param value2 value to calulate the distance between
  64865. * @return the distance between the two vectors squared
  64866. */
  64867. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64868. /**
  64869. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64870. * @param value1 value to calulate the center between
  64871. * @param value2 value to calulate the center between
  64872. * @return the center between the two vectors
  64873. */
  64874. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64875. /**
  64876. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64877. * This methods computes transformed normalized direction vectors only.
  64878. * @param vector the vector to transform
  64879. * @param transformation the transformation matrix to apply
  64880. * @returns the new vector
  64881. */
  64882. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64883. /**
  64884. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64885. * This methods computes transformed normalized direction vectors only.
  64886. * @param vector the vector to transform
  64887. * @param transformation the transformation matrix to apply
  64888. * @param result the vector to store the result in
  64889. */
  64890. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64891. /**
  64892. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64893. * This methods computes transformed normalized direction vectors only.
  64894. * @param x value to transform
  64895. * @param y value to transform
  64896. * @param z value to transform
  64897. * @param w value to transform
  64898. * @param transformation the transformation matrix to apply
  64899. * @param result the vector to store the results in
  64900. */
  64901. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64902. /**
  64903. * Creates a new Vector4 from a Vector3
  64904. * @param source defines the source data
  64905. * @param w defines the 4th component (default is 0)
  64906. * @returns a new Vector4
  64907. */
  64908. static FromVector3(source: Vector3, w?: number): Vector4;
  64909. }
  64910. /**
  64911. * Interface for the size containing width and height
  64912. */
  64913. export interface ISize {
  64914. /**
  64915. * Width
  64916. */
  64917. width: number;
  64918. /**
  64919. * Heighht
  64920. */
  64921. height: number;
  64922. }
  64923. /**
  64924. * Size containing widht and height
  64925. */
  64926. export class Size implements ISize {
  64927. /**
  64928. * Width
  64929. */
  64930. width: number;
  64931. /**
  64932. * Height
  64933. */
  64934. height: number;
  64935. /**
  64936. * Creates a Size object from the given width and height (floats).
  64937. * @param width width of the new size
  64938. * @param height height of the new size
  64939. */
  64940. constructor(width: number, height: number);
  64941. /**
  64942. * Returns a string with the Size width and height
  64943. * @returns a string with the Size width and height
  64944. */
  64945. toString(): string;
  64946. /**
  64947. * "Size"
  64948. * @returns the string "Size"
  64949. */
  64950. getClassName(): string;
  64951. /**
  64952. * Returns the Size hash code.
  64953. * @returns a hash code for a unique width and height
  64954. */
  64955. getHashCode(): number;
  64956. /**
  64957. * Updates the current size from the given one.
  64958. * @param src the given size
  64959. */
  64960. copyFrom(src: Size): void;
  64961. /**
  64962. * Updates in place the current Size from the given floats.
  64963. * @param width width of the new size
  64964. * @param height height of the new size
  64965. * @returns the updated Size.
  64966. */
  64967. copyFromFloats(width: number, height: number): Size;
  64968. /**
  64969. * Updates in place the current Size from the given floats.
  64970. * @param width width to set
  64971. * @param height height to set
  64972. * @returns the updated Size.
  64973. */
  64974. set(width: number, height: number): Size;
  64975. /**
  64976. * Multiplies the width and height by numbers
  64977. * @param w factor to multiple the width by
  64978. * @param h factor to multiple the height by
  64979. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  64980. */
  64981. multiplyByFloats(w: number, h: number): Size;
  64982. /**
  64983. * Clones the size
  64984. * @returns a new Size copied from the given one.
  64985. */
  64986. clone(): Size;
  64987. /**
  64988. * True if the current Size and the given one width and height are strictly equal.
  64989. * @param other the other size to compare against
  64990. * @returns True if the current Size and the given one width and height are strictly equal.
  64991. */
  64992. equals(other: Size): boolean;
  64993. /**
  64994. * The surface of the Size : width * height (float).
  64995. */
  64996. readonly surface: number;
  64997. /**
  64998. * Create a new size of zero
  64999. * @returns a new Size set to (0.0, 0.0)
  65000. */
  65001. static Zero(): Size;
  65002. /**
  65003. * Sums the width and height of two sizes
  65004. * @param otherSize size to add to this size
  65005. * @returns a new Size set as the addition result of the current Size and the given one.
  65006. */
  65007. add(otherSize: Size): Size;
  65008. /**
  65009. * Subtracts the width and height of two
  65010. * @param otherSize size to subtract to this size
  65011. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65012. */
  65013. subtract(otherSize: Size): Size;
  65014. /**
  65015. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65016. * @param start starting size to lerp between
  65017. * @param end end size to lerp between
  65018. * @param amount amount to lerp between the start and end values
  65019. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65020. */
  65021. static Lerp(start: Size, end: Size, amount: number): Size;
  65022. }
  65023. /**
  65024. * Class used to store quaternion data
  65025. * @see https://en.wikipedia.org/wiki/Quaternion
  65026. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65027. */
  65028. export class Quaternion {
  65029. /** defines the first component (0 by default) */
  65030. x: number;
  65031. /** defines the second component (0 by default) */
  65032. y: number;
  65033. /** defines the third component (0 by default) */
  65034. z: number;
  65035. /** defines the fourth component (1.0 by default) */
  65036. w: number;
  65037. /**
  65038. * Creates a new Quaternion from the given floats
  65039. * @param x defines the first component (0 by default)
  65040. * @param y defines the second component (0 by default)
  65041. * @param z defines the third component (0 by default)
  65042. * @param w defines the fourth component (1.0 by default)
  65043. */
  65044. constructor(
  65045. /** defines the first component (0 by default) */
  65046. x?: number,
  65047. /** defines the second component (0 by default) */
  65048. y?: number,
  65049. /** defines the third component (0 by default) */
  65050. z?: number,
  65051. /** defines the fourth component (1.0 by default) */
  65052. w?: number);
  65053. /**
  65054. * Gets a string representation for the current quaternion
  65055. * @returns a string with the Quaternion coordinates
  65056. */
  65057. toString(): string;
  65058. /**
  65059. * Gets the class name of the quaternion
  65060. * @returns the string "Quaternion"
  65061. */
  65062. getClassName(): string;
  65063. /**
  65064. * Gets a hash code for this quaternion
  65065. * @returns the quaternion hash code
  65066. */
  65067. getHashCode(): number;
  65068. /**
  65069. * Copy the quaternion to an array
  65070. * @returns a new array populated with 4 elements from the quaternion coordinates
  65071. */
  65072. asArray(): number[];
  65073. /**
  65074. * Check if two quaternions are equals
  65075. * @param otherQuaternion defines the second operand
  65076. * @return true if the current quaternion and the given one coordinates are strictly equals
  65077. */
  65078. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65079. /**
  65080. * Clone the current quaternion
  65081. * @returns a new quaternion copied from the current one
  65082. */
  65083. clone(): Quaternion;
  65084. /**
  65085. * Copy a quaternion to the current one
  65086. * @param other defines the other quaternion
  65087. * @returns the updated current quaternion
  65088. */
  65089. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65090. /**
  65091. * Updates the current quaternion with the given float coordinates
  65092. * @param x defines the x coordinate
  65093. * @param y defines the y coordinate
  65094. * @param z defines the z coordinate
  65095. * @param w defines the w coordinate
  65096. * @returns the updated current quaternion
  65097. */
  65098. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65099. /**
  65100. * Updates the current quaternion from the given float coordinates
  65101. * @param x defines the x coordinate
  65102. * @param y defines the y coordinate
  65103. * @param z defines the z coordinate
  65104. * @param w defines the w coordinate
  65105. * @returns the updated current quaternion
  65106. */
  65107. set(x: number, y: number, z: number, w: number): Quaternion;
  65108. /**
  65109. * Adds two quaternions
  65110. * @param other defines the second operand
  65111. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65112. */
  65113. add(other: DeepImmutable<Quaternion>): Quaternion;
  65114. /**
  65115. * Add a quaternion to the current one
  65116. * @param other defines the quaternion to add
  65117. * @returns the current quaternion
  65118. */
  65119. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65120. /**
  65121. * Subtract two quaternions
  65122. * @param other defines the second operand
  65123. * @returns a new quaternion as the subtraction result of the given one from the current one
  65124. */
  65125. subtract(other: Quaternion): Quaternion;
  65126. /**
  65127. * Multiplies the current quaternion by a scale factor
  65128. * @param value defines the scale factor
  65129. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65130. */
  65131. scale(value: number): Quaternion;
  65132. /**
  65133. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65134. * @param scale defines the scale factor
  65135. * @param result defines the Quaternion object where to store the result
  65136. * @returns the unmodified current quaternion
  65137. */
  65138. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65139. /**
  65140. * Multiplies in place the current quaternion by a scale factor
  65141. * @param value defines the scale factor
  65142. * @returns the current modified quaternion
  65143. */
  65144. scaleInPlace(value: number): Quaternion;
  65145. /**
  65146. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65147. * @param scale defines the scale factor
  65148. * @param result defines the Quaternion object where to store the result
  65149. * @returns the unmodified current quaternion
  65150. */
  65151. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65152. /**
  65153. * Multiplies two quaternions
  65154. * @param q1 defines the second operand
  65155. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65156. */
  65157. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65158. /**
  65159. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65160. * @param q1 defines the second operand
  65161. * @param result defines the target quaternion
  65162. * @returns the current quaternion
  65163. */
  65164. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65165. /**
  65166. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65167. * @param q1 defines the second operand
  65168. * @returns the currentupdated quaternion
  65169. */
  65170. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65171. /**
  65172. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65173. * @param ref defines the target quaternion
  65174. * @returns the current quaternion
  65175. */
  65176. conjugateToRef(ref: Quaternion): Quaternion;
  65177. /**
  65178. * Conjugates in place (1-q) the current quaternion
  65179. * @returns the current updated quaternion
  65180. */
  65181. conjugateInPlace(): Quaternion;
  65182. /**
  65183. * Conjugates in place (1-q) the current quaternion
  65184. * @returns a new quaternion
  65185. */
  65186. conjugate(): Quaternion;
  65187. /**
  65188. * Gets length of current quaternion
  65189. * @returns the quaternion length (float)
  65190. */
  65191. length(): number;
  65192. /**
  65193. * Normalize in place the current quaternion
  65194. * @returns the current updated quaternion
  65195. */
  65196. normalize(): Quaternion;
  65197. /**
  65198. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65199. * @param order is a reserved parameter and is ignore for now
  65200. * @returns a new Vector3 containing the Euler angles
  65201. */
  65202. toEulerAngles(order?: string): Vector3;
  65203. /**
  65204. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65205. * @param result defines the vector which will be filled with the Euler angles
  65206. * @param order is a reserved parameter and is ignore for now
  65207. * @returns the current unchanged quaternion
  65208. */
  65209. toEulerAnglesToRef(result: Vector3): Quaternion;
  65210. /**
  65211. * Updates the given rotation matrix with the current quaternion values
  65212. * @param result defines the target matrix
  65213. * @returns the current unchanged quaternion
  65214. */
  65215. toRotationMatrix(result: Matrix): Quaternion;
  65216. /**
  65217. * Updates the current quaternion from the given rotation matrix values
  65218. * @param matrix defines the source matrix
  65219. * @returns the current updated quaternion
  65220. */
  65221. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65222. /**
  65223. * Creates a new quaternion from a rotation matrix
  65224. * @param matrix defines the source matrix
  65225. * @returns a new quaternion created from the given rotation matrix values
  65226. */
  65227. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65228. /**
  65229. * Updates the given quaternion with the given rotation matrix values
  65230. * @param matrix defines the source matrix
  65231. * @param result defines the target quaternion
  65232. */
  65233. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65234. /**
  65235. * Returns the dot product (float) between the quaternions "left" and "right"
  65236. * @param left defines the left operand
  65237. * @param right defines the right operand
  65238. * @returns the dot product
  65239. */
  65240. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65241. /**
  65242. * Checks if the two quaternions are close to each other
  65243. * @param quat0 defines the first quaternion to check
  65244. * @param quat1 defines the second quaternion to check
  65245. * @returns true if the two quaternions are close to each other
  65246. */
  65247. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65248. /**
  65249. * Creates an empty quaternion
  65250. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65251. */
  65252. static Zero(): Quaternion;
  65253. /**
  65254. * Inverse a given quaternion
  65255. * @param q defines the source quaternion
  65256. * @returns a new quaternion as the inverted current quaternion
  65257. */
  65258. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65259. /**
  65260. * Inverse a given quaternion
  65261. * @param q defines the source quaternion
  65262. * @param result the quaternion the result will be stored in
  65263. * @returns the result quaternion
  65264. */
  65265. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65266. /**
  65267. * Creates an identity quaternion
  65268. * @returns the identity quaternion
  65269. */
  65270. static Identity(): Quaternion;
  65271. /**
  65272. * Gets a boolean indicating if the given quaternion is identity
  65273. * @param quaternion defines the quaternion to check
  65274. * @returns true if the quaternion is identity
  65275. */
  65276. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65277. /**
  65278. * Creates a quaternion from a rotation around an axis
  65279. * @param axis defines the axis to use
  65280. * @param angle defines the angle to use
  65281. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65282. */
  65283. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65284. /**
  65285. * Creates a rotation around an axis and stores it into the given quaternion
  65286. * @param axis defines the axis to use
  65287. * @param angle defines the angle to use
  65288. * @param result defines the target quaternion
  65289. * @returns the target quaternion
  65290. */
  65291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65292. /**
  65293. * Creates a new quaternion from data stored into an array
  65294. * @param array defines the data source
  65295. * @param offset defines the offset in the source array where the data starts
  65296. * @returns a new quaternion
  65297. */
  65298. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65299. /**
  65300. * Create a quaternion from Euler rotation angles
  65301. * @param x Pitch
  65302. * @param y Yaw
  65303. * @param z Roll
  65304. * @returns the new Quaternion
  65305. */
  65306. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65307. /**
  65308. * Updates a quaternion from Euler rotation angles
  65309. * @param x Pitch
  65310. * @param y Yaw
  65311. * @param z Roll
  65312. * @param result the quaternion to store the result
  65313. * @returns the updated quaternion
  65314. */
  65315. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65316. /**
  65317. * Create a quaternion from Euler rotation vector
  65318. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65319. * @returns the new Quaternion
  65320. */
  65321. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65322. /**
  65323. * Updates a quaternion from Euler rotation vector
  65324. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65325. * @param result the quaternion to store the result
  65326. * @returns the updated quaternion
  65327. */
  65328. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65329. /**
  65330. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65331. * @param yaw defines the rotation around Y axis
  65332. * @param pitch defines the rotation around X axis
  65333. * @param roll defines the rotation around Z axis
  65334. * @returns the new quaternion
  65335. */
  65336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65337. /**
  65338. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65339. * @param yaw defines the rotation around Y axis
  65340. * @param pitch defines the rotation around X axis
  65341. * @param roll defines the rotation around Z axis
  65342. * @param result defines the target quaternion
  65343. */
  65344. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65345. /**
  65346. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65347. * @param alpha defines the rotation around first axis
  65348. * @param beta defines the rotation around second axis
  65349. * @param gamma defines the rotation around third axis
  65350. * @returns the new quaternion
  65351. */
  65352. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65353. /**
  65354. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65355. * @param alpha defines the rotation around first axis
  65356. * @param beta defines the rotation around second axis
  65357. * @param gamma defines the rotation around third axis
  65358. * @param result defines the target quaternion
  65359. */
  65360. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65361. /**
  65362. * 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)
  65363. * @param axis1 defines the first axis
  65364. * @param axis2 defines the second axis
  65365. * @param axis3 defines the third axis
  65366. * @returns the new quaternion
  65367. */
  65368. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65369. /**
  65370. * 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
  65371. * @param axis1 defines the first axis
  65372. * @param axis2 defines the second axis
  65373. * @param axis3 defines the third axis
  65374. * @param ref defines the target quaternion
  65375. */
  65376. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65377. /**
  65378. * Interpolates between two quaternions
  65379. * @param left defines first quaternion
  65380. * @param right defines second quaternion
  65381. * @param amount defines the gradient to use
  65382. * @returns the new interpolated quaternion
  65383. */
  65384. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65385. /**
  65386. * Interpolates between two quaternions and stores it into a target quaternion
  65387. * @param left defines first quaternion
  65388. * @param right defines second quaternion
  65389. * @param amount defines the gradient to use
  65390. * @param result defines the target quaternion
  65391. */
  65392. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65393. /**
  65394. * Interpolate between two quaternions using Hermite interpolation
  65395. * @param value1 defines first quaternion
  65396. * @param tangent1 defines the incoming tangent
  65397. * @param value2 defines second quaternion
  65398. * @param tangent2 defines the outgoing tangent
  65399. * @param amount defines the target quaternion
  65400. * @returns the new interpolated quaternion
  65401. */
  65402. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65403. }
  65404. /**
  65405. * Class used to store matrix data (4x4)
  65406. */
  65407. export class Matrix {
  65408. private static _updateFlagSeed;
  65409. private static _identityReadOnly;
  65410. private _isIdentity;
  65411. private _isIdentityDirty;
  65412. private _isIdentity3x2;
  65413. private _isIdentity3x2Dirty;
  65414. /**
  65415. * Gets the update flag of the matrix which is an unique number for the matrix.
  65416. * It will be incremented every time the matrix data change.
  65417. * You can use it to speed the comparison between two versions of the same matrix.
  65418. */
  65419. updateFlag: number;
  65420. private readonly _m;
  65421. /**
  65422. * Gets the internal data of the matrix
  65423. */
  65424. readonly m: DeepImmutable<Float32Array>;
  65425. /** @hidden */
  65426. _markAsUpdated(): void;
  65427. /** @hidden */
  65428. private _updateIdentityStatus;
  65429. /**
  65430. * Creates an empty matrix (filled with zeros)
  65431. */
  65432. constructor();
  65433. /**
  65434. * Check if the current matrix is identity
  65435. * @returns true is the matrix is the identity matrix
  65436. */
  65437. isIdentity(): boolean;
  65438. /**
  65439. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65440. * @returns true is the matrix is the identity matrix
  65441. */
  65442. isIdentityAs3x2(): boolean;
  65443. /**
  65444. * Gets the determinant of the matrix
  65445. * @returns the matrix determinant
  65446. */
  65447. determinant(): number;
  65448. /**
  65449. * Returns the matrix as a Float32Array
  65450. * @returns the matrix underlying array
  65451. */
  65452. toArray(): DeepImmutable<Float32Array>;
  65453. /**
  65454. * Returns the matrix as a Float32Array
  65455. * @returns the matrix underlying array.
  65456. */
  65457. asArray(): DeepImmutable<Float32Array>;
  65458. /**
  65459. * Inverts the current matrix in place
  65460. * @returns the current inverted matrix
  65461. */
  65462. invert(): Matrix;
  65463. /**
  65464. * Sets all the matrix elements to zero
  65465. * @returns the current matrix
  65466. */
  65467. reset(): Matrix;
  65468. /**
  65469. * Adds the current matrix with a second one
  65470. * @param other defines the matrix to add
  65471. * @returns a new matrix as the addition of the current matrix and the given one
  65472. */
  65473. add(other: DeepImmutable<Matrix>): Matrix;
  65474. /**
  65475. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65476. * @param other defines the matrix to add
  65477. * @param result defines the target matrix
  65478. * @returns the current matrix
  65479. */
  65480. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65481. /**
  65482. * Adds in place the given matrix to the current matrix
  65483. * @param other defines the second operand
  65484. * @returns the current updated matrix
  65485. */
  65486. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65487. /**
  65488. * Sets the given matrix to the current inverted Matrix
  65489. * @param other defines the target matrix
  65490. * @returns the unmodified current matrix
  65491. */
  65492. invertToRef(other: Matrix): Matrix;
  65493. /**
  65494. * add a value at the specified position in the current Matrix
  65495. * @param index the index of the value within the matrix. between 0 and 15.
  65496. * @param value the value to be added
  65497. * @returns the current updated matrix
  65498. */
  65499. addAtIndex(index: number, value: number): Matrix;
  65500. /**
  65501. * mutiply the specified position in the current Matrix by a value
  65502. * @param index the index of the value within the matrix. between 0 and 15.
  65503. * @param value the value to be added
  65504. * @returns the current updated matrix
  65505. */
  65506. multiplyAtIndex(index: number, value: number): Matrix;
  65507. /**
  65508. * Inserts the translation vector (using 3 floats) in the current matrix
  65509. * @param x defines the 1st component of the translation
  65510. * @param y defines the 2nd component of the translation
  65511. * @param z defines the 3rd component of the translation
  65512. * @returns the current updated matrix
  65513. */
  65514. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65515. /**
  65516. * Adds the translation vector (using 3 floats) in the current matrix
  65517. * @param x defines the 1st component of the translation
  65518. * @param y defines the 2nd component of the translation
  65519. * @param z defines the 3rd component of the translation
  65520. * @returns the current updated matrix
  65521. */
  65522. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65523. /**
  65524. * Inserts the translation vector in the current matrix
  65525. * @param vector3 defines the translation to insert
  65526. * @returns the current updated matrix
  65527. */
  65528. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65529. /**
  65530. * Gets the translation value of the current matrix
  65531. * @returns a new Vector3 as the extracted translation from the matrix
  65532. */
  65533. getTranslation(): Vector3;
  65534. /**
  65535. * Fill a Vector3 with the extracted translation from the matrix
  65536. * @param result defines the Vector3 where to store the translation
  65537. * @returns the current matrix
  65538. */
  65539. getTranslationToRef(result: Vector3): Matrix;
  65540. /**
  65541. * Remove rotation and scaling part from the matrix
  65542. * @returns the updated matrix
  65543. */
  65544. removeRotationAndScaling(): Matrix;
  65545. /**
  65546. * Multiply two matrices
  65547. * @param other defines the second operand
  65548. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65549. */
  65550. multiply(other: DeepImmutable<Matrix>): Matrix;
  65551. /**
  65552. * Copy the current matrix from the given one
  65553. * @param other defines the source matrix
  65554. * @returns the current updated matrix
  65555. */
  65556. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65557. /**
  65558. * Populates the given array from the starting index with the current matrix values
  65559. * @param array defines the target array
  65560. * @param offset defines the offset in the target array where to start storing values
  65561. * @returns the current matrix
  65562. */
  65563. copyToArray(array: Float32Array, offset?: number): Matrix;
  65564. /**
  65565. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65566. * @param other defines the second operand
  65567. * @param result defines the matrix where to store the multiplication
  65568. * @returns the current matrix
  65569. */
  65570. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65571. /**
  65572. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65573. * @param other defines the second operand
  65574. * @param result defines the array where to store the multiplication
  65575. * @param offset defines the offset in the target array where to start storing values
  65576. * @returns the current matrix
  65577. */
  65578. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65579. /**
  65580. * Check equality between this matrix and a second one
  65581. * @param value defines the second matrix to compare
  65582. * @returns true is the current matrix and the given one values are strictly equal
  65583. */
  65584. equals(value: DeepImmutable<Matrix>): boolean;
  65585. /**
  65586. * Clone the current matrix
  65587. * @returns a new matrix from the current matrix
  65588. */
  65589. clone(): Matrix;
  65590. /**
  65591. * Returns the name of the current matrix class
  65592. * @returns the string "Matrix"
  65593. */
  65594. getClassName(): string;
  65595. /**
  65596. * Gets the hash code of the current matrix
  65597. * @returns the hash code
  65598. */
  65599. getHashCode(): number;
  65600. /**
  65601. * Decomposes the current Matrix into a translation, rotation and scaling components
  65602. * @param scale defines the scale vector3 given as a reference to update
  65603. * @param rotation defines the rotation quaternion given as a reference to update
  65604. * @param translation defines the translation vector3 given as a reference to update
  65605. * @returns true if operation was successful
  65606. */
  65607. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65608. /**
  65609. * Gets specific row of the matrix
  65610. * @param index defines the number of the row to get
  65611. * @returns the index-th row of the current matrix as a new Vector4
  65612. */
  65613. getRow(index: number): Nullable<Vector4>;
  65614. /**
  65615. * Sets the index-th row of the current matrix to the vector4 values
  65616. * @param index defines the number of the row to set
  65617. * @param row defines the target vector4
  65618. * @returns the updated current matrix
  65619. */
  65620. setRow(index: number, row: Vector4): Matrix;
  65621. /**
  65622. * Compute the transpose of the matrix
  65623. * @returns the new transposed matrix
  65624. */
  65625. transpose(): Matrix;
  65626. /**
  65627. * Compute the transpose of the matrix and store it in a given matrix
  65628. * @param result defines the target matrix
  65629. * @returns the current matrix
  65630. */
  65631. transposeToRef(result: Matrix): Matrix;
  65632. /**
  65633. * Sets the index-th row of the current matrix with the given 4 x float values
  65634. * @param index defines the row index
  65635. * @param x defines the x component to set
  65636. * @param y defines the y component to set
  65637. * @param z defines the z component to set
  65638. * @param w defines the w component to set
  65639. * @returns the updated current matrix
  65640. */
  65641. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65642. /**
  65643. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65644. * @param scale defines the scale factor
  65645. * @returns a new matrix
  65646. */
  65647. scale(scale: number): Matrix;
  65648. /**
  65649. * Scale the current matrix values by a factor to a given result matrix
  65650. * @param scale defines the scale factor
  65651. * @param result defines the matrix to store the result
  65652. * @returns the current matrix
  65653. */
  65654. scaleToRef(scale: number, result: Matrix): Matrix;
  65655. /**
  65656. * Scale the current matrix values by a factor and add the result to a given matrix
  65657. * @param scale defines the scale factor
  65658. * @param result defines the Matrix to store the result
  65659. * @returns the current matrix
  65660. */
  65661. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65662. /**
  65663. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65664. * @param ref matrix to store the result
  65665. */
  65666. toNormalMatrix(ref: Matrix): void;
  65667. /**
  65668. * Gets only rotation part of the current matrix
  65669. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65670. */
  65671. getRotationMatrix(): Matrix;
  65672. /**
  65673. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65674. * @param result defines the target matrix to store data to
  65675. * @returns the current matrix
  65676. */
  65677. getRotationMatrixToRef(result: Matrix): Matrix;
  65678. /**
  65679. * Toggles model matrix from being right handed to left handed in place and vice versa
  65680. */
  65681. toggleModelMatrixHandInPlace(): void;
  65682. /**
  65683. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65684. */
  65685. toggleProjectionMatrixHandInPlace(): void;
  65686. /**
  65687. * Creates a matrix from an array
  65688. * @param array defines the source array
  65689. * @param offset defines an offset in the source array
  65690. * @returns a new Matrix set from the starting index of the given array
  65691. */
  65692. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65693. /**
  65694. * Copy the content of an array into a given matrix
  65695. * @param array defines the source array
  65696. * @param offset defines an offset in the source array
  65697. * @param result defines the target matrix
  65698. */
  65699. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65700. /**
  65701. * Stores an array into a matrix after having multiplied each component by a given factor
  65702. * @param array defines the source array
  65703. * @param offset defines the offset in the source array
  65704. * @param scale defines the scaling factor
  65705. * @param result defines the target matrix
  65706. */
  65707. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65708. /**
  65709. * Gets an identity matrix that must not be updated
  65710. */
  65711. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65712. /**
  65713. * Stores a list of values (16) inside a given matrix
  65714. * @param initialM11 defines 1st value of 1st row
  65715. * @param initialM12 defines 2nd value of 1st row
  65716. * @param initialM13 defines 3rd value of 1st row
  65717. * @param initialM14 defines 4th value of 1st row
  65718. * @param initialM21 defines 1st value of 2nd row
  65719. * @param initialM22 defines 2nd value of 2nd row
  65720. * @param initialM23 defines 3rd value of 2nd row
  65721. * @param initialM24 defines 4th value of 2nd row
  65722. * @param initialM31 defines 1st value of 3rd row
  65723. * @param initialM32 defines 2nd value of 3rd row
  65724. * @param initialM33 defines 3rd value of 3rd row
  65725. * @param initialM34 defines 4th value of 3rd row
  65726. * @param initialM41 defines 1st value of 4th row
  65727. * @param initialM42 defines 2nd value of 4th row
  65728. * @param initialM43 defines 3rd value of 4th row
  65729. * @param initialM44 defines 4th value of 4th row
  65730. * @param result defines the target matrix
  65731. */
  65732. 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;
  65733. /**
  65734. * Creates new matrix from a list of values (16)
  65735. * @param initialM11 defines 1st value of 1st row
  65736. * @param initialM12 defines 2nd value of 1st row
  65737. * @param initialM13 defines 3rd value of 1st row
  65738. * @param initialM14 defines 4th value of 1st row
  65739. * @param initialM21 defines 1st value of 2nd row
  65740. * @param initialM22 defines 2nd value of 2nd row
  65741. * @param initialM23 defines 3rd value of 2nd row
  65742. * @param initialM24 defines 4th value of 2nd row
  65743. * @param initialM31 defines 1st value of 3rd row
  65744. * @param initialM32 defines 2nd value of 3rd row
  65745. * @param initialM33 defines 3rd value of 3rd row
  65746. * @param initialM34 defines 4th value of 3rd row
  65747. * @param initialM41 defines 1st value of 4th row
  65748. * @param initialM42 defines 2nd value of 4th row
  65749. * @param initialM43 defines 3rd value of 4th row
  65750. * @param initialM44 defines 4th value of 4th row
  65751. * @returns the new matrix
  65752. */
  65753. 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;
  65754. /**
  65755. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65756. * @param scale defines the scale vector3
  65757. * @param rotation defines the rotation quaternion
  65758. * @param translation defines the translation vector3
  65759. * @returns a new matrix
  65760. */
  65761. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65762. /**
  65763. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65764. * @param scale defines the scale vector3
  65765. * @param rotation defines the rotation quaternion
  65766. * @param translation defines the translation vector3
  65767. * @param result defines the target matrix
  65768. */
  65769. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65770. /**
  65771. * Creates a new identity matrix
  65772. * @returns a new identity matrix
  65773. */
  65774. static Identity(): Matrix;
  65775. /**
  65776. * Creates a new identity matrix and stores the result in a given matrix
  65777. * @param result defines the target matrix
  65778. */
  65779. static IdentityToRef(result: Matrix): void;
  65780. /**
  65781. * Creates a new zero matrix
  65782. * @returns a new zero matrix
  65783. */
  65784. static Zero(): Matrix;
  65785. /**
  65786. * Creates a new rotation matrix for "angle" radians around the X axis
  65787. * @param angle defines the angle (in radians) to use
  65788. * @return the new matrix
  65789. */
  65790. static RotationX(angle: number): Matrix;
  65791. /**
  65792. * Creates a new matrix as the invert of a given matrix
  65793. * @param source defines the source matrix
  65794. * @returns the new matrix
  65795. */
  65796. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65797. /**
  65798. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65799. * @param angle defines the angle (in radians) to use
  65800. * @param result defines the target matrix
  65801. */
  65802. static RotationXToRef(angle: number, result: Matrix): void;
  65803. /**
  65804. * Creates a new rotation matrix for "angle" radians around the Y axis
  65805. * @param angle defines the angle (in radians) to use
  65806. * @return the new matrix
  65807. */
  65808. static RotationY(angle: number): Matrix;
  65809. /**
  65810. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65811. * @param angle defines the angle (in radians) to use
  65812. * @param result defines the target matrix
  65813. */
  65814. static RotationYToRef(angle: number, result: Matrix): void;
  65815. /**
  65816. * Creates a new rotation matrix for "angle" radians around the Z axis
  65817. * @param angle defines the angle (in radians) to use
  65818. * @return the new matrix
  65819. */
  65820. static RotationZ(angle: number): Matrix;
  65821. /**
  65822. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65823. * @param angle defines the angle (in radians) to use
  65824. * @param result defines the target matrix
  65825. */
  65826. static RotationZToRef(angle: number, result: Matrix): void;
  65827. /**
  65828. * Creates a new rotation matrix for "angle" radians around the given axis
  65829. * @param axis defines the axis to use
  65830. * @param angle defines the angle (in radians) to use
  65831. * @return the new matrix
  65832. */
  65833. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65834. /**
  65835. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65836. * @param axis defines the axis to use
  65837. * @param angle defines the angle (in radians) to use
  65838. * @param result defines the target matrix
  65839. */
  65840. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65841. /**
  65842. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65843. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65844. * @param from defines the vector to align
  65845. * @param to defines the vector to align to
  65846. * @param result defines the target matrix
  65847. */
  65848. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65849. /**
  65850. * Creates a rotation matrix
  65851. * @param yaw defines the yaw angle in radians (Y axis)
  65852. * @param pitch defines the pitch angle in radians (X axis)
  65853. * @param roll defines the roll angle in radians (X axis)
  65854. * @returns the new rotation matrix
  65855. */
  65856. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65857. /**
  65858. * Creates a rotation matrix and stores it in a given matrix
  65859. * @param yaw defines the yaw angle in radians (Y axis)
  65860. * @param pitch defines the pitch angle in radians (X axis)
  65861. * @param roll defines the roll angle in radians (X axis)
  65862. * @param result defines the target matrix
  65863. */
  65864. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65865. /**
  65866. * Creates a scaling matrix
  65867. * @param x defines the scale factor on X axis
  65868. * @param y defines the scale factor on Y axis
  65869. * @param z defines the scale factor on Z axis
  65870. * @returns the new matrix
  65871. */
  65872. static Scaling(x: number, y: number, z: number): Matrix;
  65873. /**
  65874. * Creates a scaling matrix and stores it in a given matrix
  65875. * @param x defines the scale factor on X axis
  65876. * @param y defines the scale factor on Y axis
  65877. * @param z defines the scale factor on Z axis
  65878. * @param result defines the target matrix
  65879. */
  65880. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65881. /**
  65882. * Creates a translation matrix
  65883. * @param x defines the translation on X axis
  65884. * @param y defines the translation on Y axis
  65885. * @param z defines the translationon Z axis
  65886. * @returns the new matrix
  65887. */
  65888. static Translation(x: number, y: number, z: number): Matrix;
  65889. /**
  65890. * Creates a translation matrix and stores it in a given matrix
  65891. * @param x defines the translation on X axis
  65892. * @param y defines the translation on Y axis
  65893. * @param z defines the translationon Z axis
  65894. * @param result defines the target matrix
  65895. */
  65896. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65897. /**
  65898. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65899. * @param startValue defines the start value
  65900. * @param endValue defines the end value
  65901. * @param gradient defines the gradient factor
  65902. * @returns the new matrix
  65903. */
  65904. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65905. /**
  65906. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65907. * @param startValue defines the start value
  65908. * @param endValue defines the end value
  65909. * @param gradient defines the gradient factor
  65910. * @param result defines the Matrix object where to store data
  65911. */
  65912. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65913. /**
  65914. * Builds a new matrix whose values are computed by:
  65915. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65916. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65917. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65918. * @param startValue defines the first matrix
  65919. * @param endValue defines the second matrix
  65920. * @param gradient defines the gradient between the two matrices
  65921. * @returns the new matrix
  65922. */
  65923. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65924. /**
  65925. * Update a matrix to values which are computed by:
  65926. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65927. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65928. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65929. * @param startValue defines the first matrix
  65930. * @param endValue defines the second matrix
  65931. * @param gradient defines the gradient between the two matrices
  65932. * @param result defines the target matrix
  65933. */
  65934. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65935. /**
  65936. * 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"
  65937. * This function works in left handed mode
  65938. * @param eye defines the final position of the entity
  65939. * @param target defines where the entity should look at
  65940. * @param up defines the up vector for the entity
  65941. * @returns the new matrix
  65942. */
  65943. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65944. /**
  65945. * 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".
  65946. * This function works in left handed mode
  65947. * @param eye defines the final position of the entity
  65948. * @param target defines where the entity should look at
  65949. * @param up defines the up vector for the entity
  65950. * @param result defines the target matrix
  65951. */
  65952. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65953. /**
  65954. * 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"
  65955. * This function works in right handed mode
  65956. * @param eye defines the final position of the entity
  65957. * @param target defines where the entity should look at
  65958. * @param up defines the up vector for the entity
  65959. * @returns the new matrix
  65960. */
  65961. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65962. /**
  65963. * 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".
  65964. * This function works in right handed mode
  65965. * @param eye defines the final position of the entity
  65966. * @param target defines where the entity should look at
  65967. * @param up defines the up vector for the entity
  65968. * @param result defines the target matrix
  65969. */
  65970. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65971. /**
  65972. * Create a left-handed orthographic projection matrix
  65973. * @param width defines the viewport width
  65974. * @param height defines the viewport height
  65975. * @param znear defines the near clip plane
  65976. * @param zfar defines the far clip plane
  65977. * @returns a new matrix as a left-handed orthographic projection matrix
  65978. */
  65979. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65980. /**
  65981. * Store a left-handed orthographic projection to a given matrix
  65982. * @param width defines the viewport width
  65983. * @param height defines the viewport height
  65984. * @param znear defines the near clip plane
  65985. * @param zfar defines the far clip plane
  65986. * @param result defines the target matrix
  65987. */
  65988. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  65989. /**
  65990. * Create a left-handed orthographic projection matrix
  65991. * @param left defines the viewport left coordinate
  65992. * @param right defines the viewport right coordinate
  65993. * @param bottom defines the viewport bottom coordinate
  65994. * @param top defines the viewport top coordinate
  65995. * @param znear defines the near clip plane
  65996. * @param zfar defines the far clip plane
  65997. * @returns a new matrix as a left-handed orthographic projection matrix
  65998. */
  65999. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66000. /**
  66001. * Stores a left-handed orthographic projection into a given matrix
  66002. * @param left defines the viewport left coordinate
  66003. * @param right defines the viewport right coordinate
  66004. * @param bottom defines the viewport bottom coordinate
  66005. * @param top defines the viewport top coordinate
  66006. * @param znear defines the near clip plane
  66007. * @param zfar defines the far clip plane
  66008. * @param result defines the target matrix
  66009. */
  66010. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66011. /**
  66012. * Creates a right-handed orthographic projection matrix
  66013. * @param left defines the viewport left coordinate
  66014. * @param right defines the viewport right coordinate
  66015. * @param bottom defines the viewport bottom coordinate
  66016. * @param top defines the viewport top coordinate
  66017. * @param znear defines the near clip plane
  66018. * @param zfar defines the far clip plane
  66019. * @returns a new matrix as a right-handed orthographic projection matrix
  66020. */
  66021. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66022. /**
  66023. * Stores a right-handed orthographic projection into a given matrix
  66024. * @param left defines the viewport left coordinate
  66025. * @param right defines the viewport right coordinate
  66026. * @param bottom defines the viewport bottom coordinate
  66027. * @param top defines the viewport top coordinate
  66028. * @param znear defines the near clip plane
  66029. * @param zfar defines the far clip plane
  66030. * @param result defines the target matrix
  66031. */
  66032. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66033. /**
  66034. * Creates a left-handed perspective projection matrix
  66035. * @param width defines the viewport width
  66036. * @param height defines the viewport height
  66037. * @param znear defines the near clip plane
  66038. * @param zfar defines the far clip plane
  66039. * @returns a new matrix as a left-handed perspective projection matrix
  66040. */
  66041. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66042. /**
  66043. * Creates a left-handed perspective projection matrix
  66044. * @param fov defines the horizontal field of view
  66045. * @param aspect defines the aspect ratio
  66046. * @param znear defines the near clip plane
  66047. * @param zfar defines the far clip plane
  66048. * @returns a new matrix as a left-handed perspective projection matrix
  66049. */
  66050. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66051. /**
  66052. * Stores a left-handed perspective projection into a given matrix
  66053. * @param fov defines the horizontal field of view
  66054. * @param aspect defines the aspect ratio
  66055. * @param znear defines the near clip plane
  66056. * @param zfar defines the far clip plane
  66057. * @param result defines the target matrix
  66058. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66059. */
  66060. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66061. /**
  66062. * Creates a right-handed perspective projection matrix
  66063. * @param fov defines the horizontal field of view
  66064. * @param aspect defines the aspect ratio
  66065. * @param znear defines the near clip plane
  66066. * @param zfar defines the far clip plane
  66067. * @returns a new matrix as a right-handed perspective projection matrix
  66068. */
  66069. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66070. /**
  66071. * Stores a right-handed perspective projection into a given matrix
  66072. * @param fov defines the horizontal field of view
  66073. * @param aspect defines the aspect ratio
  66074. * @param znear defines the near clip plane
  66075. * @param zfar defines the far clip plane
  66076. * @param result defines the target matrix
  66077. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66078. */
  66079. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66080. /**
  66081. * Stores a perspective projection for WebVR info a given matrix
  66082. * @param fov defines the field of view
  66083. * @param znear defines the near clip plane
  66084. * @param zfar defines the far clip plane
  66085. * @param result defines the target matrix
  66086. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66087. */
  66088. static PerspectiveFovWebVRToRef(fov: {
  66089. upDegrees: number;
  66090. downDegrees: number;
  66091. leftDegrees: number;
  66092. rightDegrees: number;
  66093. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66094. /**
  66095. * Computes a complete transformation matrix
  66096. * @param viewport defines the viewport to use
  66097. * @param world defines the world matrix
  66098. * @param view defines the view matrix
  66099. * @param projection defines the projection matrix
  66100. * @param zmin defines the near clip plane
  66101. * @param zmax defines the far clip plane
  66102. * @returns the transformation matrix
  66103. */
  66104. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66105. /**
  66106. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66107. * @param matrix defines the matrix to use
  66108. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66109. */
  66110. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66111. /**
  66112. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66113. * @param matrix defines the matrix to use
  66114. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66115. */
  66116. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66117. /**
  66118. * Compute the transpose of a given matrix
  66119. * @param matrix defines the matrix to transpose
  66120. * @returns the new matrix
  66121. */
  66122. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66123. /**
  66124. * Compute the transpose of a matrix and store it in a target matrix
  66125. * @param matrix defines the matrix to transpose
  66126. * @param result defines the target matrix
  66127. */
  66128. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66129. /**
  66130. * Computes a reflection matrix from a plane
  66131. * @param plane defines the reflection plane
  66132. * @returns a new matrix
  66133. */
  66134. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66135. /**
  66136. * Computes a reflection matrix from a plane
  66137. * @param plane defines the reflection plane
  66138. * @param result defines the target matrix
  66139. */
  66140. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66141. /**
  66142. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66143. * @param xaxis defines the value of the 1st axis
  66144. * @param yaxis defines the value of the 2nd axis
  66145. * @param zaxis defines the value of the 3rd axis
  66146. * @param result defines the target matrix
  66147. */
  66148. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66149. /**
  66150. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66151. * @param quat defines the quaternion to use
  66152. * @param result defines the target matrix
  66153. */
  66154. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66155. }
  66156. /**
  66157. * Represens a plane by the equation ax + by + cz + d = 0
  66158. */
  66159. export class Plane {
  66160. /**
  66161. * Normal of the plane (a,b,c)
  66162. */
  66163. normal: Vector3;
  66164. /**
  66165. * d component of the plane
  66166. */
  66167. d: number;
  66168. /**
  66169. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66170. * @param a a component of the plane
  66171. * @param b b component of the plane
  66172. * @param c c component of the plane
  66173. * @param d d component of the plane
  66174. */
  66175. constructor(a: number, b: number, c: number, d: number);
  66176. /**
  66177. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66178. */
  66179. asArray(): number[];
  66180. /**
  66181. * @returns a new plane copied from the current Plane.
  66182. */
  66183. clone(): Plane;
  66184. /**
  66185. * @returns the string "Plane".
  66186. */
  66187. getClassName(): string;
  66188. /**
  66189. * @returns the Plane hash code.
  66190. */
  66191. getHashCode(): number;
  66192. /**
  66193. * Normalize the current Plane in place.
  66194. * @returns the updated Plane.
  66195. */
  66196. normalize(): Plane;
  66197. /**
  66198. * Applies a transformation the plane and returns the result
  66199. * @param transformation the transformation matrix to be applied to the plane
  66200. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66201. */
  66202. transform(transformation: DeepImmutable<Matrix>): Plane;
  66203. /**
  66204. * Calcualtte the dot product between the point and the plane normal
  66205. * @param point point to calculate the dot product with
  66206. * @returns the dot product (float) of the point coordinates and the plane normal.
  66207. */
  66208. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66209. /**
  66210. * Updates the current Plane from the plane defined by the three given points.
  66211. * @param point1 one of the points used to contruct the plane
  66212. * @param point2 one of the points used to contruct the plane
  66213. * @param point3 one of the points used to contruct the plane
  66214. * @returns the updated Plane.
  66215. */
  66216. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66217. /**
  66218. * Checks if the plane is facing a given direction
  66219. * @param direction the direction to check if the plane is facing
  66220. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66221. * @returns True is the vector "direction" is the same side than the plane normal.
  66222. */
  66223. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66224. /**
  66225. * Calculates the distance to a point
  66226. * @param point point to calculate distance to
  66227. * @returns the signed distance (float) from the given point to the Plane.
  66228. */
  66229. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66230. /**
  66231. * Creates a plane from an array
  66232. * @param array the array to create a plane from
  66233. * @returns a new Plane from the given array.
  66234. */
  66235. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66236. /**
  66237. * Creates a plane from three points
  66238. * @param point1 point used to create the plane
  66239. * @param point2 point used to create the plane
  66240. * @param point3 point used to create the plane
  66241. * @returns a new Plane defined by the three given points.
  66242. */
  66243. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66244. /**
  66245. * Creates a plane from an origin point and a normal
  66246. * @param origin origin of the plane to be constructed
  66247. * @param normal normal of the plane to be constructed
  66248. * @returns a new Plane the normal vector to this plane at the given origin point.
  66249. * Note : the vector "normal" is updated because normalized.
  66250. */
  66251. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66252. /**
  66253. * Calculates the distance from a plane and a point
  66254. * @param origin origin of the plane to be constructed
  66255. * @param normal normal of the plane to be constructed
  66256. * @param point point to calculate distance to
  66257. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66258. */
  66259. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66260. }
  66261. /**
  66262. * Class used to represent a viewport on screen
  66263. */
  66264. export class Viewport {
  66265. /** viewport left coordinate */
  66266. x: number;
  66267. /** viewport top coordinate */
  66268. y: number;
  66269. /**viewport width */
  66270. width: number;
  66271. /** viewport height */
  66272. height: number;
  66273. /**
  66274. * Creates a Viewport object located at (x, y) and sized (width, height)
  66275. * @param x defines viewport left coordinate
  66276. * @param y defines viewport top coordinate
  66277. * @param width defines the viewport width
  66278. * @param height defines the viewport height
  66279. */
  66280. constructor(
  66281. /** viewport left coordinate */
  66282. x: number,
  66283. /** viewport top coordinate */
  66284. y: number,
  66285. /**viewport width */
  66286. width: number,
  66287. /** viewport height */
  66288. height: number);
  66289. /**
  66290. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66291. * @param renderWidth defines the rendering width
  66292. * @param renderHeight defines the rendering height
  66293. * @returns a new Viewport
  66294. */
  66295. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66296. /**
  66297. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66298. * @param renderWidth defines the rendering width
  66299. * @param renderHeight defines the rendering height
  66300. * @param ref defines the target viewport
  66301. * @returns the current viewport
  66302. */
  66303. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66304. /**
  66305. * Returns a new Viewport copied from the current one
  66306. * @returns a new Viewport
  66307. */
  66308. clone(): Viewport;
  66309. }
  66310. /**
  66311. * Reprasents a camera frustum
  66312. */
  66313. export class Frustum {
  66314. /**
  66315. * Gets the planes representing the frustum
  66316. * @param transform matrix to be applied to the returned planes
  66317. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66318. */
  66319. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66320. /**
  66321. * Gets the near frustum plane transformed by the transform matrix
  66322. * @param transform transformation matrix to be applied to the resulting frustum plane
  66323. * @param frustumPlane the resuling frustum plane
  66324. */
  66325. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66326. /**
  66327. * Gets the far frustum plane transformed by the transform matrix
  66328. * @param transform transformation matrix to be applied to the resulting frustum plane
  66329. * @param frustumPlane the resuling frustum plane
  66330. */
  66331. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66332. /**
  66333. * Gets the left frustum plane transformed by the transform matrix
  66334. * @param transform transformation matrix to be applied to the resulting frustum plane
  66335. * @param frustumPlane the resuling frustum plane
  66336. */
  66337. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66338. /**
  66339. * Gets the right frustum plane transformed by the transform matrix
  66340. * @param transform transformation matrix to be applied to the resulting frustum plane
  66341. * @param frustumPlane the resuling frustum plane
  66342. */
  66343. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66344. /**
  66345. * Gets the top frustum plane transformed by the transform matrix
  66346. * @param transform transformation matrix to be applied to the resulting frustum plane
  66347. * @param frustumPlane the resuling frustum plane
  66348. */
  66349. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66350. /**
  66351. * Gets the bottom frustum plane transformed by the transform matrix
  66352. * @param transform transformation matrix to be applied to the resulting frustum plane
  66353. * @param frustumPlane the resuling frustum plane
  66354. */
  66355. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66356. /**
  66357. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66358. * @param transform transformation matrix to be applied to the resulting frustum planes
  66359. * @param frustumPlanes the resuling frustum planes
  66360. */
  66361. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66362. }
  66363. /** Defines supported spaces */
  66364. export enum Space {
  66365. /** Local (object) space */
  66366. LOCAL = 0,
  66367. /** World space */
  66368. WORLD = 1,
  66369. /** Bone space */
  66370. BONE = 2
  66371. }
  66372. /** Defines the 3 main axes */
  66373. export class Axis {
  66374. /** X axis */
  66375. static X: Vector3;
  66376. /** Y axis */
  66377. static Y: Vector3;
  66378. /** Z axis */
  66379. static Z: Vector3;
  66380. }
  66381. /** Class used to represent a Bezier curve */
  66382. export class BezierCurve {
  66383. /**
  66384. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66385. * @param t defines the time
  66386. * @param x1 defines the left coordinate on X axis
  66387. * @param y1 defines the left coordinate on Y axis
  66388. * @param x2 defines the right coordinate on X axis
  66389. * @param y2 defines the right coordinate on Y axis
  66390. * @returns the interpolated value
  66391. */
  66392. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66393. }
  66394. /**
  66395. * Defines potential orientation for back face culling
  66396. */
  66397. export enum Orientation {
  66398. /**
  66399. * Clockwise
  66400. */
  66401. CW = 0,
  66402. /** Counter clockwise */
  66403. CCW = 1
  66404. }
  66405. /**
  66406. * Defines angle representation
  66407. */
  66408. export class Angle {
  66409. private _radians;
  66410. /**
  66411. * Creates an Angle object of "radians" radians (float).
  66412. * @param radians the angle in radians
  66413. */
  66414. constructor(radians: number);
  66415. /**
  66416. * Get value in degrees
  66417. * @returns the Angle value in degrees (float)
  66418. */
  66419. degrees(): number;
  66420. /**
  66421. * Get value in radians
  66422. * @returns the Angle value in radians (float)
  66423. */
  66424. radians(): number;
  66425. /**
  66426. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66427. * @param a defines first vector
  66428. * @param b defines second vector
  66429. * @returns a new Angle
  66430. */
  66431. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66432. /**
  66433. * Gets a new Angle object from the given float in radians
  66434. * @param radians defines the angle value in radians
  66435. * @returns a new Angle
  66436. */
  66437. static FromRadians(radians: number): Angle;
  66438. /**
  66439. * Gets a new Angle object from the given float in degrees
  66440. * @param degrees defines the angle value in degrees
  66441. * @returns a new Angle
  66442. */
  66443. static FromDegrees(degrees: number): Angle;
  66444. }
  66445. /**
  66446. * This represents an arc in a 2d space.
  66447. */
  66448. export class Arc2 {
  66449. /** Defines the start point of the arc */
  66450. startPoint: Vector2;
  66451. /** Defines the mid point of the arc */
  66452. midPoint: Vector2;
  66453. /** Defines the end point of the arc */
  66454. endPoint: Vector2;
  66455. /**
  66456. * Defines the center point of the arc.
  66457. */
  66458. centerPoint: Vector2;
  66459. /**
  66460. * Defines the radius of the arc.
  66461. */
  66462. radius: number;
  66463. /**
  66464. * Defines the angle of the arc (from mid point to end point).
  66465. */
  66466. angle: Angle;
  66467. /**
  66468. * Defines the start angle of the arc (from start point to middle point).
  66469. */
  66470. startAngle: Angle;
  66471. /**
  66472. * Defines the orientation of the arc (clock wise/counter clock wise).
  66473. */
  66474. orientation: Orientation;
  66475. /**
  66476. * Creates an Arc object from the three given points : start, middle and end.
  66477. * @param startPoint Defines the start point of the arc
  66478. * @param midPoint Defines the midlle point of the arc
  66479. * @param endPoint Defines the end point of the arc
  66480. */
  66481. constructor(
  66482. /** Defines the start point of the arc */
  66483. startPoint: Vector2,
  66484. /** Defines the mid point of the arc */
  66485. midPoint: Vector2,
  66486. /** Defines the end point of the arc */
  66487. endPoint: Vector2);
  66488. }
  66489. /**
  66490. * Represents a 2D path made up of multiple 2D points
  66491. */
  66492. export class Path2 {
  66493. private _points;
  66494. private _length;
  66495. /**
  66496. * If the path start and end point are the same
  66497. */
  66498. closed: boolean;
  66499. /**
  66500. * Creates a Path2 object from the starting 2D coordinates x and y.
  66501. * @param x the starting points x value
  66502. * @param y the starting points y value
  66503. */
  66504. constructor(x: number, y: number);
  66505. /**
  66506. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66507. * @param x the added points x value
  66508. * @param y the added points y value
  66509. * @returns the updated Path2.
  66510. */
  66511. addLineTo(x: number, y: number): Path2;
  66512. /**
  66513. * 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.
  66514. * @param midX middle point x value
  66515. * @param midY middle point y value
  66516. * @param endX end point x value
  66517. * @param endY end point y value
  66518. * @param numberOfSegments (default: 36)
  66519. * @returns the updated Path2.
  66520. */
  66521. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66522. /**
  66523. * Closes the Path2.
  66524. * @returns the Path2.
  66525. */
  66526. close(): Path2;
  66527. /**
  66528. * Gets the sum of the distance between each sequential point in the path
  66529. * @returns the Path2 total length (float).
  66530. */
  66531. length(): number;
  66532. /**
  66533. * Gets the points which construct the path
  66534. * @returns the Path2 internal array of points.
  66535. */
  66536. getPoints(): Vector2[];
  66537. /**
  66538. * Retreives the point at the distance aways from the starting point
  66539. * @param normalizedLengthPosition the length along the path to retreive the point from
  66540. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66541. */
  66542. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66543. /**
  66544. * Creates a new path starting from an x and y position
  66545. * @param x starting x value
  66546. * @param y starting y value
  66547. * @returns a new Path2 starting at the coordinates (x, y).
  66548. */
  66549. static StartingAt(x: number, y: number): Path2;
  66550. }
  66551. /**
  66552. * Represents a 3D path made up of multiple 3D points
  66553. */
  66554. export class Path3D {
  66555. /**
  66556. * an array of Vector3, the curve axis of the Path3D
  66557. */
  66558. path: Vector3[];
  66559. private _curve;
  66560. private _distances;
  66561. private _tangents;
  66562. private _normals;
  66563. private _binormals;
  66564. private _raw;
  66565. /**
  66566. * new Path3D(path, normal, raw)
  66567. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66568. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66569. * @param path an array of Vector3, the curve axis of the Path3D
  66570. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66571. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66572. */
  66573. constructor(
  66574. /**
  66575. * an array of Vector3, the curve axis of the Path3D
  66576. */
  66577. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66578. /**
  66579. * Returns the Path3D array of successive Vector3 designing its curve.
  66580. * @returns the Path3D array of successive Vector3 designing its curve.
  66581. */
  66582. getCurve(): Vector3[];
  66583. /**
  66584. * Returns an array populated with tangent vectors on each Path3D curve point.
  66585. * @returns an array populated with tangent vectors on each Path3D curve point.
  66586. */
  66587. getTangents(): Vector3[];
  66588. /**
  66589. * Returns an array populated with normal vectors on each Path3D curve point.
  66590. * @returns an array populated with normal vectors on each Path3D curve point.
  66591. */
  66592. getNormals(): Vector3[];
  66593. /**
  66594. * Returns an array populated with binormal vectors on each Path3D curve point.
  66595. * @returns an array populated with binormal vectors on each Path3D curve point.
  66596. */
  66597. getBinormals(): Vector3[];
  66598. /**
  66599. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66600. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66601. */
  66602. getDistances(): number[];
  66603. /**
  66604. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66605. * @param path path which all values are copied into the curves points
  66606. * @param firstNormal which should be projected onto the curve
  66607. * @returns the same object updated.
  66608. */
  66609. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66610. private _compute;
  66611. private _getFirstNonNullVector;
  66612. private _getLastNonNullVector;
  66613. private _normalVector;
  66614. }
  66615. /**
  66616. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66617. * A Curve3 is designed from a series of successive Vector3.
  66618. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66619. */
  66620. export class Curve3 {
  66621. private _points;
  66622. private _length;
  66623. /**
  66624. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66625. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66626. * @param v1 (Vector3) the control point
  66627. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66628. * @param nbPoints (integer) the wanted number of points in the curve
  66629. * @returns the created Curve3
  66630. */
  66631. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66632. /**
  66633. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66634. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66635. * @param v1 (Vector3) the first control point
  66636. * @param v2 (Vector3) the second control point
  66637. * @param v3 (Vector3) the end point of the Cubic Bezier
  66638. * @param nbPoints (integer) the wanted number of points in the curve
  66639. * @returns the created Curve3
  66640. */
  66641. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66642. /**
  66643. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66644. * @param p1 (Vector3) the origin point of the Hermite Spline
  66645. * @param t1 (Vector3) the tangent vector at the origin point
  66646. * @param p2 (Vector3) the end point of the Hermite Spline
  66647. * @param t2 (Vector3) the tangent vector at the end point
  66648. * @param nbPoints (integer) the wanted number of points in the curve
  66649. * @returns the created Curve3
  66650. */
  66651. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66652. /**
  66653. * Returns a Curve3 object along a CatmullRom Spline curve :
  66654. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66655. * @param nbPoints (integer) the wanted number of points between each curve control points
  66656. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66657. * @returns the created Curve3
  66658. */
  66659. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66660. /**
  66661. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66662. * A Curve3 is designed from a series of successive Vector3.
  66663. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66664. * @param points points which make up the curve
  66665. */
  66666. constructor(points: Vector3[]);
  66667. /**
  66668. * @returns the Curve3 stored array of successive Vector3
  66669. */
  66670. getPoints(): Vector3[];
  66671. /**
  66672. * @returns the computed length (float) of the curve.
  66673. */
  66674. length(): number;
  66675. /**
  66676. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66677. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66678. * curveA and curveB keep unchanged.
  66679. * @param curve the curve to continue from this curve
  66680. * @returns the newly constructed curve
  66681. */
  66682. continue(curve: DeepImmutable<Curve3>): Curve3;
  66683. private _computeLength;
  66684. }
  66685. /**
  66686. * Contains position and normal vectors for a vertex
  66687. */
  66688. export class PositionNormalVertex {
  66689. /** the position of the vertex (defaut: 0,0,0) */
  66690. position: Vector3;
  66691. /** the normal of the vertex (defaut: 0,1,0) */
  66692. normal: Vector3;
  66693. /**
  66694. * Creates a PositionNormalVertex
  66695. * @param position the position of the vertex (defaut: 0,0,0)
  66696. * @param normal the normal of the vertex (defaut: 0,1,0)
  66697. */
  66698. constructor(
  66699. /** the position of the vertex (defaut: 0,0,0) */
  66700. position?: Vector3,
  66701. /** the normal of the vertex (defaut: 0,1,0) */
  66702. normal?: Vector3);
  66703. /**
  66704. * Clones the PositionNormalVertex
  66705. * @returns the cloned PositionNormalVertex
  66706. */
  66707. clone(): PositionNormalVertex;
  66708. }
  66709. /**
  66710. * Contains position, normal and uv vectors for a vertex
  66711. */
  66712. export class PositionNormalTextureVertex {
  66713. /** the position of the vertex (defaut: 0,0,0) */
  66714. position: Vector3;
  66715. /** the normal of the vertex (defaut: 0,1,0) */
  66716. normal: Vector3;
  66717. /** the uv of the vertex (default: 0,0) */
  66718. uv: Vector2;
  66719. /**
  66720. * Creates a PositionNormalTextureVertex
  66721. * @param position the position of the vertex (defaut: 0,0,0)
  66722. * @param normal the normal of the vertex (defaut: 0,1,0)
  66723. * @param uv the uv of the vertex (default: 0,0)
  66724. */
  66725. constructor(
  66726. /** the position of the vertex (defaut: 0,0,0) */
  66727. position?: Vector3,
  66728. /** the normal of the vertex (defaut: 0,1,0) */
  66729. normal?: Vector3,
  66730. /** the uv of the vertex (default: 0,0) */
  66731. uv?: Vector2);
  66732. /**
  66733. * Clones the PositionNormalTextureVertex
  66734. * @returns the cloned PositionNormalTextureVertex
  66735. */
  66736. clone(): PositionNormalTextureVertex;
  66737. }
  66738. /**
  66739. * @hidden
  66740. */
  66741. export class Tmp {
  66742. static Color3: Color3[];
  66743. static Color4: Color4[];
  66744. static Vector2: Vector2[];
  66745. static Vector3: Vector3[];
  66746. static Vector4: Vector4[];
  66747. static Quaternion: Quaternion[];
  66748. static Matrix: Matrix[];
  66749. }
  66750. }
  66751. declare module BABYLON {
  66752. /**
  66753. * Class used to enable access to offline support
  66754. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66755. */
  66756. export interface IOfflineProvider {
  66757. /**
  66758. * Gets a boolean indicating if scene must be saved in the database
  66759. */
  66760. enableSceneOffline: boolean;
  66761. /**
  66762. * Gets a boolean indicating if textures must be saved in the database
  66763. */
  66764. enableTexturesOffline: boolean;
  66765. /**
  66766. * Open the offline support and make it available
  66767. * @param successCallback defines the callback to call on success
  66768. * @param errorCallback defines the callback to call on error
  66769. */
  66770. open(successCallback: () => void, errorCallback: () => void): void;
  66771. /**
  66772. * Loads an image from the offline support
  66773. * @param url defines the url to load from
  66774. * @param image defines the target DOM image
  66775. */
  66776. loadImage(url: string, image: HTMLImageElement): void;
  66777. /**
  66778. * Loads a file from offline support
  66779. * @param url defines the URL to load from
  66780. * @param sceneLoaded defines a callback to call on success
  66781. * @param progressCallBack defines a callback to call when progress changed
  66782. * @param errorCallback defines a callback to call on error
  66783. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66784. */
  66785. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66786. }
  66787. }
  66788. declare module BABYLON {
  66789. /**
  66790. * A class serves as a medium between the observable and its observers
  66791. */
  66792. export class EventState {
  66793. /**
  66794. * Create a new EventState
  66795. * @param mask defines the mask associated with this state
  66796. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66797. * @param target defines the original target of the state
  66798. * @param currentTarget defines the current target of the state
  66799. */
  66800. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66801. /**
  66802. * Initialize the current event state
  66803. * @param mask defines the mask associated with this state
  66804. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66805. * @param target defines the original target of the state
  66806. * @param currentTarget defines the current target of the state
  66807. * @returns the current event state
  66808. */
  66809. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66810. /**
  66811. * An Observer can set this property to true to prevent subsequent observers of being notified
  66812. */
  66813. skipNextObservers: boolean;
  66814. /**
  66815. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66816. */
  66817. mask: number;
  66818. /**
  66819. * The object that originally notified the event
  66820. */
  66821. target?: any;
  66822. /**
  66823. * The current object in the bubbling phase
  66824. */
  66825. currentTarget?: any;
  66826. /**
  66827. * This will be populated with the return value of the last function that was executed.
  66828. * If it is the first function in the callback chain it will be the event data.
  66829. */
  66830. lastReturnValue?: any;
  66831. }
  66832. /**
  66833. * Represent an Observer registered to a given Observable object.
  66834. */
  66835. export class Observer<T> {
  66836. /**
  66837. * Defines the callback to call when the observer is notified
  66838. */
  66839. callback: (eventData: T, eventState: EventState) => void;
  66840. /**
  66841. * Defines the mask of the observer (used to filter notifications)
  66842. */
  66843. mask: number;
  66844. /**
  66845. * Defines the current scope used to restore the JS context
  66846. */
  66847. scope: any;
  66848. /** @hidden */
  66849. _willBeUnregistered: boolean;
  66850. /**
  66851. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66852. */
  66853. unregisterOnNextCall: boolean;
  66854. /**
  66855. * Creates a new observer
  66856. * @param callback defines the callback to call when the observer is notified
  66857. * @param mask defines the mask of the observer (used to filter notifications)
  66858. * @param scope defines the current scope used to restore the JS context
  66859. */
  66860. constructor(
  66861. /**
  66862. * Defines the callback to call when the observer is notified
  66863. */
  66864. callback: (eventData: T, eventState: EventState) => void,
  66865. /**
  66866. * Defines the mask of the observer (used to filter notifications)
  66867. */
  66868. mask: number,
  66869. /**
  66870. * Defines the current scope used to restore the JS context
  66871. */
  66872. scope?: any);
  66873. }
  66874. /**
  66875. * Represent a list of observers registered to multiple Observables object.
  66876. */
  66877. export class MultiObserver<T> {
  66878. private _observers;
  66879. private _observables;
  66880. /**
  66881. * Release associated resources
  66882. */
  66883. dispose(): void;
  66884. /**
  66885. * Raise a callback when one of the observable will notify
  66886. * @param observables defines a list of observables to watch
  66887. * @param callback defines the callback to call on notification
  66888. * @param mask defines the mask used to filter notifications
  66889. * @param scope defines the current scope used to restore the JS context
  66890. * @returns the new MultiObserver
  66891. */
  66892. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66893. }
  66894. /**
  66895. * The Observable class is a simple implementation of the Observable pattern.
  66896. *
  66897. * 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.
  66898. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66899. * 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).
  66900. * 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.
  66901. */
  66902. export class Observable<T> {
  66903. private _observers;
  66904. private _eventState;
  66905. private _onObserverAdded;
  66906. /**
  66907. * Creates a new observable
  66908. * @param onObserverAdded defines a callback to call when a new observer is added
  66909. */
  66910. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66911. /**
  66912. * Create a new Observer with the specified callback
  66913. * @param callback the callback that will be executed for that Observer
  66914. * @param mask the mask used to filter observers
  66915. * @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.
  66916. * @param scope optional scope for the callback to be called from
  66917. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66918. * @returns the new observer created for the callback
  66919. */
  66920. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66921. /**
  66922. * Create a new Observer with the specified callback and unregisters after the next notification
  66923. * @param callback the callback that will be executed for that Observer
  66924. * @returns the new observer created for the callback
  66925. */
  66926. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66927. /**
  66928. * Remove an Observer from the Observable object
  66929. * @param observer the instance of the Observer to remove
  66930. * @returns false if it doesn't belong to this Observable
  66931. */
  66932. remove(observer: Nullable<Observer<T>>): boolean;
  66933. /**
  66934. * Remove a callback from the Observable object
  66935. * @param callback the callback to remove
  66936. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66937. * @returns false if it doesn't belong to this Observable
  66938. */
  66939. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66940. private _deferUnregister;
  66941. private _remove;
  66942. /**
  66943. * Moves the observable to the top of the observer list making it get called first when notified
  66944. * @param observer the observer to move
  66945. */
  66946. makeObserverTopPriority(observer: Observer<T>): void;
  66947. /**
  66948. * Moves the observable to the bottom of the observer list making it get called last when notified
  66949. * @param observer the observer to move
  66950. */
  66951. makeObserverBottomPriority(observer: Observer<T>): void;
  66952. /**
  66953. * Notify all Observers by calling their respective callback with the given data
  66954. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66955. * @param eventData defines the data to send to all observers
  66956. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66957. * @param target defines the original target of the state
  66958. * @param currentTarget defines the current target of the state
  66959. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66960. */
  66961. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66962. /**
  66963. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66964. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66965. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66966. * and it is crucial that all callbacks will be executed.
  66967. * The order of the callbacks is kept, callbacks are not executed parallel.
  66968. *
  66969. * @param eventData The data to be sent to each callback
  66970. * @param mask is used to filter observers defaults to -1
  66971. * @param target defines the callback target (see EventState)
  66972. * @param currentTarget defines he current object in the bubbling phase
  66973. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66974. */
  66975. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66976. /**
  66977. * Notify a specific observer
  66978. * @param observer defines the observer to notify
  66979. * @param eventData defines the data to be sent to each callback
  66980. * @param mask is used to filter observers defaults to -1
  66981. */
  66982. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66983. /**
  66984. * Gets a boolean indicating if the observable has at least one observer
  66985. * @returns true is the Observable has at least one Observer registered
  66986. */
  66987. hasObservers(): boolean;
  66988. /**
  66989. * Clear the list of observers
  66990. */
  66991. clear(): void;
  66992. /**
  66993. * Clone the current observable
  66994. * @returns a new observable
  66995. */
  66996. clone(): Observable<T>;
  66997. /**
  66998. * Does this observable handles observer registered with a given mask
  66999. * @param mask defines the mask to be tested
  67000. * @return whether or not one observer registered with the given mask is handeled
  67001. **/
  67002. hasSpecificMask(mask?: number): boolean;
  67003. }
  67004. }
  67005. declare module BABYLON {
  67006. /**
  67007. * Class used to help managing file picking and drag'n'drop
  67008. * File Storage
  67009. */
  67010. export class FilesInputStore {
  67011. /**
  67012. * List of files ready to be loaded
  67013. */
  67014. static FilesToLoad: {
  67015. [key: string]: File;
  67016. };
  67017. }
  67018. }
  67019. declare module BABYLON {
  67020. /** Defines the cross module used constants to avoid circular dependncies */
  67021. export class Constants {
  67022. /** Defines that alpha blending is disabled */
  67023. static readonly ALPHA_DISABLE: number;
  67024. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67025. static readonly ALPHA_ADD: number;
  67026. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67027. static readonly ALPHA_COMBINE: number;
  67028. /** Defines that alpha blending to DEST - SRC * DEST */
  67029. static readonly ALPHA_SUBTRACT: number;
  67030. /** Defines that alpha blending to SRC * DEST */
  67031. static readonly ALPHA_MULTIPLY: number;
  67032. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67033. static readonly ALPHA_MAXIMIZED: number;
  67034. /** Defines that alpha blending to SRC + DEST */
  67035. static readonly ALPHA_ONEONE: number;
  67036. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67037. static readonly ALPHA_PREMULTIPLIED: number;
  67038. /**
  67039. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67040. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67041. */
  67042. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67043. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67044. static readonly ALPHA_INTERPOLATE: number;
  67045. /**
  67046. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67047. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67048. */
  67049. static readonly ALPHA_SCREENMODE: number;
  67050. /** Defines that the ressource is not delayed*/
  67051. static readonly DELAYLOADSTATE_NONE: number;
  67052. /** Defines that the ressource was successfully delay loaded */
  67053. static readonly DELAYLOADSTATE_LOADED: number;
  67054. /** Defines that the ressource is currently delay loading */
  67055. static readonly DELAYLOADSTATE_LOADING: number;
  67056. /** Defines that the ressource is delayed and has not started loading */
  67057. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67058. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67059. static readonly NEVER: number;
  67060. /** 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 */
  67061. static readonly ALWAYS: number;
  67062. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67063. static readonly LESS: number;
  67064. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67065. static readonly EQUAL: number;
  67066. /** 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 */
  67067. static readonly LEQUAL: number;
  67068. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67069. static readonly GREATER: number;
  67070. /** 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 */
  67071. static readonly GEQUAL: number;
  67072. /** 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 */
  67073. static readonly NOTEQUAL: number;
  67074. /** Passed to stencilOperation to specify that stencil value must be kept */
  67075. static readonly KEEP: number;
  67076. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67077. static readonly REPLACE: number;
  67078. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67079. static readonly INCR: number;
  67080. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67081. static readonly DECR: number;
  67082. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67083. static readonly INVERT: number;
  67084. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67085. static readonly INCR_WRAP: number;
  67086. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67087. static readonly DECR_WRAP: number;
  67088. /** Texture is not repeating outside of 0..1 UVs */
  67089. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67090. /** Texture is repeating outside of 0..1 UVs */
  67091. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67092. /** Texture is repeating and mirrored */
  67093. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67094. /** ALPHA */
  67095. static readonly TEXTUREFORMAT_ALPHA: number;
  67096. /** LUMINANCE */
  67097. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67098. /** LUMINANCE_ALPHA */
  67099. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67100. /** RGB */
  67101. static readonly TEXTUREFORMAT_RGB: number;
  67102. /** RGBA */
  67103. static readonly TEXTUREFORMAT_RGBA: number;
  67104. /** RED */
  67105. static readonly TEXTUREFORMAT_RED: number;
  67106. /** RED (2nd reference) */
  67107. static readonly TEXTUREFORMAT_R: number;
  67108. /** RG */
  67109. static readonly TEXTUREFORMAT_RG: number;
  67110. /** RED_INTEGER */
  67111. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67112. /** RED_INTEGER (2nd reference) */
  67113. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67114. /** RG_INTEGER */
  67115. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67116. /** RGB_INTEGER */
  67117. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67118. /** RGBA_INTEGER */
  67119. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67120. /** UNSIGNED_BYTE */
  67121. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67122. /** UNSIGNED_BYTE (2nd reference) */
  67123. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67124. /** FLOAT */
  67125. static readonly TEXTURETYPE_FLOAT: number;
  67126. /** HALF_FLOAT */
  67127. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67128. /** BYTE */
  67129. static readonly TEXTURETYPE_BYTE: number;
  67130. /** SHORT */
  67131. static readonly TEXTURETYPE_SHORT: number;
  67132. /** UNSIGNED_SHORT */
  67133. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67134. /** INT */
  67135. static readonly TEXTURETYPE_INT: number;
  67136. /** UNSIGNED_INT */
  67137. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67138. /** UNSIGNED_SHORT_4_4_4_4 */
  67139. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67140. /** UNSIGNED_SHORT_5_5_5_1 */
  67141. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67142. /** UNSIGNED_SHORT_5_6_5 */
  67143. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67144. /** UNSIGNED_INT_2_10_10_10_REV */
  67145. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67146. /** UNSIGNED_INT_24_8 */
  67147. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67148. /** UNSIGNED_INT_10F_11F_11F_REV */
  67149. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67150. /** UNSIGNED_INT_5_9_9_9_REV */
  67151. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67152. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67153. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67154. /** nearest is mag = nearest and min = nearest and mip = linear */
  67155. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67156. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67157. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67158. /** Trilinear is mag = linear and min = linear and mip = linear */
  67159. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67160. /** nearest is mag = nearest and min = nearest and mip = linear */
  67161. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67162. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67163. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67164. /** Trilinear is mag = linear and min = linear and mip = linear */
  67165. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67166. /** mag = nearest and min = nearest and mip = nearest */
  67167. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67168. /** mag = nearest and min = linear and mip = nearest */
  67169. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67170. /** mag = nearest and min = linear and mip = linear */
  67171. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67172. /** mag = nearest and min = linear and mip = none */
  67173. static readonly TEXTURE_NEAREST_LINEAR: number;
  67174. /** mag = nearest and min = nearest and mip = none */
  67175. static readonly TEXTURE_NEAREST_NEAREST: number;
  67176. /** mag = linear and min = nearest and mip = nearest */
  67177. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67178. /** mag = linear and min = nearest and mip = linear */
  67179. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67180. /** mag = linear and min = linear and mip = none */
  67181. static readonly TEXTURE_LINEAR_LINEAR: number;
  67182. /** mag = linear and min = nearest and mip = none */
  67183. static readonly TEXTURE_LINEAR_NEAREST: number;
  67184. /** Explicit coordinates mode */
  67185. static readonly TEXTURE_EXPLICIT_MODE: number;
  67186. /** Spherical coordinates mode */
  67187. static readonly TEXTURE_SPHERICAL_MODE: number;
  67188. /** Planar coordinates mode */
  67189. static readonly TEXTURE_PLANAR_MODE: number;
  67190. /** Cubic coordinates mode */
  67191. static readonly TEXTURE_CUBIC_MODE: number;
  67192. /** Projection coordinates mode */
  67193. static readonly TEXTURE_PROJECTION_MODE: number;
  67194. /** Skybox coordinates mode */
  67195. static readonly TEXTURE_SKYBOX_MODE: number;
  67196. /** Inverse Cubic coordinates mode */
  67197. static readonly TEXTURE_INVCUBIC_MODE: number;
  67198. /** Equirectangular coordinates mode */
  67199. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67200. /** Equirectangular Fixed coordinates mode */
  67201. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67202. /** Equirectangular Fixed Mirrored coordinates mode */
  67203. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67204. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67205. static readonly SCALEMODE_FLOOR: number;
  67206. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67207. static readonly SCALEMODE_NEAREST: number;
  67208. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67209. static readonly SCALEMODE_CEILING: number;
  67210. /**
  67211. * The dirty texture flag value
  67212. */
  67213. static readonly MATERIAL_TextureDirtyFlag: number;
  67214. /**
  67215. * The dirty light flag value
  67216. */
  67217. static readonly MATERIAL_LightDirtyFlag: number;
  67218. /**
  67219. * The dirty fresnel flag value
  67220. */
  67221. static readonly MATERIAL_FresnelDirtyFlag: number;
  67222. /**
  67223. * The dirty attribute flag value
  67224. */
  67225. static readonly MATERIAL_AttributesDirtyFlag: number;
  67226. /**
  67227. * The dirty misc flag value
  67228. */
  67229. static readonly MATERIAL_MiscDirtyFlag: number;
  67230. /**
  67231. * The all dirty flag value
  67232. */
  67233. static readonly MATERIAL_AllDirtyFlag: number;
  67234. /**
  67235. * Returns the triangle fill mode
  67236. */
  67237. static readonly MATERIAL_TriangleFillMode: number;
  67238. /**
  67239. * Returns the wireframe mode
  67240. */
  67241. static readonly MATERIAL_WireFrameFillMode: number;
  67242. /**
  67243. * Returns the point fill mode
  67244. */
  67245. static readonly MATERIAL_PointFillMode: number;
  67246. /**
  67247. * Returns the point list draw mode
  67248. */
  67249. static readonly MATERIAL_PointListDrawMode: number;
  67250. /**
  67251. * Returns the line list draw mode
  67252. */
  67253. static readonly MATERIAL_LineListDrawMode: number;
  67254. /**
  67255. * Returns the line loop draw mode
  67256. */
  67257. static readonly MATERIAL_LineLoopDrawMode: number;
  67258. /**
  67259. * Returns the line strip draw mode
  67260. */
  67261. static readonly MATERIAL_LineStripDrawMode: number;
  67262. /**
  67263. * Returns the triangle strip draw mode
  67264. */
  67265. static readonly MATERIAL_TriangleStripDrawMode: number;
  67266. /**
  67267. * Returns the triangle fan draw mode
  67268. */
  67269. static readonly MATERIAL_TriangleFanDrawMode: number;
  67270. /**
  67271. * Stores the clock-wise side orientation
  67272. */
  67273. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67274. /**
  67275. * Stores the counter clock-wise side orientation
  67276. */
  67277. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67278. /**
  67279. * Nothing
  67280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67281. */
  67282. static readonly ACTION_NothingTrigger: number;
  67283. /**
  67284. * On pick
  67285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67286. */
  67287. static readonly ACTION_OnPickTrigger: number;
  67288. /**
  67289. * On left pick
  67290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67291. */
  67292. static readonly ACTION_OnLeftPickTrigger: number;
  67293. /**
  67294. * On right pick
  67295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67296. */
  67297. static readonly ACTION_OnRightPickTrigger: number;
  67298. /**
  67299. * On center pick
  67300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67301. */
  67302. static readonly ACTION_OnCenterPickTrigger: number;
  67303. /**
  67304. * On pick down
  67305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67306. */
  67307. static readonly ACTION_OnPickDownTrigger: number;
  67308. /**
  67309. * On double pick
  67310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67311. */
  67312. static readonly ACTION_OnDoublePickTrigger: number;
  67313. /**
  67314. * On pick up
  67315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67316. */
  67317. static readonly ACTION_OnPickUpTrigger: number;
  67318. /**
  67319. * On pick out.
  67320. * This trigger will only be raised if you also declared a OnPickDown
  67321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67322. */
  67323. static readonly ACTION_OnPickOutTrigger: number;
  67324. /**
  67325. * On long press
  67326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67327. */
  67328. static readonly ACTION_OnLongPressTrigger: number;
  67329. /**
  67330. * On pointer over
  67331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67332. */
  67333. static readonly ACTION_OnPointerOverTrigger: number;
  67334. /**
  67335. * On pointer out
  67336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67337. */
  67338. static readonly ACTION_OnPointerOutTrigger: number;
  67339. /**
  67340. * On every frame
  67341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67342. */
  67343. static readonly ACTION_OnEveryFrameTrigger: number;
  67344. /**
  67345. * On intersection enter
  67346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67347. */
  67348. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67349. /**
  67350. * On intersection exit
  67351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67352. */
  67353. static readonly ACTION_OnIntersectionExitTrigger: number;
  67354. /**
  67355. * On key down
  67356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67357. */
  67358. static readonly ACTION_OnKeyDownTrigger: number;
  67359. /**
  67360. * On key up
  67361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67362. */
  67363. static readonly ACTION_OnKeyUpTrigger: number;
  67364. /**
  67365. * Billboard mode will only apply to Y axis
  67366. */
  67367. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67368. /**
  67369. * Billboard mode will apply to all axes
  67370. */
  67371. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67372. /**
  67373. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67374. */
  67375. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67376. /**
  67377. * Gets or sets base Assets URL
  67378. */
  67379. static PARTICLES_BaseAssetsUrl: string;
  67380. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67381. * Test order :
  67382. * Is the bounding sphere outside the frustum ?
  67383. * If not, are the bounding box vertices outside the frustum ?
  67384. * It not, then the cullable object is in the frustum.
  67385. */
  67386. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67387. /** Culling strategy : Bounding Sphere Only.
  67388. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67389. * It's also less accurate than the standard because some not visible objects can still be selected.
  67390. * Test : is the bounding sphere outside the frustum ?
  67391. * If not, then the cullable object is in the frustum.
  67392. */
  67393. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67394. /** Culling strategy : Optimistic Inclusion.
  67395. * This in an inclusion test first, then the standard exclusion test.
  67396. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67397. * 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.
  67398. * Anyway, it's as accurate as the standard strategy.
  67399. * Test :
  67400. * Is the cullable object bounding sphere center in the frustum ?
  67401. * If not, apply the default culling strategy.
  67402. */
  67403. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67404. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67405. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67406. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67407. * 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.
  67408. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67409. * Test :
  67410. * Is the cullable object bounding sphere center in the frustum ?
  67411. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67412. */
  67413. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67414. /**
  67415. * No logging while loading
  67416. */
  67417. static readonly SCENELOADER_NO_LOGGING: number;
  67418. /**
  67419. * Minimal logging while loading
  67420. */
  67421. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67422. /**
  67423. * Summary logging while loading
  67424. */
  67425. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67426. /**
  67427. * Detailled logging while loading
  67428. */
  67429. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67430. }
  67431. }
  67432. declare module BABYLON {
  67433. /**
  67434. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67435. * Babylon.js
  67436. */
  67437. export class DomManagement {
  67438. /**
  67439. * Checks if the window object exists
  67440. * @returns true if the window object exists
  67441. */
  67442. static IsWindowObjectExist(): boolean;
  67443. /**
  67444. * Extracts text content from a DOM element hierarchy
  67445. * @param element defines the root element
  67446. * @returns a string
  67447. */
  67448. static GetDOMTextContent(element: HTMLElement): string;
  67449. }
  67450. }
  67451. declare module BABYLON {
  67452. /**
  67453. * Logger used througouht the application to allow configuration of
  67454. * the log level required for the messages.
  67455. */
  67456. export class Logger {
  67457. /**
  67458. * No log
  67459. */
  67460. static readonly NoneLogLevel: number;
  67461. /**
  67462. * Only message logs
  67463. */
  67464. static readonly MessageLogLevel: number;
  67465. /**
  67466. * Only warning logs
  67467. */
  67468. static readonly WarningLogLevel: number;
  67469. /**
  67470. * Only error logs
  67471. */
  67472. static readonly ErrorLogLevel: number;
  67473. /**
  67474. * All logs
  67475. */
  67476. static readonly AllLogLevel: number;
  67477. private static _LogCache;
  67478. /**
  67479. * Gets a value indicating the number of loading errors
  67480. * @ignorenaming
  67481. */
  67482. static errorsCount: number;
  67483. /**
  67484. * Callback called when a new log is added
  67485. */
  67486. static OnNewCacheEntry: (entry: string) => void;
  67487. private static _AddLogEntry;
  67488. private static _FormatMessage;
  67489. private static _LogDisabled;
  67490. private static _LogEnabled;
  67491. private static _WarnDisabled;
  67492. private static _WarnEnabled;
  67493. private static _ErrorDisabled;
  67494. private static _ErrorEnabled;
  67495. /**
  67496. * Log a message to the console
  67497. */
  67498. static Log: (message: string) => void;
  67499. /**
  67500. * Write a warning message to the console
  67501. */
  67502. static Warn: (message: string) => void;
  67503. /**
  67504. * Write an error message to the console
  67505. */
  67506. static Error: (message: string) => void;
  67507. /**
  67508. * Gets current log cache (list of logs)
  67509. */
  67510. static readonly LogCache: string;
  67511. /**
  67512. * Clears the log cache
  67513. */
  67514. static ClearLogCache(): void;
  67515. /**
  67516. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67517. */
  67518. static LogLevels: number;
  67519. }
  67520. }
  67521. declare module BABYLON {
  67522. /** @hidden */
  67523. export class _TypeStore {
  67524. /** @hidden */
  67525. static RegisteredTypes: {
  67526. [key: string]: Object;
  67527. };
  67528. /** @hidden */
  67529. static GetClass(fqdn: string): any;
  67530. }
  67531. }
  67532. declare module BABYLON {
  67533. /**
  67534. * Class containing a set of static utilities functions for deep copy.
  67535. */
  67536. export class DeepCopier {
  67537. /**
  67538. * Tries to copy an object by duplicating every property
  67539. * @param source defines the source object
  67540. * @param destination defines the target object
  67541. * @param doNotCopyList defines a list of properties to avoid
  67542. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67543. */
  67544. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67545. }
  67546. }
  67547. declare module BABYLON {
  67548. /**
  67549. * Class containing a set of static utilities functions for precision date
  67550. */
  67551. export class PrecisionDate {
  67552. /**
  67553. * Gets either window.performance.now() if supported or Date.now() else
  67554. */
  67555. static readonly Now: number;
  67556. }
  67557. }
  67558. declare module BABYLON {
  67559. /** @hidden */
  67560. export class _DevTools {
  67561. static WarnImport(name: string): string;
  67562. }
  67563. }
  67564. declare module BABYLON {
  67565. /**
  67566. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67567. */
  67568. export class WebRequest {
  67569. private _xhr;
  67570. /**
  67571. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67572. * i.e. when loading files, where the server/service expects an Authorization header
  67573. */
  67574. static CustomRequestHeaders: {
  67575. [key: string]: string;
  67576. };
  67577. /**
  67578. * Add callback functions in this array to update all the requests before they get sent to the network
  67579. */
  67580. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67581. private _injectCustomRequestHeaders;
  67582. /**
  67583. * Gets or sets a function to be called when loading progress changes
  67584. */
  67585. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67586. /**
  67587. * Returns client's state
  67588. */
  67589. readonly readyState: number;
  67590. /**
  67591. * Returns client's status
  67592. */
  67593. readonly status: number;
  67594. /**
  67595. * Returns client's status as a text
  67596. */
  67597. readonly statusText: string;
  67598. /**
  67599. * Returns client's response
  67600. */
  67601. readonly response: any;
  67602. /**
  67603. * Returns client's response url
  67604. */
  67605. readonly responseURL: string;
  67606. /**
  67607. * Returns client's response as text
  67608. */
  67609. readonly responseText: string;
  67610. /**
  67611. * Gets or sets the expected response type
  67612. */
  67613. responseType: XMLHttpRequestResponseType;
  67614. /** @hidden */
  67615. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67616. /** @hidden */
  67617. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67618. /**
  67619. * Cancels any network activity
  67620. */
  67621. abort(): void;
  67622. /**
  67623. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67624. * @param body defines an optional request body
  67625. */
  67626. send(body?: Document | BodyInit | null): void;
  67627. /**
  67628. * Sets the request method, request URL
  67629. * @param method defines the method to use (GET, POST, etc..)
  67630. * @param url defines the url to connect with
  67631. */
  67632. open(method: string, url: string): void;
  67633. }
  67634. }
  67635. declare module BABYLON {
  67636. /**
  67637. * Class used to evalaute queries containing `and` and `or` operators
  67638. */
  67639. export class AndOrNotEvaluator {
  67640. /**
  67641. * Evaluate a query
  67642. * @param query defines the query to evaluate
  67643. * @param evaluateCallback defines the callback used to filter result
  67644. * @returns true if the query matches
  67645. */
  67646. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67647. private static _HandleParenthesisContent;
  67648. private static _SimplifyNegation;
  67649. }
  67650. }
  67651. declare module BABYLON {
  67652. /**
  67653. * Class used to store custom tags
  67654. */
  67655. export class Tags {
  67656. /**
  67657. * Adds support for tags on the given object
  67658. * @param obj defines the object to use
  67659. */
  67660. static EnableFor(obj: any): void;
  67661. /**
  67662. * Removes tags support
  67663. * @param obj defines the object to use
  67664. */
  67665. static DisableFor(obj: any): void;
  67666. /**
  67667. * Gets a boolean indicating if the given object has tags
  67668. * @param obj defines the object to use
  67669. * @returns a boolean
  67670. */
  67671. static HasTags(obj: any): boolean;
  67672. /**
  67673. * Gets the tags available on a given object
  67674. * @param obj defines the object to use
  67675. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67676. * @returns the tags
  67677. */
  67678. static GetTags(obj: any, asString?: boolean): any;
  67679. /**
  67680. * Adds tags to an object
  67681. * @param obj defines the object to use
  67682. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67683. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67684. */
  67685. static AddTagsTo(obj: any, tagsString: string): void;
  67686. /**
  67687. * @hidden
  67688. */
  67689. static _AddTagTo(obj: any, tag: string): void;
  67690. /**
  67691. * Removes specific tags from a specific object
  67692. * @param obj defines the object to use
  67693. * @param tagsString defines the tags to remove
  67694. */
  67695. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67696. /**
  67697. * @hidden
  67698. */
  67699. static _RemoveTagFrom(obj: any, tag: string): void;
  67700. /**
  67701. * Defines if tags hosted on an object match a given query
  67702. * @param obj defines the object to use
  67703. * @param tagsQuery defines the tag query
  67704. * @returns a boolean
  67705. */
  67706. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67707. }
  67708. }
  67709. declare module BABYLON {
  67710. /**
  67711. * Manages the defines for the Material
  67712. */
  67713. export class MaterialDefines {
  67714. /** @hidden */
  67715. protected _keys: string[];
  67716. private _isDirty;
  67717. /** @hidden */
  67718. _renderId: number;
  67719. /** @hidden */
  67720. _areLightsDirty: boolean;
  67721. /** @hidden */
  67722. _areAttributesDirty: boolean;
  67723. /** @hidden */
  67724. _areTexturesDirty: boolean;
  67725. /** @hidden */
  67726. _areFresnelDirty: boolean;
  67727. /** @hidden */
  67728. _areMiscDirty: boolean;
  67729. /** @hidden */
  67730. _areImageProcessingDirty: boolean;
  67731. /** @hidden */
  67732. _normals: boolean;
  67733. /** @hidden */
  67734. _uvs: boolean;
  67735. /** @hidden */
  67736. _needNormals: boolean;
  67737. /** @hidden */
  67738. _needUVs: boolean;
  67739. [id: string]: any;
  67740. /**
  67741. * Specifies if the material needs to be re-calculated
  67742. */
  67743. readonly isDirty: boolean;
  67744. /**
  67745. * Marks the material to indicate that it has been re-calculated
  67746. */
  67747. markAsProcessed(): void;
  67748. /**
  67749. * Marks the material to indicate that it needs to be re-calculated
  67750. */
  67751. markAsUnprocessed(): void;
  67752. /**
  67753. * Marks the material to indicate all of its defines need to be re-calculated
  67754. */
  67755. markAllAsDirty(): void;
  67756. /**
  67757. * Marks the material to indicate that image processing needs to be re-calculated
  67758. */
  67759. markAsImageProcessingDirty(): void;
  67760. /**
  67761. * Marks the material to indicate the lights need to be re-calculated
  67762. */
  67763. markAsLightDirty(): void;
  67764. /**
  67765. * Marks the attribute state as changed
  67766. */
  67767. markAsAttributesDirty(): void;
  67768. /**
  67769. * Marks the texture state as changed
  67770. */
  67771. markAsTexturesDirty(): void;
  67772. /**
  67773. * Marks the fresnel state as changed
  67774. */
  67775. markAsFresnelDirty(): void;
  67776. /**
  67777. * Marks the misc state as changed
  67778. */
  67779. markAsMiscDirty(): void;
  67780. /**
  67781. * Rebuilds the material defines
  67782. */
  67783. rebuild(): void;
  67784. /**
  67785. * Specifies if two material defines are equal
  67786. * @param other - A material define instance to compare to
  67787. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67788. */
  67789. isEqual(other: MaterialDefines): boolean;
  67790. /**
  67791. * Clones this instance's defines to another instance
  67792. * @param other - material defines to clone values to
  67793. */
  67794. cloneTo(other: MaterialDefines): void;
  67795. /**
  67796. * Resets the material define values
  67797. */
  67798. reset(): void;
  67799. /**
  67800. * Converts the material define values to a string
  67801. * @returns - String of material define information
  67802. */
  67803. toString(): string;
  67804. }
  67805. }
  67806. declare module BABYLON {
  67807. /**
  67808. * Class used to store and describe the pipeline context associated with an effect
  67809. */
  67810. export interface IPipelineContext {
  67811. /**
  67812. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67813. */
  67814. isAsync: boolean;
  67815. /**
  67816. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67817. */
  67818. isReady: boolean;
  67819. /** @hidden */
  67820. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67821. }
  67822. }
  67823. declare module BABYLON {
  67824. /**
  67825. * Class used to store gfx data (like WebGLBuffer)
  67826. */
  67827. export class DataBuffer {
  67828. /**
  67829. * Gets or sets the number of objects referencing this buffer
  67830. */
  67831. references: number;
  67832. /** Gets or sets the size of the underlying buffer */
  67833. capacity: number;
  67834. /**
  67835. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67836. */
  67837. is32Bits: boolean;
  67838. /**
  67839. * Gets the underlying buffer
  67840. */
  67841. readonly underlyingResource: any;
  67842. }
  67843. }
  67844. declare module BABYLON {
  67845. /** @hidden */
  67846. export interface IShaderProcessor {
  67847. attributeProcessor?: (attribute: string) => string;
  67848. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67849. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67850. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67851. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67852. lineProcessor?: (line: string, isFragment: boolean) => string;
  67853. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67854. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67855. }
  67856. }
  67857. declare module BABYLON {
  67858. /** @hidden */
  67859. export interface ProcessingOptions {
  67860. defines: string[];
  67861. indexParameters: any;
  67862. isFragment: boolean;
  67863. shouldUseHighPrecisionShader: boolean;
  67864. supportsUniformBuffers: boolean;
  67865. shadersRepository: string;
  67866. includesShadersStore: {
  67867. [key: string]: string;
  67868. };
  67869. processor?: IShaderProcessor;
  67870. version: string;
  67871. platformName: string;
  67872. lookForClosingBracketForUniformBuffer?: boolean;
  67873. }
  67874. }
  67875. declare module BABYLON {
  67876. /** @hidden */
  67877. export class ShaderCodeNode {
  67878. line: string;
  67879. children: ShaderCodeNode[];
  67880. additionalDefineKey?: string;
  67881. additionalDefineValue?: string;
  67882. isValid(preprocessors: {
  67883. [key: string]: string;
  67884. }): boolean;
  67885. process(preprocessors: {
  67886. [key: string]: string;
  67887. }, options: ProcessingOptions): string;
  67888. }
  67889. }
  67890. declare module BABYLON {
  67891. /** @hidden */
  67892. export class ShaderCodeCursor {
  67893. private _lines;
  67894. lineIndex: number;
  67895. readonly currentLine: string;
  67896. readonly canRead: boolean;
  67897. lines: string[];
  67898. }
  67899. }
  67900. declare module BABYLON {
  67901. /** @hidden */
  67902. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67903. process(preprocessors: {
  67904. [key: string]: string;
  67905. }, options: ProcessingOptions): string;
  67906. }
  67907. }
  67908. declare module BABYLON {
  67909. /** @hidden */
  67910. export class ShaderDefineExpression {
  67911. isTrue(preprocessors: {
  67912. [key: string]: string;
  67913. }): boolean;
  67914. }
  67915. }
  67916. declare module BABYLON {
  67917. /** @hidden */
  67918. export class ShaderCodeTestNode extends ShaderCodeNode {
  67919. testExpression: ShaderDefineExpression;
  67920. isValid(preprocessors: {
  67921. [key: string]: string;
  67922. }): boolean;
  67923. }
  67924. }
  67925. declare module BABYLON {
  67926. /** @hidden */
  67927. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67928. define: string;
  67929. not: boolean;
  67930. constructor(define: string, not?: boolean);
  67931. isTrue(preprocessors: {
  67932. [key: string]: string;
  67933. }): boolean;
  67934. }
  67935. }
  67936. declare module BABYLON {
  67937. /** @hidden */
  67938. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  67939. leftOperand: ShaderDefineExpression;
  67940. rightOperand: ShaderDefineExpression;
  67941. isTrue(preprocessors: {
  67942. [key: string]: string;
  67943. }): boolean;
  67944. }
  67945. }
  67946. declare module BABYLON {
  67947. /** @hidden */
  67948. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  67949. leftOperand: ShaderDefineExpression;
  67950. rightOperand: ShaderDefineExpression;
  67951. isTrue(preprocessors: {
  67952. [key: string]: string;
  67953. }): boolean;
  67954. }
  67955. }
  67956. declare module BABYLON {
  67957. /** @hidden */
  67958. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  67959. define: string;
  67960. operand: string;
  67961. testValue: string;
  67962. constructor(define: string, operand: string, testValue: string);
  67963. isTrue(preprocessors: {
  67964. [key: string]: string;
  67965. }): boolean;
  67966. }
  67967. }
  67968. declare module BABYLON {
  67969. /** @hidden */
  67970. export class ShaderProcessor {
  67971. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  67972. private static _ProcessPrecision;
  67973. private static _ExtractOperation;
  67974. private static _BuildSubExpression;
  67975. private static _BuildExpression;
  67976. private static _MoveCursorWithinIf;
  67977. private static _MoveCursor;
  67978. private static _EvaluatePreProcessors;
  67979. private static _PreparePreProcessors;
  67980. private static _ProcessShaderConversion;
  67981. private static _ProcessIncludes;
  67982. }
  67983. }
  67984. declare module BABYLON {
  67985. /**
  67986. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  67987. */
  67988. export class PerformanceMonitor {
  67989. private _enabled;
  67990. private _rollingFrameTime;
  67991. private _lastFrameTimeMs;
  67992. /**
  67993. * constructor
  67994. * @param frameSampleSize The number of samples required to saturate the sliding window
  67995. */
  67996. constructor(frameSampleSize?: number);
  67997. /**
  67998. * Samples current frame
  67999. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68000. */
  68001. sampleFrame(timeMs?: number): void;
  68002. /**
  68003. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68004. */
  68005. readonly averageFrameTime: number;
  68006. /**
  68007. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68008. */
  68009. readonly averageFrameTimeVariance: number;
  68010. /**
  68011. * Returns the frame time of the most recent frame
  68012. */
  68013. readonly instantaneousFrameTime: number;
  68014. /**
  68015. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68016. */
  68017. readonly averageFPS: number;
  68018. /**
  68019. * Returns the average framerate in frames per second using the most recent frame time
  68020. */
  68021. readonly instantaneousFPS: number;
  68022. /**
  68023. * Returns true if enough samples have been taken to completely fill the sliding window
  68024. */
  68025. readonly isSaturated: boolean;
  68026. /**
  68027. * Enables contributions to the sliding window sample set
  68028. */
  68029. enable(): void;
  68030. /**
  68031. * Disables contributions to the sliding window sample set
  68032. * Samples will not be interpolated over the disabled period
  68033. */
  68034. disable(): void;
  68035. /**
  68036. * Returns true if sampling is enabled
  68037. */
  68038. readonly isEnabled: boolean;
  68039. /**
  68040. * Resets performance monitor
  68041. */
  68042. reset(): void;
  68043. }
  68044. /**
  68045. * RollingAverage
  68046. *
  68047. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68048. */
  68049. export class RollingAverage {
  68050. /**
  68051. * Current average
  68052. */
  68053. average: number;
  68054. /**
  68055. * Current variance
  68056. */
  68057. variance: number;
  68058. protected _samples: Array<number>;
  68059. protected _sampleCount: number;
  68060. protected _pos: number;
  68061. protected _m2: number;
  68062. /**
  68063. * constructor
  68064. * @param length The number of samples required to saturate the sliding window
  68065. */
  68066. constructor(length: number);
  68067. /**
  68068. * Adds a sample to the sample set
  68069. * @param v The sample value
  68070. */
  68071. add(v: number): void;
  68072. /**
  68073. * Returns previously added values or null if outside of history or outside the sliding window domain
  68074. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68075. * @return Value previously recorded with add() or null if outside of range
  68076. */
  68077. history(i: number): number;
  68078. /**
  68079. * Returns true if enough samples have been taken to completely fill the sliding window
  68080. * @return true if sample-set saturated
  68081. */
  68082. isSaturated(): boolean;
  68083. /**
  68084. * Resets the rolling average (equivalent to 0 samples taken so far)
  68085. */
  68086. reset(): void;
  68087. /**
  68088. * Wraps a value around the sample range boundaries
  68089. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68090. * @return Wrapped position in sample range
  68091. */
  68092. protected _wrapPosition(i: number): number;
  68093. }
  68094. }
  68095. declare module BABYLON {
  68096. /**
  68097. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68098. * The underlying implementation relies on an associative array to ensure the best performances.
  68099. * The value can be anything including 'null' but except 'undefined'
  68100. */
  68101. export class StringDictionary<T> {
  68102. /**
  68103. * This will clear this dictionary and copy the content from the 'source' one.
  68104. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68105. * @param source the dictionary to take the content from and copy to this dictionary
  68106. */
  68107. copyFrom(source: StringDictionary<T>): void;
  68108. /**
  68109. * Get a value based from its key
  68110. * @param key the given key to get the matching value from
  68111. * @return the value if found, otherwise undefined is returned
  68112. */
  68113. get(key: string): T | undefined;
  68114. /**
  68115. * Get a value from its key or add it if it doesn't exist.
  68116. * This method will ensure you that a given key/data will be present in the dictionary.
  68117. * @param key the given key to get the matching value from
  68118. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68119. * The factory will only be invoked if there's no data for the given key.
  68120. * @return the value corresponding to the key.
  68121. */
  68122. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68123. /**
  68124. * Get a value from its key if present in the dictionary otherwise add it
  68125. * @param key the key to get the value from
  68126. * @param val if there's no such key/value pair in the dictionary add it with this value
  68127. * @return the value corresponding to the key
  68128. */
  68129. getOrAdd(key: string, val: T): T;
  68130. /**
  68131. * Check if there's a given key in the dictionary
  68132. * @param key the key to check for
  68133. * @return true if the key is present, false otherwise
  68134. */
  68135. contains(key: string): boolean;
  68136. /**
  68137. * Add a new key and its corresponding value
  68138. * @param key the key to add
  68139. * @param value the value corresponding to the key
  68140. * @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
  68141. */
  68142. add(key: string, value: T): boolean;
  68143. /**
  68144. * Update a specific value associated to a key
  68145. * @param key defines the key to use
  68146. * @param value defines the value to store
  68147. * @returns true if the value was updated (or false if the key was not found)
  68148. */
  68149. set(key: string, value: T): boolean;
  68150. /**
  68151. * Get the element of the given key and remove it from the dictionary
  68152. * @param key defines the key to search
  68153. * @returns the value associated with the key or null if not found
  68154. */
  68155. getAndRemove(key: string): Nullable<T>;
  68156. /**
  68157. * Remove a key/value from the dictionary.
  68158. * @param key the key to remove
  68159. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68160. */
  68161. remove(key: string): boolean;
  68162. /**
  68163. * Clear the whole content of the dictionary
  68164. */
  68165. clear(): void;
  68166. /**
  68167. * Gets the current count
  68168. */
  68169. readonly count: number;
  68170. /**
  68171. * Execute a callback on each key/val of the dictionary.
  68172. * Note that you can remove any element in this dictionary in the callback implementation
  68173. * @param callback the callback to execute on a given key/value pair
  68174. */
  68175. forEach(callback: (key: string, val: T) => void): void;
  68176. /**
  68177. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68178. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68179. * Note that you can remove any element in this dictionary in the callback implementation
  68180. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68181. * @returns the first item
  68182. */
  68183. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68184. private _count;
  68185. private _data;
  68186. }
  68187. }
  68188. declare module BABYLON {
  68189. /**
  68190. * Helper class that provides a small promise polyfill
  68191. */
  68192. export class PromisePolyfill {
  68193. /**
  68194. * Static function used to check if the polyfill is required
  68195. * If this is the case then the function will inject the polyfill to window.Promise
  68196. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68197. */
  68198. static Apply(force?: boolean): void;
  68199. }
  68200. }
  68201. declare module BABYLON {
  68202. /**
  68203. * Class used to store data that will be store in GPU memory
  68204. */
  68205. export class Buffer {
  68206. private _engine;
  68207. private _buffer;
  68208. /** @hidden */
  68209. _data: Nullable<DataArray>;
  68210. private _updatable;
  68211. private _instanced;
  68212. /**
  68213. * Gets the byte stride.
  68214. */
  68215. readonly byteStride: number;
  68216. /**
  68217. * Constructor
  68218. * @param engine the engine
  68219. * @param data the data to use for this buffer
  68220. * @param updatable whether the data is updatable
  68221. * @param stride the stride (optional)
  68222. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68223. * @param instanced whether the buffer is instanced (optional)
  68224. * @param useBytes set to true if the stride in in bytes (optional)
  68225. */
  68226. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68227. /**
  68228. * Create a new VertexBuffer based on the current buffer
  68229. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68230. * @param offset defines offset in the buffer (0 by default)
  68231. * @param size defines the size in floats of attributes (position is 3 for instance)
  68232. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68233. * @param instanced defines if the vertex buffer contains indexed data
  68234. * @param useBytes defines if the offset and stride are in bytes
  68235. * @returns the new vertex buffer
  68236. */
  68237. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68238. /**
  68239. * Gets a boolean indicating if the Buffer is updatable?
  68240. * @returns true if the buffer is updatable
  68241. */
  68242. isUpdatable(): boolean;
  68243. /**
  68244. * Gets current buffer's data
  68245. * @returns a DataArray or null
  68246. */
  68247. getData(): Nullable<DataArray>;
  68248. /**
  68249. * Gets underlying native buffer
  68250. * @returns underlying native buffer
  68251. */
  68252. getBuffer(): Nullable<DataBuffer>;
  68253. /**
  68254. * Gets the stride in float32 units (i.e. byte stride / 4).
  68255. * May not be an integer if the byte stride is not divisible by 4.
  68256. * DEPRECATED. Use byteStride instead.
  68257. * @returns the stride in float32 units
  68258. */
  68259. getStrideSize(): number;
  68260. /**
  68261. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68262. * @param data defines the data to store
  68263. */
  68264. create(data?: Nullable<DataArray>): void;
  68265. /** @hidden */
  68266. _rebuild(): void;
  68267. /**
  68268. * Update current buffer data
  68269. * @param data defines the data to store
  68270. */
  68271. update(data: DataArray): void;
  68272. /**
  68273. * Updates the data directly.
  68274. * @param data the new data
  68275. * @param offset the new offset
  68276. * @param vertexCount the vertex count (optional)
  68277. * @param useBytes set to true if the offset is in bytes
  68278. */
  68279. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68280. /**
  68281. * Release all resources
  68282. */
  68283. dispose(): void;
  68284. }
  68285. /**
  68286. * Specialized buffer used to store vertex data
  68287. */
  68288. export class VertexBuffer {
  68289. /** @hidden */
  68290. _buffer: Buffer;
  68291. private _kind;
  68292. private _size;
  68293. private _ownsBuffer;
  68294. private _instanced;
  68295. private _instanceDivisor;
  68296. /**
  68297. * The byte type.
  68298. */
  68299. static readonly BYTE: number;
  68300. /**
  68301. * The unsigned byte type.
  68302. */
  68303. static readonly UNSIGNED_BYTE: number;
  68304. /**
  68305. * The short type.
  68306. */
  68307. static readonly SHORT: number;
  68308. /**
  68309. * The unsigned short type.
  68310. */
  68311. static readonly UNSIGNED_SHORT: number;
  68312. /**
  68313. * The integer type.
  68314. */
  68315. static readonly INT: number;
  68316. /**
  68317. * The unsigned integer type.
  68318. */
  68319. static readonly UNSIGNED_INT: number;
  68320. /**
  68321. * The float type.
  68322. */
  68323. static readonly FLOAT: number;
  68324. /**
  68325. * Gets or sets the instance divisor when in instanced mode
  68326. */
  68327. instanceDivisor: number;
  68328. /**
  68329. * Gets the byte stride.
  68330. */
  68331. readonly byteStride: number;
  68332. /**
  68333. * Gets the byte offset.
  68334. */
  68335. readonly byteOffset: number;
  68336. /**
  68337. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68338. */
  68339. readonly normalized: boolean;
  68340. /**
  68341. * Gets the data type of each component in the array.
  68342. */
  68343. readonly type: number;
  68344. /**
  68345. * Constructor
  68346. * @param engine the engine
  68347. * @param data the data to use for this vertex buffer
  68348. * @param kind the vertex buffer kind
  68349. * @param updatable whether the data is updatable
  68350. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68351. * @param stride the stride (optional)
  68352. * @param instanced whether the buffer is instanced (optional)
  68353. * @param offset the offset of the data (optional)
  68354. * @param size the number of components (optional)
  68355. * @param type the type of the component (optional)
  68356. * @param normalized whether the data contains normalized data (optional)
  68357. * @param useBytes set to true if stride and offset are in bytes (optional)
  68358. */
  68359. 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);
  68360. /** @hidden */
  68361. _rebuild(): void;
  68362. /**
  68363. * Returns the kind of the VertexBuffer (string)
  68364. * @returns a string
  68365. */
  68366. getKind(): string;
  68367. /**
  68368. * Gets a boolean indicating if the VertexBuffer is updatable?
  68369. * @returns true if the buffer is updatable
  68370. */
  68371. isUpdatable(): boolean;
  68372. /**
  68373. * Gets current buffer's data
  68374. * @returns a DataArray or null
  68375. */
  68376. getData(): Nullable<DataArray>;
  68377. /**
  68378. * Gets underlying native buffer
  68379. * @returns underlying native buffer
  68380. */
  68381. getBuffer(): Nullable<DataBuffer>;
  68382. /**
  68383. * Gets the stride in float32 units (i.e. byte stride / 4).
  68384. * May not be an integer if the byte stride is not divisible by 4.
  68385. * DEPRECATED. Use byteStride instead.
  68386. * @returns the stride in float32 units
  68387. */
  68388. getStrideSize(): number;
  68389. /**
  68390. * Returns the offset as a multiple of the type byte length.
  68391. * DEPRECATED. Use byteOffset instead.
  68392. * @returns the offset in bytes
  68393. */
  68394. getOffset(): number;
  68395. /**
  68396. * Returns the number of components per vertex attribute (integer)
  68397. * @returns the size in float
  68398. */
  68399. getSize(): number;
  68400. /**
  68401. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68402. * @returns true if this buffer is instanced
  68403. */
  68404. getIsInstanced(): boolean;
  68405. /**
  68406. * Returns the instancing divisor, zero for non-instanced (integer).
  68407. * @returns a number
  68408. */
  68409. getInstanceDivisor(): number;
  68410. /**
  68411. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68412. * @param data defines the data to store
  68413. */
  68414. create(data?: DataArray): void;
  68415. /**
  68416. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68417. * This function will create a new buffer if the current one is not updatable
  68418. * @param data defines the data to store
  68419. */
  68420. update(data: DataArray): void;
  68421. /**
  68422. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68423. * Returns the directly updated WebGLBuffer.
  68424. * @param data the new data
  68425. * @param offset the new offset
  68426. * @param useBytes set to true if the offset is in bytes
  68427. */
  68428. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68429. /**
  68430. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68431. */
  68432. dispose(): void;
  68433. /**
  68434. * Enumerates each value of this vertex buffer as numbers.
  68435. * @param count the number of values to enumerate
  68436. * @param callback the callback function called for each value
  68437. */
  68438. forEach(count: number, callback: (value: number, index: number) => void): void;
  68439. /**
  68440. * Positions
  68441. */
  68442. static readonly PositionKind: string;
  68443. /**
  68444. * Normals
  68445. */
  68446. static readonly NormalKind: string;
  68447. /**
  68448. * Tangents
  68449. */
  68450. static readonly TangentKind: string;
  68451. /**
  68452. * Texture coordinates
  68453. */
  68454. static readonly UVKind: string;
  68455. /**
  68456. * Texture coordinates 2
  68457. */
  68458. static readonly UV2Kind: string;
  68459. /**
  68460. * Texture coordinates 3
  68461. */
  68462. static readonly UV3Kind: string;
  68463. /**
  68464. * Texture coordinates 4
  68465. */
  68466. static readonly UV4Kind: string;
  68467. /**
  68468. * Texture coordinates 5
  68469. */
  68470. static readonly UV5Kind: string;
  68471. /**
  68472. * Texture coordinates 6
  68473. */
  68474. static readonly UV6Kind: string;
  68475. /**
  68476. * Colors
  68477. */
  68478. static readonly ColorKind: string;
  68479. /**
  68480. * Matrix indices (for bones)
  68481. */
  68482. static readonly MatricesIndicesKind: string;
  68483. /**
  68484. * Matrix weights (for bones)
  68485. */
  68486. static readonly MatricesWeightsKind: string;
  68487. /**
  68488. * Additional matrix indices (for bones)
  68489. */
  68490. static readonly MatricesIndicesExtraKind: string;
  68491. /**
  68492. * Additional matrix weights (for bones)
  68493. */
  68494. static readonly MatricesWeightsExtraKind: string;
  68495. /**
  68496. * Deduces the stride given a kind.
  68497. * @param kind The kind string to deduce
  68498. * @returns The deduced stride
  68499. */
  68500. static DeduceStride(kind: string): number;
  68501. /**
  68502. * Gets the byte length of the given type.
  68503. * @param type the type
  68504. * @returns the number of bytes
  68505. */
  68506. static GetTypeByteLength(type: number): number;
  68507. /**
  68508. * Enumerates each value of the given parameters as numbers.
  68509. * @param data the data to enumerate
  68510. * @param byteOffset the byte offset of the data
  68511. * @param byteStride the byte stride of the data
  68512. * @param componentCount the number of components per element
  68513. * @param componentType the type of the component
  68514. * @param count the total number of components
  68515. * @param normalized whether the data is normalized
  68516. * @param callback the callback function called for each value
  68517. */
  68518. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68519. private static _GetFloatValue;
  68520. }
  68521. }
  68522. declare module BABYLON {
  68523. /**
  68524. * Class representing spherical harmonics coefficients to the 3rd degree
  68525. */
  68526. export class SphericalHarmonics {
  68527. /**
  68528. * Defines whether or not the harmonics have been prescaled for rendering.
  68529. */
  68530. preScaled: boolean;
  68531. /**
  68532. * The l0,0 coefficients of the spherical harmonics
  68533. */
  68534. l00: Vector3;
  68535. /**
  68536. * The l1,-1 coefficients of the spherical harmonics
  68537. */
  68538. l1_1: Vector3;
  68539. /**
  68540. * The l1,0 coefficients of the spherical harmonics
  68541. */
  68542. l10: Vector3;
  68543. /**
  68544. * The l1,1 coefficients of the spherical harmonics
  68545. */
  68546. l11: Vector3;
  68547. /**
  68548. * The l2,-2 coefficients of the spherical harmonics
  68549. */
  68550. l2_2: Vector3;
  68551. /**
  68552. * The l2,-1 coefficients of the spherical harmonics
  68553. */
  68554. l2_1: Vector3;
  68555. /**
  68556. * The l2,0 coefficients of the spherical harmonics
  68557. */
  68558. l20: Vector3;
  68559. /**
  68560. * The l2,1 coefficients of the spherical harmonics
  68561. */
  68562. l21: Vector3;
  68563. /**
  68564. * The l2,2 coefficients of the spherical harmonics
  68565. */
  68566. l22: Vector3;
  68567. /**
  68568. * Adds a light to the spherical harmonics
  68569. * @param direction the direction of the light
  68570. * @param color the color of the light
  68571. * @param deltaSolidAngle the delta solid angle of the light
  68572. */
  68573. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68574. /**
  68575. * Scales the spherical harmonics by the given amount
  68576. * @param scale the amount to scale
  68577. */
  68578. scaleInPlace(scale: number): void;
  68579. /**
  68580. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68581. *
  68582. * ```
  68583. * E_lm = A_l * L_lm
  68584. * ```
  68585. *
  68586. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68587. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68588. * the scaling factors are given in equation 9.
  68589. */
  68590. convertIncidentRadianceToIrradiance(): void;
  68591. /**
  68592. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68593. *
  68594. * ```
  68595. * L = (1/pi) * E * rho
  68596. * ```
  68597. *
  68598. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68599. */
  68600. convertIrradianceToLambertianRadiance(): void;
  68601. /**
  68602. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68603. * required operations at run time.
  68604. *
  68605. * This is simply done by scaling back the SH with Ylm constants parameter.
  68606. * The trigonometric part being applied by the shader at run time.
  68607. */
  68608. preScaleForRendering(): void;
  68609. /**
  68610. * Constructs a spherical harmonics from an array.
  68611. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68612. * @returns the spherical harmonics
  68613. */
  68614. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68615. /**
  68616. * Gets the spherical harmonics from polynomial
  68617. * @param polynomial the spherical polynomial
  68618. * @returns the spherical harmonics
  68619. */
  68620. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68621. }
  68622. /**
  68623. * Class representing spherical polynomial coefficients to the 3rd degree
  68624. */
  68625. export class SphericalPolynomial {
  68626. private _harmonics;
  68627. /**
  68628. * The spherical harmonics used to create the polynomials.
  68629. */
  68630. readonly preScaledHarmonics: SphericalHarmonics;
  68631. /**
  68632. * The x coefficients of the spherical polynomial
  68633. */
  68634. x: Vector3;
  68635. /**
  68636. * The y coefficients of the spherical polynomial
  68637. */
  68638. y: Vector3;
  68639. /**
  68640. * The z coefficients of the spherical polynomial
  68641. */
  68642. z: Vector3;
  68643. /**
  68644. * The xx coefficients of the spherical polynomial
  68645. */
  68646. xx: Vector3;
  68647. /**
  68648. * The yy coefficients of the spherical polynomial
  68649. */
  68650. yy: Vector3;
  68651. /**
  68652. * The zz coefficients of the spherical polynomial
  68653. */
  68654. zz: Vector3;
  68655. /**
  68656. * The xy coefficients of the spherical polynomial
  68657. */
  68658. xy: Vector3;
  68659. /**
  68660. * The yz coefficients of the spherical polynomial
  68661. */
  68662. yz: Vector3;
  68663. /**
  68664. * The zx coefficients of the spherical polynomial
  68665. */
  68666. zx: Vector3;
  68667. /**
  68668. * Adds an ambient color to the spherical polynomial
  68669. * @param color the color to add
  68670. */
  68671. addAmbient(color: Color3): void;
  68672. /**
  68673. * Scales the spherical polynomial by the given amount
  68674. * @param scale the amount to scale
  68675. */
  68676. scaleInPlace(scale: number): void;
  68677. /**
  68678. * Gets the spherical polynomial from harmonics
  68679. * @param harmonics the spherical harmonics
  68680. * @returns the spherical polynomial
  68681. */
  68682. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68683. /**
  68684. * Constructs a spherical polynomial from an array.
  68685. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68686. * @returns the spherical polynomial
  68687. */
  68688. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68689. }
  68690. }
  68691. declare module BABYLON {
  68692. /**
  68693. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68694. */
  68695. export interface CubeMapInfo {
  68696. /**
  68697. * The pixel array for the front face.
  68698. * This is stored in format, left to right, up to down format.
  68699. */
  68700. front: Nullable<ArrayBufferView>;
  68701. /**
  68702. * The pixel array for the back face.
  68703. * This is stored in format, left to right, up to down format.
  68704. */
  68705. back: Nullable<ArrayBufferView>;
  68706. /**
  68707. * The pixel array for the left face.
  68708. * This is stored in format, left to right, up to down format.
  68709. */
  68710. left: Nullable<ArrayBufferView>;
  68711. /**
  68712. * The pixel array for the right face.
  68713. * This is stored in format, left to right, up to down format.
  68714. */
  68715. right: Nullable<ArrayBufferView>;
  68716. /**
  68717. * The pixel array for the up face.
  68718. * This is stored in format, left to right, up to down format.
  68719. */
  68720. up: Nullable<ArrayBufferView>;
  68721. /**
  68722. * The pixel array for the down face.
  68723. * This is stored in format, left to right, up to down format.
  68724. */
  68725. down: Nullable<ArrayBufferView>;
  68726. /**
  68727. * The size of the cubemap stored.
  68728. *
  68729. * Each faces will be size * size pixels.
  68730. */
  68731. size: number;
  68732. /**
  68733. * The format of the texture.
  68734. *
  68735. * RGBA, RGB.
  68736. */
  68737. format: number;
  68738. /**
  68739. * The type of the texture data.
  68740. *
  68741. * UNSIGNED_INT, FLOAT.
  68742. */
  68743. type: number;
  68744. /**
  68745. * Specifies whether the texture is in gamma space.
  68746. */
  68747. gammaSpace: boolean;
  68748. }
  68749. /**
  68750. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68751. */
  68752. export class PanoramaToCubeMapTools {
  68753. private static FACE_FRONT;
  68754. private static FACE_BACK;
  68755. private static FACE_RIGHT;
  68756. private static FACE_LEFT;
  68757. private static FACE_DOWN;
  68758. private static FACE_UP;
  68759. /**
  68760. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68761. *
  68762. * @param float32Array The source data.
  68763. * @param inputWidth The width of the input panorama.
  68764. * @param inputHeight The height of the input panorama.
  68765. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68766. * @return The cubemap data
  68767. */
  68768. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68769. private static CreateCubemapTexture;
  68770. private static CalcProjectionSpherical;
  68771. }
  68772. }
  68773. declare module BABYLON {
  68774. /**
  68775. * Helper class dealing with the extraction of spherical polynomial dataArray
  68776. * from a cube map.
  68777. */
  68778. export class CubeMapToSphericalPolynomialTools {
  68779. private static FileFaces;
  68780. /**
  68781. * Converts a texture to the according Spherical Polynomial data.
  68782. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68783. *
  68784. * @param texture The texture to extract the information from.
  68785. * @return The Spherical Polynomial data.
  68786. */
  68787. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68788. /**
  68789. * Converts a cubemap to the according Spherical Polynomial data.
  68790. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68791. *
  68792. * @param cubeInfo The Cube map to extract the information from.
  68793. * @return The Spherical Polynomial data.
  68794. */
  68795. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68796. }
  68797. }
  68798. declare module BABYLON {
  68799. /**
  68800. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68801. * during the life time of the application.
  68802. */
  68803. export class EngineStore {
  68804. /** Gets the list of created engines */
  68805. static Instances: Engine[];
  68806. /** @hidden */
  68807. static _LastCreatedScene: Nullable<Scene>;
  68808. /**
  68809. * Gets the latest created engine
  68810. */
  68811. static readonly LastCreatedEngine: Nullable<Engine>;
  68812. /**
  68813. * Gets the latest created scene
  68814. */
  68815. static readonly LastCreatedScene: Nullable<Scene>;
  68816. }
  68817. }
  68818. declare module BABYLON {
  68819. /**
  68820. * Define options used to create a render target texture
  68821. */
  68822. export class RenderTargetCreationOptions {
  68823. /**
  68824. * Specifies is mipmaps must be generated
  68825. */
  68826. generateMipMaps?: boolean;
  68827. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68828. generateDepthBuffer?: boolean;
  68829. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68830. generateStencilBuffer?: boolean;
  68831. /** Defines texture type (int by default) */
  68832. type?: number;
  68833. /** Defines sampling mode (trilinear by default) */
  68834. samplingMode?: number;
  68835. /** Defines format (RGBA by default) */
  68836. format?: number;
  68837. }
  68838. }
  68839. declare module BABYLON {
  68840. /**
  68841. * @hidden
  68842. **/
  68843. export class _AlphaState {
  68844. private _isAlphaBlendDirty;
  68845. private _isBlendFunctionParametersDirty;
  68846. private _isBlendEquationParametersDirty;
  68847. private _isBlendConstantsDirty;
  68848. private _alphaBlend;
  68849. private _blendFunctionParameters;
  68850. private _blendEquationParameters;
  68851. private _blendConstants;
  68852. /**
  68853. * Initializes the state.
  68854. */
  68855. constructor();
  68856. readonly isDirty: boolean;
  68857. alphaBlend: boolean;
  68858. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68859. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68860. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68861. reset(): void;
  68862. apply(gl: WebGLRenderingContext): void;
  68863. }
  68864. }
  68865. declare module BABYLON {
  68866. /**
  68867. * @hidden
  68868. **/
  68869. export class _DepthCullingState {
  68870. private _isDepthTestDirty;
  68871. private _isDepthMaskDirty;
  68872. private _isDepthFuncDirty;
  68873. private _isCullFaceDirty;
  68874. private _isCullDirty;
  68875. private _isZOffsetDirty;
  68876. private _isFrontFaceDirty;
  68877. private _depthTest;
  68878. private _depthMask;
  68879. private _depthFunc;
  68880. private _cull;
  68881. private _cullFace;
  68882. private _zOffset;
  68883. private _frontFace;
  68884. /**
  68885. * Initializes the state.
  68886. */
  68887. constructor();
  68888. readonly isDirty: boolean;
  68889. zOffset: number;
  68890. cullFace: Nullable<number>;
  68891. cull: Nullable<boolean>;
  68892. depthFunc: Nullable<number>;
  68893. depthMask: boolean;
  68894. depthTest: boolean;
  68895. frontFace: Nullable<number>;
  68896. reset(): void;
  68897. apply(gl: WebGLRenderingContext): void;
  68898. }
  68899. }
  68900. declare module BABYLON {
  68901. /**
  68902. * @hidden
  68903. **/
  68904. export class _StencilState {
  68905. /** 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 */
  68906. static readonly ALWAYS: number;
  68907. /** Passed to stencilOperation to specify that stencil value must be kept */
  68908. static readonly KEEP: number;
  68909. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68910. static readonly REPLACE: number;
  68911. private _isStencilTestDirty;
  68912. private _isStencilMaskDirty;
  68913. private _isStencilFuncDirty;
  68914. private _isStencilOpDirty;
  68915. private _stencilTest;
  68916. private _stencilMask;
  68917. private _stencilFunc;
  68918. private _stencilFuncRef;
  68919. private _stencilFuncMask;
  68920. private _stencilOpStencilFail;
  68921. private _stencilOpDepthFail;
  68922. private _stencilOpStencilDepthPass;
  68923. readonly isDirty: boolean;
  68924. stencilFunc: number;
  68925. stencilFuncRef: number;
  68926. stencilFuncMask: number;
  68927. stencilOpStencilFail: number;
  68928. stencilOpDepthFail: number;
  68929. stencilOpStencilDepthPass: number;
  68930. stencilMask: number;
  68931. stencilTest: boolean;
  68932. constructor();
  68933. reset(): void;
  68934. apply(gl: WebGLRenderingContext): void;
  68935. }
  68936. }
  68937. declare module BABYLON {
  68938. /**
  68939. * @hidden
  68940. **/
  68941. export class _TimeToken {
  68942. _startTimeQuery: Nullable<WebGLQuery>;
  68943. _endTimeQuery: Nullable<WebGLQuery>;
  68944. _timeElapsedQuery: Nullable<WebGLQuery>;
  68945. _timeElapsedQueryEnded: boolean;
  68946. }
  68947. }
  68948. declare module BABYLON {
  68949. /**
  68950. * Class used to store data associated with WebGL texture data for the engine
  68951. * This class should not be used directly
  68952. */
  68953. export class InternalTexture {
  68954. /** @hidden */
  68955. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  68956. /**
  68957. * The source of the texture data is unknown
  68958. */
  68959. static DATASOURCE_UNKNOWN: number;
  68960. /**
  68961. * Texture data comes from an URL
  68962. */
  68963. static DATASOURCE_URL: number;
  68964. /**
  68965. * Texture data is only used for temporary storage
  68966. */
  68967. static DATASOURCE_TEMP: number;
  68968. /**
  68969. * Texture data comes from raw data (ArrayBuffer)
  68970. */
  68971. static DATASOURCE_RAW: number;
  68972. /**
  68973. * Texture content is dynamic (video or dynamic texture)
  68974. */
  68975. static DATASOURCE_DYNAMIC: number;
  68976. /**
  68977. * Texture content is generated by rendering to it
  68978. */
  68979. static DATASOURCE_RENDERTARGET: number;
  68980. /**
  68981. * Texture content is part of a multi render target process
  68982. */
  68983. static DATASOURCE_MULTIRENDERTARGET: number;
  68984. /**
  68985. * Texture data comes from a cube data file
  68986. */
  68987. static DATASOURCE_CUBE: number;
  68988. /**
  68989. * Texture data comes from a raw cube data
  68990. */
  68991. static DATASOURCE_CUBERAW: number;
  68992. /**
  68993. * Texture data come from a prefiltered cube data file
  68994. */
  68995. static DATASOURCE_CUBEPREFILTERED: number;
  68996. /**
  68997. * Texture content is raw 3D data
  68998. */
  68999. static DATASOURCE_RAW3D: number;
  69000. /**
  69001. * Texture content is a depth texture
  69002. */
  69003. static DATASOURCE_DEPTHTEXTURE: number;
  69004. /**
  69005. * Texture data comes from a raw cube data encoded with RGBD
  69006. */
  69007. static DATASOURCE_CUBERAW_RGBD: number;
  69008. /**
  69009. * Defines if the texture is ready
  69010. */
  69011. isReady: boolean;
  69012. /**
  69013. * Defines if the texture is a cube texture
  69014. */
  69015. isCube: boolean;
  69016. /**
  69017. * Defines if the texture contains 3D data
  69018. */
  69019. is3D: boolean;
  69020. /**
  69021. * Defines if the texture contains multiview data
  69022. */
  69023. isMultiview: boolean;
  69024. /**
  69025. * Gets the URL used to load this texture
  69026. */
  69027. url: string;
  69028. /**
  69029. * Gets the sampling mode of the texture
  69030. */
  69031. samplingMode: number;
  69032. /**
  69033. * Gets a boolean indicating if the texture needs mipmaps generation
  69034. */
  69035. generateMipMaps: boolean;
  69036. /**
  69037. * Gets the number of samples used by the texture (WebGL2+ only)
  69038. */
  69039. samples: number;
  69040. /**
  69041. * Gets the type of the texture (int, float...)
  69042. */
  69043. type: number;
  69044. /**
  69045. * Gets the format of the texture (RGB, RGBA...)
  69046. */
  69047. format: number;
  69048. /**
  69049. * Observable called when the texture is loaded
  69050. */
  69051. onLoadedObservable: Observable<InternalTexture>;
  69052. /**
  69053. * Gets the width of the texture
  69054. */
  69055. width: number;
  69056. /**
  69057. * Gets the height of the texture
  69058. */
  69059. height: number;
  69060. /**
  69061. * Gets the depth of the texture
  69062. */
  69063. depth: number;
  69064. /**
  69065. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69066. */
  69067. baseWidth: number;
  69068. /**
  69069. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69070. */
  69071. baseHeight: number;
  69072. /**
  69073. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69074. */
  69075. baseDepth: number;
  69076. /**
  69077. * Gets a boolean indicating if the texture is inverted on Y axis
  69078. */
  69079. invertY: boolean;
  69080. /** @hidden */
  69081. _invertVScale: boolean;
  69082. /** @hidden */
  69083. _associatedChannel: number;
  69084. /** @hidden */
  69085. _dataSource: number;
  69086. /** @hidden */
  69087. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69088. /** @hidden */
  69089. _bufferView: Nullable<ArrayBufferView>;
  69090. /** @hidden */
  69091. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69092. /** @hidden */
  69093. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69094. /** @hidden */
  69095. _size: number;
  69096. /** @hidden */
  69097. _extension: string;
  69098. /** @hidden */
  69099. _files: Nullable<string[]>;
  69100. /** @hidden */
  69101. _workingCanvas: Nullable<HTMLCanvasElement>;
  69102. /** @hidden */
  69103. _workingContext: Nullable<CanvasRenderingContext2D>;
  69104. /** @hidden */
  69105. _framebuffer: Nullable<WebGLFramebuffer>;
  69106. /** @hidden */
  69107. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69108. /** @hidden */
  69109. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69110. /** @hidden */
  69111. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69112. /** @hidden */
  69113. _attachments: Nullable<number[]>;
  69114. /** @hidden */
  69115. _cachedCoordinatesMode: Nullable<number>;
  69116. /** @hidden */
  69117. _cachedWrapU: Nullable<number>;
  69118. /** @hidden */
  69119. _cachedWrapV: Nullable<number>;
  69120. /** @hidden */
  69121. _cachedWrapR: Nullable<number>;
  69122. /** @hidden */
  69123. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69124. /** @hidden */
  69125. _isDisabled: boolean;
  69126. /** @hidden */
  69127. _compression: Nullable<string>;
  69128. /** @hidden */
  69129. _generateStencilBuffer: boolean;
  69130. /** @hidden */
  69131. _generateDepthBuffer: boolean;
  69132. /** @hidden */
  69133. _comparisonFunction: number;
  69134. /** @hidden */
  69135. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69136. /** @hidden */
  69137. _lodGenerationScale: number;
  69138. /** @hidden */
  69139. _lodGenerationOffset: number;
  69140. /** @hidden */
  69141. _colorTextureArray: Nullable<WebGLTexture>;
  69142. /** @hidden */
  69143. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69144. /** @hidden */
  69145. _lodTextureHigh: Nullable<BaseTexture>;
  69146. /** @hidden */
  69147. _lodTextureMid: Nullable<BaseTexture>;
  69148. /** @hidden */
  69149. _lodTextureLow: Nullable<BaseTexture>;
  69150. /** @hidden */
  69151. _isRGBD: boolean;
  69152. /** @hidden */
  69153. _linearSpecularLOD: boolean;
  69154. /** @hidden */
  69155. _irradianceTexture: Nullable<BaseTexture>;
  69156. /** @hidden */
  69157. _webGLTexture: Nullable<WebGLTexture>;
  69158. /** @hidden */
  69159. _references: number;
  69160. private _engine;
  69161. /**
  69162. * Gets the Engine the texture belongs to.
  69163. * @returns The babylon engine
  69164. */
  69165. getEngine(): Engine;
  69166. /**
  69167. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69168. */
  69169. readonly dataSource: number;
  69170. /**
  69171. * Creates a new InternalTexture
  69172. * @param engine defines the engine to use
  69173. * @param dataSource defines the type of data that will be used
  69174. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69175. */
  69176. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69177. /**
  69178. * Increments the number of references (ie. the number of Texture that point to it)
  69179. */
  69180. incrementReferences(): void;
  69181. /**
  69182. * Change the size of the texture (not the size of the content)
  69183. * @param width defines the new width
  69184. * @param height defines the new height
  69185. * @param depth defines the new depth (1 by default)
  69186. */
  69187. updateSize(width: int, height: int, depth?: int): void;
  69188. /** @hidden */
  69189. _rebuild(): void;
  69190. /** @hidden */
  69191. _swapAndDie(target: InternalTexture): void;
  69192. /**
  69193. * Dispose the current allocated resources
  69194. */
  69195. dispose(): void;
  69196. }
  69197. }
  69198. declare module BABYLON {
  69199. /**
  69200. * This represents the main contract an easing function should follow.
  69201. * Easing functions are used throughout the animation system.
  69202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69203. */
  69204. export interface IEasingFunction {
  69205. /**
  69206. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69207. * of the easing function.
  69208. * The link below provides some of the most common examples of easing functions.
  69209. * @see https://easings.net/
  69210. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69211. * @returns the corresponding value on the curve defined by the easing function
  69212. */
  69213. ease(gradient: number): number;
  69214. }
  69215. /**
  69216. * Base class used for every default easing function.
  69217. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69218. */
  69219. export class EasingFunction implements IEasingFunction {
  69220. /**
  69221. * Interpolation follows the mathematical formula associated with the easing function.
  69222. */
  69223. static readonly EASINGMODE_EASEIN: number;
  69224. /**
  69225. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69226. */
  69227. static readonly EASINGMODE_EASEOUT: number;
  69228. /**
  69229. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69230. */
  69231. static readonly EASINGMODE_EASEINOUT: number;
  69232. private _easingMode;
  69233. /**
  69234. * Sets the easing mode of the current function.
  69235. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69236. */
  69237. setEasingMode(easingMode: number): void;
  69238. /**
  69239. * Gets the current easing mode.
  69240. * @returns the easing mode
  69241. */
  69242. getEasingMode(): number;
  69243. /**
  69244. * @hidden
  69245. */
  69246. easeInCore(gradient: number): number;
  69247. /**
  69248. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69249. * of the easing function.
  69250. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69251. * @returns the corresponding value on the curve defined by the easing function
  69252. */
  69253. ease(gradient: number): number;
  69254. }
  69255. /**
  69256. * Easing function with a circle shape (see link below).
  69257. * @see https://easings.net/#easeInCirc
  69258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69259. */
  69260. export class CircleEase extends EasingFunction implements IEasingFunction {
  69261. /** @hidden */
  69262. easeInCore(gradient: number): number;
  69263. }
  69264. /**
  69265. * Easing function with a ease back shape (see link below).
  69266. * @see https://easings.net/#easeInBack
  69267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69268. */
  69269. export class BackEase extends EasingFunction implements IEasingFunction {
  69270. /** Defines the amplitude of the function */
  69271. amplitude: number;
  69272. /**
  69273. * Instantiates a back ease easing
  69274. * @see https://easings.net/#easeInBack
  69275. * @param amplitude Defines the amplitude of the function
  69276. */
  69277. constructor(
  69278. /** Defines the amplitude of the function */
  69279. amplitude?: number);
  69280. /** @hidden */
  69281. easeInCore(gradient: number): number;
  69282. }
  69283. /**
  69284. * Easing function with a bouncing shape (see link below).
  69285. * @see https://easings.net/#easeInBounce
  69286. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69287. */
  69288. export class BounceEase extends EasingFunction implements IEasingFunction {
  69289. /** Defines the number of bounces */
  69290. bounces: number;
  69291. /** Defines the amplitude of the bounce */
  69292. bounciness: number;
  69293. /**
  69294. * Instantiates a bounce easing
  69295. * @see https://easings.net/#easeInBounce
  69296. * @param bounces Defines the number of bounces
  69297. * @param bounciness Defines the amplitude of the bounce
  69298. */
  69299. constructor(
  69300. /** Defines the number of bounces */
  69301. bounces?: number,
  69302. /** Defines the amplitude of the bounce */
  69303. bounciness?: number);
  69304. /** @hidden */
  69305. easeInCore(gradient: number): number;
  69306. }
  69307. /**
  69308. * Easing function with a power of 3 shape (see link below).
  69309. * @see https://easings.net/#easeInCubic
  69310. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69311. */
  69312. export class CubicEase extends EasingFunction implements IEasingFunction {
  69313. /** @hidden */
  69314. easeInCore(gradient: number): number;
  69315. }
  69316. /**
  69317. * Easing function with an elastic shape (see link below).
  69318. * @see https://easings.net/#easeInElastic
  69319. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69320. */
  69321. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69322. /** Defines the number of oscillations*/
  69323. oscillations: number;
  69324. /** Defines the amplitude of the oscillations*/
  69325. springiness: number;
  69326. /**
  69327. * Instantiates an elastic easing function
  69328. * @see https://easings.net/#easeInElastic
  69329. * @param oscillations Defines the number of oscillations
  69330. * @param springiness Defines the amplitude of the oscillations
  69331. */
  69332. constructor(
  69333. /** Defines the number of oscillations*/
  69334. oscillations?: number,
  69335. /** Defines the amplitude of the oscillations*/
  69336. springiness?: number);
  69337. /** @hidden */
  69338. easeInCore(gradient: number): number;
  69339. }
  69340. /**
  69341. * Easing function with an exponential shape (see link below).
  69342. * @see https://easings.net/#easeInExpo
  69343. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69344. */
  69345. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69346. /** Defines the exponent of the function */
  69347. exponent: number;
  69348. /**
  69349. * Instantiates an exponential easing function
  69350. * @see https://easings.net/#easeInExpo
  69351. * @param exponent Defines the exponent of the function
  69352. */
  69353. constructor(
  69354. /** Defines the exponent of the function */
  69355. exponent?: number);
  69356. /** @hidden */
  69357. easeInCore(gradient: number): number;
  69358. }
  69359. /**
  69360. * Easing function with a power shape (see link below).
  69361. * @see https://easings.net/#easeInQuad
  69362. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69363. */
  69364. export class PowerEase extends EasingFunction implements IEasingFunction {
  69365. /** Defines the power of the function */
  69366. power: number;
  69367. /**
  69368. * Instantiates an power base easing function
  69369. * @see https://easings.net/#easeInQuad
  69370. * @param power Defines the power of the function
  69371. */
  69372. constructor(
  69373. /** Defines the power of the function */
  69374. power?: number);
  69375. /** @hidden */
  69376. easeInCore(gradient: number): number;
  69377. }
  69378. /**
  69379. * Easing function with a power of 2 shape (see link below).
  69380. * @see https://easings.net/#easeInQuad
  69381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69382. */
  69383. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69384. /** @hidden */
  69385. easeInCore(gradient: number): number;
  69386. }
  69387. /**
  69388. * Easing function with a power of 4 shape (see link below).
  69389. * @see https://easings.net/#easeInQuart
  69390. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69391. */
  69392. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69393. /** @hidden */
  69394. easeInCore(gradient: number): number;
  69395. }
  69396. /**
  69397. * Easing function with a power of 5 shape (see link below).
  69398. * @see https://easings.net/#easeInQuint
  69399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69400. */
  69401. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69402. /** @hidden */
  69403. easeInCore(gradient: number): number;
  69404. }
  69405. /**
  69406. * Easing function with a sin shape (see link below).
  69407. * @see https://easings.net/#easeInSine
  69408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69409. */
  69410. export class SineEase extends EasingFunction implements IEasingFunction {
  69411. /** @hidden */
  69412. easeInCore(gradient: number): number;
  69413. }
  69414. /**
  69415. * Easing function with a bezier shape (see link below).
  69416. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69417. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69418. */
  69419. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69420. /** Defines the x component of the start tangent in the bezier curve */
  69421. x1: number;
  69422. /** Defines the y component of the start tangent in the bezier curve */
  69423. y1: number;
  69424. /** Defines the x component of the end tangent in the bezier curve */
  69425. x2: number;
  69426. /** Defines the y component of the end tangent in the bezier curve */
  69427. y2: number;
  69428. /**
  69429. * Instantiates a bezier function
  69430. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69431. * @param x1 Defines the x component of the start tangent in the bezier curve
  69432. * @param y1 Defines the y component of the start tangent in the bezier curve
  69433. * @param x2 Defines the x component of the end tangent in the bezier curve
  69434. * @param y2 Defines the y component of the end tangent in the bezier curve
  69435. */
  69436. constructor(
  69437. /** Defines the x component of the start tangent in the bezier curve */
  69438. x1?: number,
  69439. /** Defines the y component of the start tangent in the bezier curve */
  69440. y1?: number,
  69441. /** Defines the x component of the end tangent in the bezier curve */
  69442. x2?: number,
  69443. /** Defines the y component of the end tangent in the bezier curve */
  69444. y2?: number);
  69445. /** @hidden */
  69446. easeInCore(gradient: number): number;
  69447. }
  69448. }
  69449. declare module BABYLON {
  69450. /**
  69451. * Defines an interface which represents an animation key frame
  69452. */
  69453. export interface IAnimationKey {
  69454. /**
  69455. * Frame of the key frame
  69456. */
  69457. frame: number;
  69458. /**
  69459. * Value at the specifies key frame
  69460. */
  69461. value: any;
  69462. /**
  69463. * The input tangent for the cubic hermite spline
  69464. */
  69465. inTangent?: any;
  69466. /**
  69467. * The output tangent for the cubic hermite spline
  69468. */
  69469. outTangent?: any;
  69470. /**
  69471. * The animation interpolation type
  69472. */
  69473. interpolation?: AnimationKeyInterpolation;
  69474. }
  69475. /**
  69476. * Enum for the animation key frame interpolation type
  69477. */
  69478. export enum AnimationKeyInterpolation {
  69479. /**
  69480. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69481. */
  69482. STEP = 1
  69483. }
  69484. }
  69485. declare module BABYLON {
  69486. /**
  69487. * Represents the range of an animation
  69488. */
  69489. export class AnimationRange {
  69490. /**The name of the animation range**/
  69491. name: string;
  69492. /**The starting frame of the animation */
  69493. from: number;
  69494. /**The ending frame of the animation*/
  69495. to: number;
  69496. /**
  69497. * Initializes the range of an animation
  69498. * @param name The name of the animation range
  69499. * @param from The starting frame of the animation
  69500. * @param to The ending frame of the animation
  69501. */
  69502. constructor(
  69503. /**The name of the animation range**/
  69504. name: string,
  69505. /**The starting frame of the animation */
  69506. from: number,
  69507. /**The ending frame of the animation*/
  69508. to: number);
  69509. /**
  69510. * Makes a copy of the animation range
  69511. * @returns A copy of the animation range
  69512. */
  69513. clone(): AnimationRange;
  69514. }
  69515. }
  69516. declare module BABYLON {
  69517. /**
  69518. * Composed of a frame, and an action function
  69519. */
  69520. export class AnimationEvent {
  69521. /** The frame for which the event is triggered **/
  69522. frame: number;
  69523. /** The event to perform when triggered **/
  69524. action: (currentFrame: number) => void;
  69525. /** Specifies if the event should be triggered only once**/
  69526. onlyOnce?: boolean | undefined;
  69527. /**
  69528. * Specifies if the animation event is done
  69529. */
  69530. isDone: boolean;
  69531. /**
  69532. * Initializes the animation event
  69533. * @param frame The frame for which the event is triggered
  69534. * @param action The event to perform when triggered
  69535. * @param onlyOnce Specifies if the event should be triggered only once
  69536. */
  69537. constructor(
  69538. /** The frame for which the event is triggered **/
  69539. frame: number,
  69540. /** The event to perform when triggered **/
  69541. action: (currentFrame: number) => void,
  69542. /** Specifies if the event should be triggered only once**/
  69543. onlyOnce?: boolean | undefined);
  69544. /** @hidden */
  69545. _clone(): AnimationEvent;
  69546. }
  69547. }
  69548. declare module BABYLON {
  69549. /**
  69550. * Interface used to define a behavior
  69551. */
  69552. export interface Behavior<T> {
  69553. /** gets or sets behavior's name */
  69554. name: string;
  69555. /**
  69556. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69557. */
  69558. init(): void;
  69559. /**
  69560. * Called when the behavior is attached to a target
  69561. * @param target defines the target where the behavior is attached to
  69562. */
  69563. attach(target: T): void;
  69564. /**
  69565. * Called when the behavior is detached from its target
  69566. */
  69567. detach(): void;
  69568. }
  69569. /**
  69570. * Interface implemented by classes supporting behaviors
  69571. */
  69572. export interface IBehaviorAware<T> {
  69573. /**
  69574. * Attach a behavior
  69575. * @param behavior defines the behavior to attach
  69576. * @returns the current host
  69577. */
  69578. addBehavior(behavior: Behavior<T>): T;
  69579. /**
  69580. * Remove a behavior from the current object
  69581. * @param behavior defines the behavior to detach
  69582. * @returns the current host
  69583. */
  69584. removeBehavior(behavior: Behavior<T>): T;
  69585. /**
  69586. * Gets a behavior using its name to search
  69587. * @param name defines the name to search
  69588. * @returns the behavior or null if not found
  69589. */
  69590. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69591. }
  69592. }
  69593. declare module BABYLON {
  69594. /**
  69595. * @hidden
  69596. */
  69597. export class IntersectionInfo {
  69598. bu: Nullable<number>;
  69599. bv: Nullable<number>;
  69600. distance: number;
  69601. faceId: number;
  69602. subMeshId: number;
  69603. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69604. }
  69605. }
  69606. declare module BABYLON {
  69607. /**
  69608. * Class used to store bounding sphere information
  69609. */
  69610. export class BoundingSphere {
  69611. /**
  69612. * Gets the center of the bounding sphere in local space
  69613. */
  69614. readonly center: Vector3;
  69615. /**
  69616. * Radius of the bounding sphere in local space
  69617. */
  69618. radius: number;
  69619. /**
  69620. * Gets the center of the bounding sphere in world space
  69621. */
  69622. readonly centerWorld: Vector3;
  69623. /**
  69624. * Radius of the bounding sphere in world space
  69625. */
  69626. radiusWorld: number;
  69627. /**
  69628. * Gets the minimum vector in local space
  69629. */
  69630. readonly minimum: Vector3;
  69631. /**
  69632. * Gets the maximum vector in local space
  69633. */
  69634. readonly maximum: Vector3;
  69635. private _worldMatrix;
  69636. private static readonly TmpVector3;
  69637. /**
  69638. * Creates a new bounding sphere
  69639. * @param min defines the minimum vector (in local space)
  69640. * @param max defines the maximum vector (in local space)
  69641. * @param worldMatrix defines the new world matrix
  69642. */
  69643. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69644. /**
  69645. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69646. * @param min defines the new minimum vector (in local space)
  69647. * @param max defines the new maximum vector (in local space)
  69648. * @param worldMatrix defines the new world matrix
  69649. */
  69650. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69651. /**
  69652. * Scale the current bounding sphere by applying a scale factor
  69653. * @param factor defines the scale factor to apply
  69654. * @returns the current bounding box
  69655. */
  69656. scale(factor: number): BoundingSphere;
  69657. /**
  69658. * Gets the world matrix of the bounding box
  69659. * @returns a matrix
  69660. */
  69661. getWorldMatrix(): DeepImmutable<Matrix>;
  69662. /** @hidden */
  69663. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69664. /**
  69665. * Tests if the bounding sphere is intersecting the frustum planes
  69666. * @param frustumPlanes defines the frustum planes to test
  69667. * @returns true if there is an intersection
  69668. */
  69669. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69670. /**
  69671. * Tests if the bounding sphere center is in between the frustum planes.
  69672. * Used for optimistic fast inclusion.
  69673. * @param frustumPlanes defines the frustum planes to test
  69674. * @returns true if the sphere center is in between the frustum planes
  69675. */
  69676. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69677. /**
  69678. * Tests if a point is inside the bounding sphere
  69679. * @param point defines the point to test
  69680. * @returns true if the point is inside the bounding sphere
  69681. */
  69682. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69683. /**
  69684. * Checks if two sphere intersct
  69685. * @param sphere0 sphere 0
  69686. * @param sphere1 sphere 1
  69687. * @returns true if the speres intersect
  69688. */
  69689. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69690. }
  69691. }
  69692. declare module BABYLON {
  69693. /**
  69694. * Class used to store bounding box information
  69695. */
  69696. export class BoundingBox implements ICullable {
  69697. /**
  69698. * Gets the 8 vectors representing the bounding box in local space
  69699. */
  69700. readonly vectors: Vector3[];
  69701. /**
  69702. * Gets the center of the bounding box in local space
  69703. */
  69704. readonly center: Vector3;
  69705. /**
  69706. * Gets the center of the bounding box in world space
  69707. */
  69708. readonly centerWorld: Vector3;
  69709. /**
  69710. * Gets the extend size in local space
  69711. */
  69712. readonly extendSize: Vector3;
  69713. /**
  69714. * Gets the extend size in world space
  69715. */
  69716. readonly extendSizeWorld: Vector3;
  69717. /**
  69718. * Gets the OBB (object bounding box) directions
  69719. */
  69720. readonly directions: Vector3[];
  69721. /**
  69722. * Gets the 8 vectors representing the bounding box in world space
  69723. */
  69724. readonly vectorsWorld: Vector3[];
  69725. /**
  69726. * Gets the minimum vector in world space
  69727. */
  69728. readonly minimumWorld: Vector3;
  69729. /**
  69730. * Gets the maximum vector in world space
  69731. */
  69732. readonly maximumWorld: Vector3;
  69733. /**
  69734. * Gets the minimum vector in local space
  69735. */
  69736. readonly minimum: Vector3;
  69737. /**
  69738. * Gets the maximum vector in local space
  69739. */
  69740. readonly maximum: Vector3;
  69741. private _worldMatrix;
  69742. private static readonly TmpVector3;
  69743. /**
  69744. * @hidden
  69745. */
  69746. _tag: number;
  69747. /**
  69748. * Creates a new bounding box
  69749. * @param min defines the minimum vector (in local space)
  69750. * @param max defines the maximum vector (in local space)
  69751. * @param worldMatrix defines the new world matrix
  69752. */
  69753. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69754. /**
  69755. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69756. * @param min defines the new minimum vector (in local space)
  69757. * @param max defines the new maximum vector (in local space)
  69758. * @param worldMatrix defines the new world matrix
  69759. */
  69760. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69761. /**
  69762. * Scale the current bounding box by applying a scale factor
  69763. * @param factor defines the scale factor to apply
  69764. * @returns the current bounding box
  69765. */
  69766. scale(factor: number): BoundingBox;
  69767. /**
  69768. * Gets the world matrix of the bounding box
  69769. * @returns a matrix
  69770. */
  69771. getWorldMatrix(): DeepImmutable<Matrix>;
  69772. /** @hidden */
  69773. _update(world: DeepImmutable<Matrix>): void;
  69774. /**
  69775. * Tests if the bounding box is intersecting the frustum planes
  69776. * @param frustumPlanes defines the frustum planes to test
  69777. * @returns true if there is an intersection
  69778. */
  69779. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69780. /**
  69781. * Tests if the bounding box is entirely inside the frustum planes
  69782. * @param frustumPlanes defines the frustum planes to test
  69783. * @returns true if there is an inclusion
  69784. */
  69785. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69786. /**
  69787. * Tests if a point is inside the bounding box
  69788. * @param point defines the point to test
  69789. * @returns true if the point is inside the bounding box
  69790. */
  69791. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69792. /**
  69793. * Tests if the bounding box intersects with a bounding sphere
  69794. * @param sphere defines the sphere to test
  69795. * @returns true if there is an intersection
  69796. */
  69797. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69798. /**
  69799. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69800. * @param min defines the min vector to use
  69801. * @param max defines the max vector to use
  69802. * @returns true if there is an intersection
  69803. */
  69804. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69805. /**
  69806. * Tests if two bounding boxes are intersections
  69807. * @param box0 defines the first box to test
  69808. * @param box1 defines the second box to test
  69809. * @returns true if there is an intersection
  69810. */
  69811. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69812. /**
  69813. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69814. * @param minPoint defines the minimum vector of the bounding box
  69815. * @param maxPoint defines the maximum vector of the bounding box
  69816. * @param sphereCenter defines the sphere center
  69817. * @param sphereRadius defines the sphere radius
  69818. * @returns true if there is an intersection
  69819. */
  69820. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69821. /**
  69822. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69823. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69824. * @param frustumPlanes defines the frustum planes to test
  69825. * @return true if there is an inclusion
  69826. */
  69827. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69828. /**
  69829. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69830. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69831. * @param frustumPlanes defines the frustum planes to test
  69832. * @return true if there is an intersection
  69833. */
  69834. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69835. }
  69836. }
  69837. declare module BABYLON {
  69838. /** @hidden */
  69839. export class Collider {
  69840. /** Define if a collision was found */
  69841. collisionFound: boolean;
  69842. /**
  69843. * Define last intersection point in local space
  69844. */
  69845. intersectionPoint: Vector3;
  69846. /**
  69847. * Define last collided mesh
  69848. */
  69849. collidedMesh: Nullable<AbstractMesh>;
  69850. private _collisionPoint;
  69851. private _planeIntersectionPoint;
  69852. private _tempVector;
  69853. private _tempVector2;
  69854. private _tempVector3;
  69855. private _tempVector4;
  69856. private _edge;
  69857. private _baseToVertex;
  69858. private _destinationPoint;
  69859. private _slidePlaneNormal;
  69860. private _displacementVector;
  69861. /** @hidden */
  69862. _radius: Vector3;
  69863. /** @hidden */
  69864. _retry: number;
  69865. private _velocity;
  69866. private _basePoint;
  69867. private _epsilon;
  69868. /** @hidden */
  69869. _velocityWorldLength: number;
  69870. /** @hidden */
  69871. _basePointWorld: Vector3;
  69872. private _velocityWorld;
  69873. private _normalizedVelocity;
  69874. /** @hidden */
  69875. _initialVelocity: Vector3;
  69876. /** @hidden */
  69877. _initialPosition: Vector3;
  69878. private _nearestDistance;
  69879. private _collisionMask;
  69880. collisionMask: number;
  69881. /**
  69882. * Gets the plane normal used to compute the sliding response (in local space)
  69883. */
  69884. readonly slidePlaneNormal: Vector3;
  69885. /** @hidden */
  69886. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69887. /** @hidden */
  69888. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69889. /** @hidden */
  69890. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69891. /** @hidden */
  69892. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69893. /** @hidden */
  69894. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69895. /** @hidden */
  69896. _getResponse(pos: Vector3, vel: Vector3): void;
  69897. }
  69898. }
  69899. declare module BABYLON {
  69900. /**
  69901. * Interface for cullable objects
  69902. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69903. */
  69904. export interface ICullable {
  69905. /**
  69906. * Checks if the object or part of the object is in the frustum
  69907. * @param frustumPlanes Camera near/planes
  69908. * @returns true if the object is in frustum otherwise false
  69909. */
  69910. isInFrustum(frustumPlanes: Plane[]): boolean;
  69911. /**
  69912. * Checks if a cullable object (mesh...) is in the camera frustum
  69913. * Unlike isInFrustum this cheks the full bounding box
  69914. * @param frustumPlanes Camera near/planes
  69915. * @returns true if the object is in frustum otherwise false
  69916. */
  69917. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69918. }
  69919. /**
  69920. * Info for a bounding data of a mesh
  69921. */
  69922. export class BoundingInfo implements ICullable {
  69923. /**
  69924. * Bounding box for the mesh
  69925. */
  69926. readonly boundingBox: BoundingBox;
  69927. /**
  69928. * Bounding sphere for the mesh
  69929. */
  69930. readonly boundingSphere: BoundingSphere;
  69931. private _isLocked;
  69932. private static readonly TmpVector3;
  69933. /**
  69934. * Constructs bounding info
  69935. * @param minimum min vector of the bounding box/sphere
  69936. * @param maximum max vector of the bounding box/sphere
  69937. * @param worldMatrix defines the new world matrix
  69938. */
  69939. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69940. /**
  69941. * Recreates the entire bounding info from scratch as if we call the constructor in place
  69942. * @param min defines the new minimum vector (in local space)
  69943. * @param max defines the new maximum vector (in local space)
  69944. * @param worldMatrix defines the new world matrix
  69945. */
  69946. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69947. /**
  69948. * min vector of the bounding box/sphere
  69949. */
  69950. readonly minimum: Vector3;
  69951. /**
  69952. * max vector of the bounding box/sphere
  69953. */
  69954. readonly maximum: Vector3;
  69955. /**
  69956. * If the info is locked and won't be updated to avoid perf overhead
  69957. */
  69958. isLocked: boolean;
  69959. /**
  69960. * Updates the bounding sphere and box
  69961. * @param world world matrix to be used to update
  69962. */
  69963. update(world: DeepImmutable<Matrix>): void;
  69964. /**
  69965. * Recreate the bounding info to be centered around a specific point given a specific extend.
  69966. * @param center New center of the bounding info
  69967. * @param extend New extend of the bounding info
  69968. * @returns the current bounding info
  69969. */
  69970. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  69971. /**
  69972. * Scale the current bounding info by applying a scale factor
  69973. * @param factor defines the scale factor to apply
  69974. * @returns the current bounding info
  69975. */
  69976. scale(factor: number): BoundingInfo;
  69977. /**
  69978. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  69979. * @param frustumPlanes defines the frustum to test
  69980. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  69981. * @returns true if the bounding info is in the frustum planes
  69982. */
  69983. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  69984. /**
  69985. * Gets the world distance between the min and max points of the bounding box
  69986. */
  69987. readonly diagonalLength: number;
  69988. /**
  69989. * Checks if a cullable object (mesh...) is in the camera frustum
  69990. * Unlike isInFrustum this cheks the full bounding box
  69991. * @param frustumPlanes Camera near/planes
  69992. * @returns true if the object is in frustum otherwise false
  69993. */
  69994. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69995. /** @hidden */
  69996. _checkCollision(collider: Collider): boolean;
  69997. /**
  69998. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  69999. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70000. * @param point the point to check intersection with
  70001. * @returns if the point intersects
  70002. */
  70003. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70004. /**
  70005. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70006. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70007. * @param boundingInfo the bounding info to check intersection with
  70008. * @param precise if the intersection should be done using OBB
  70009. * @returns if the bounding info intersects
  70010. */
  70011. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70012. }
  70013. }
  70014. declare module BABYLON {
  70015. /**
  70016. * Defines an array and its length.
  70017. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70018. */
  70019. export interface ISmartArrayLike<T> {
  70020. /**
  70021. * The data of the array.
  70022. */
  70023. data: Array<T>;
  70024. /**
  70025. * The active length of the array.
  70026. */
  70027. length: number;
  70028. }
  70029. /**
  70030. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70031. */
  70032. export class SmartArray<T> implements ISmartArrayLike<T> {
  70033. /**
  70034. * The full set of data from the array.
  70035. */
  70036. data: Array<T>;
  70037. /**
  70038. * The active length of the array.
  70039. */
  70040. length: number;
  70041. protected _id: number;
  70042. /**
  70043. * Instantiates a Smart Array.
  70044. * @param capacity defines the default capacity of the array.
  70045. */
  70046. constructor(capacity: number);
  70047. /**
  70048. * Pushes a value at the end of the active data.
  70049. * @param value defines the object to push in the array.
  70050. */
  70051. push(value: T): void;
  70052. /**
  70053. * Iterates over the active data and apply the lambda to them.
  70054. * @param func defines the action to apply on each value.
  70055. */
  70056. forEach(func: (content: T) => void): void;
  70057. /**
  70058. * Sorts the full sets of data.
  70059. * @param compareFn defines the comparison function to apply.
  70060. */
  70061. sort(compareFn: (a: T, b: T) => number): void;
  70062. /**
  70063. * Resets the active data to an empty array.
  70064. */
  70065. reset(): void;
  70066. /**
  70067. * Releases all the data from the array as well as the array.
  70068. */
  70069. dispose(): void;
  70070. /**
  70071. * Concats the active data with a given array.
  70072. * @param array defines the data to concatenate with.
  70073. */
  70074. concat(array: any): void;
  70075. /**
  70076. * Returns the position of a value in the active data.
  70077. * @param value defines the value to find the index for
  70078. * @returns the index if found in the active data otherwise -1
  70079. */
  70080. indexOf(value: T): number;
  70081. /**
  70082. * Returns whether an element is part of the active data.
  70083. * @param value defines the value to look for
  70084. * @returns true if found in the active data otherwise false
  70085. */
  70086. contains(value: T): boolean;
  70087. private static _GlobalId;
  70088. }
  70089. /**
  70090. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70091. * The data in this array can only be present once
  70092. */
  70093. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70094. private _duplicateId;
  70095. /**
  70096. * Pushes a value at the end of the active data.
  70097. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70098. * @param value defines the object to push in the array.
  70099. */
  70100. push(value: T): void;
  70101. /**
  70102. * Pushes a value at the end of the active data.
  70103. * If the data is already present, it won t be added again
  70104. * @param value defines the object to push in the array.
  70105. * @returns true if added false if it was already present
  70106. */
  70107. pushNoDuplicate(value: T): boolean;
  70108. /**
  70109. * Resets the active data to an empty array.
  70110. */
  70111. reset(): void;
  70112. /**
  70113. * Concats the active data with a given array.
  70114. * This ensures no dupplicate will be present in the result.
  70115. * @param array defines the data to concatenate with.
  70116. */
  70117. concatWithNoDuplicate(array: any): void;
  70118. }
  70119. }
  70120. declare module BABYLON {
  70121. /**
  70122. * Enum that determines the text-wrapping mode to use.
  70123. */
  70124. export enum InspectableType {
  70125. /**
  70126. * Checkbox for booleans
  70127. */
  70128. Checkbox = 0,
  70129. /**
  70130. * Sliders for numbers
  70131. */
  70132. Slider = 1,
  70133. /**
  70134. * Vector3
  70135. */
  70136. Vector3 = 2,
  70137. /**
  70138. * Quaternions
  70139. */
  70140. Quaternion = 3,
  70141. /**
  70142. * Color3
  70143. */
  70144. Color3 = 4
  70145. }
  70146. /**
  70147. * Interface used to define custom inspectable properties.
  70148. * This interface is used by the inspector to display custom property grids
  70149. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70150. */
  70151. export interface IInspectable {
  70152. /**
  70153. * Gets the label to display
  70154. */
  70155. label: string;
  70156. /**
  70157. * Gets the name of the property to edit
  70158. */
  70159. propertyName: string;
  70160. /**
  70161. * Gets the type of the editor to use
  70162. */
  70163. type: InspectableType;
  70164. /**
  70165. * Gets the minimum value of the property when using in "slider" mode
  70166. */
  70167. min?: number;
  70168. /**
  70169. * Gets the maximum value of the property when using in "slider" mode
  70170. */
  70171. max?: number;
  70172. /**
  70173. * Gets the setp to use when using in "slider" mode
  70174. */
  70175. step?: number;
  70176. }
  70177. }
  70178. declare module BABYLON {
  70179. /**
  70180. * This represents the required contract to create a new type of texture loader.
  70181. */
  70182. export interface IInternalTextureLoader {
  70183. /**
  70184. * Defines wether the loader supports cascade loading the different faces.
  70185. */
  70186. supportCascades: boolean;
  70187. /**
  70188. * This returns if the loader support the current file information.
  70189. * @param extension defines the file extension of the file being loaded
  70190. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70191. * @param fallback defines the fallback internal texture if any
  70192. * @param isBase64 defines whether the texture is encoded as a base64
  70193. * @param isBuffer defines whether the texture data are stored as a buffer
  70194. * @returns true if the loader can load the specified file
  70195. */
  70196. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70197. /**
  70198. * Transform the url before loading if required.
  70199. * @param rootUrl the url of the texture
  70200. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70201. * @returns the transformed texture
  70202. */
  70203. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70204. /**
  70205. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70206. * @param rootUrl the url of the texture
  70207. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70208. * @returns the fallback texture
  70209. */
  70210. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70211. /**
  70212. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70213. * @param data contains the texture data
  70214. * @param texture defines the BabylonJS internal texture
  70215. * @param createPolynomials will be true if polynomials have been requested
  70216. * @param onLoad defines the callback to trigger once the texture is ready
  70217. * @param onError defines the callback to trigger in case of error
  70218. */
  70219. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70220. /**
  70221. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70222. * @param data contains the texture data
  70223. * @param texture defines the BabylonJS internal texture
  70224. * @param callback defines the method to call once ready to upload
  70225. */
  70226. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70227. }
  70228. }
  70229. declare module BABYLON {
  70230. interface Engine {
  70231. /**
  70232. * Creates a depth stencil cube texture.
  70233. * This is only available in WebGL 2.
  70234. * @param size The size of face edge in the cube texture.
  70235. * @param options The options defining the cube texture.
  70236. * @returns The cube texture
  70237. */
  70238. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70239. /**
  70240. * Creates a cube texture
  70241. * @param rootUrl defines the url where the files to load is located
  70242. * @param scene defines the current scene
  70243. * @param files defines the list of files to load (1 per face)
  70244. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70245. * @param onLoad defines an optional callback raised when the texture is loaded
  70246. * @param onError defines an optional callback raised if there is an issue to load the texture
  70247. * @param format defines the format of the data
  70248. * @param forcedExtension defines the extension to use to pick the right loader
  70249. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70250. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70251. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70252. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70253. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70254. * @returns the cube texture as an InternalTexture
  70255. */
  70256. 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;
  70257. /**
  70258. * Creates a cube texture
  70259. * @param rootUrl defines the url where the files to load is located
  70260. * @param scene defines the current scene
  70261. * @param files defines the list of files to load (1 per face)
  70262. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70263. * @param onLoad defines an optional callback raised when the texture is loaded
  70264. * @param onError defines an optional callback raised if there is an issue to load the texture
  70265. * @param format defines the format of the data
  70266. * @param forcedExtension defines the extension to use to pick the right loader
  70267. * @returns the cube texture as an InternalTexture
  70268. */
  70269. 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;
  70270. /**
  70271. * Creates a cube texture
  70272. * @param rootUrl defines the url where the files to load is located
  70273. * @param scene defines the current scene
  70274. * @param files defines the list of files to load (1 per face)
  70275. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70276. * @param onLoad defines an optional callback raised when the texture is loaded
  70277. * @param onError defines an optional callback raised if there is an issue to load the texture
  70278. * @param format defines the format of the data
  70279. * @param forcedExtension defines the extension to use to pick the right loader
  70280. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70281. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70282. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70283. * @returns the cube texture as an InternalTexture
  70284. */
  70285. 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;
  70286. /** @hidden */
  70287. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70288. /** @hidden */
  70289. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70290. /** @hidden */
  70291. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70292. /** @hidden */
  70293. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70294. }
  70295. }
  70296. declare module BABYLON {
  70297. /**
  70298. * Class for creating a cube texture
  70299. */
  70300. export class CubeTexture extends BaseTexture {
  70301. private _delayedOnLoad;
  70302. /**
  70303. * The url of the texture
  70304. */
  70305. url: string;
  70306. /**
  70307. * Gets or sets the center of the bounding box associated with the cube texture.
  70308. * It must define where the camera used to render the texture was set
  70309. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70310. */
  70311. boundingBoxPosition: Vector3;
  70312. private _boundingBoxSize;
  70313. /**
  70314. * Gets or sets the size of the bounding box associated with the cube texture
  70315. * When defined, the cubemap will switch to local mode
  70316. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70317. * @example https://www.babylonjs-playground.com/#RNASML
  70318. */
  70319. /**
  70320. * Returns the bounding box size
  70321. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70322. */
  70323. boundingBoxSize: Vector3;
  70324. protected _rotationY: number;
  70325. /**
  70326. * Sets texture matrix rotation angle around Y axis in radians.
  70327. */
  70328. /**
  70329. * Gets texture matrix rotation angle around Y axis radians.
  70330. */
  70331. rotationY: number;
  70332. /**
  70333. * Are mip maps generated for this texture or not.
  70334. */
  70335. readonly noMipmap: boolean;
  70336. private _noMipmap;
  70337. private _files;
  70338. private _extensions;
  70339. private _textureMatrix;
  70340. private _format;
  70341. private _createPolynomials;
  70342. /** @hidden */
  70343. _prefiltered: boolean;
  70344. /**
  70345. * Creates a cube texture from an array of image urls
  70346. * @param files defines an array of image urls
  70347. * @param scene defines the hosting scene
  70348. * @param noMipmap specifies if mip maps are not used
  70349. * @returns a cube texture
  70350. */
  70351. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70352. /**
  70353. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70354. * @param url defines the url of the prefiltered texture
  70355. * @param scene defines the scene the texture is attached to
  70356. * @param forcedExtension defines the extension of the file if different from the url
  70357. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70358. * @return the prefiltered texture
  70359. */
  70360. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70361. /**
  70362. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70363. * as prefiltered data.
  70364. * @param rootUrl defines the url of the texture or the root name of the six images
  70365. * @param scene defines the scene the texture is attached to
  70366. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70367. * @param noMipmap defines if mipmaps should be created or not
  70368. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70369. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70370. * @param onError defines a callback triggered in case of error during load
  70371. * @param format defines the internal format to use for the texture once loaded
  70372. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70373. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70374. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70375. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70376. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70377. * @return the cube texture
  70378. */
  70379. 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);
  70380. /**
  70381. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70382. */
  70383. readonly isPrefiltered: boolean;
  70384. /**
  70385. * Get the current class name of the texture useful for serialization or dynamic coding.
  70386. * @returns "CubeTexture"
  70387. */
  70388. getClassName(): string;
  70389. /**
  70390. * Update the url (and optional buffer) of this texture if url was null during construction.
  70391. * @param url the url of the texture
  70392. * @param forcedExtension defines the extension to use
  70393. * @param onLoad callback called when the texture is loaded (defaults to null)
  70394. */
  70395. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70396. /**
  70397. * Delays loading of the cube texture
  70398. * @param forcedExtension defines the extension to use
  70399. */
  70400. delayLoad(forcedExtension?: string): void;
  70401. /**
  70402. * Returns the reflection texture matrix
  70403. * @returns the reflection texture matrix
  70404. */
  70405. getReflectionTextureMatrix(): Matrix;
  70406. /**
  70407. * Sets the reflection texture matrix
  70408. * @param value Reflection texture matrix
  70409. */
  70410. setReflectionTextureMatrix(value: Matrix): void;
  70411. /**
  70412. * Parses text to create a cube texture
  70413. * @param parsedTexture define the serialized text to read from
  70414. * @param scene defines the hosting scene
  70415. * @param rootUrl defines the root url of the cube texture
  70416. * @returns a cube texture
  70417. */
  70418. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70419. /**
  70420. * Makes a clone, or deep copy, of the cube texture
  70421. * @returns a new cube texture
  70422. */
  70423. clone(): CubeTexture;
  70424. }
  70425. }
  70426. declare module BABYLON {
  70427. /** @hidden */
  70428. export var postprocessVertexShader: {
  70429. name: string;
  70430. shader: string;
  70431. };
  70432. }
  70433. declare module BABYLON {
  70434. /**
  70435. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70436. * This is the base of the follow, arc rotate cameras and Free camera
  70437. * @see http://doc.babylonjs.com/features/cameras
  70438. */
  70439. export class TargetCamera extends Camera {
  70440. private static _RigCamTransformMatrix;
  70441. private static _TargetTransformMatrix;
  70442. private static _TargetFocalPoint;
  70443. /**
  70444. * Define the current direction the camera is moving to
  70445. */
  70446. cameraDirection: Vector3;
  70447. /**
  70448. * Define the current rotation the camera is rotating to
  70449. */
  70450. cameraRotation: Vector2;
  70451. /**
  70452. * When set, the up vector of the camera will be updated by the rotation of the camera
  70453. */
  70454. updateUpVectorFromRotation: boolean;
  70455. private _tmpQuaternion;
  70456. /**
  70457. * Define the current rotation of the camera
  70458. */
  70459. rotation: Vector3;
  70460. /**
  70461. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70462. */
  70463. rotationQuaternion: Quaternion;
  70464. /**
  70465. * Define the current speed of the camera
  70466. */
  70467. speed: number;
  70468. /**
  70469. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70470. * around all axis.
  70471. */
  70472. noRotationConstraint: boolean;
  70473. /**
  70474. * Define the current target of the camera as an object or a position.
  70475. */
  70476. lockedTarget: any;
  70477. /** @hidden */
  70478. _currentTarget: Vector3;
  70479. /** @hidden */
  70480. _initialFocalDistance: number;
  70481. /** @hidden */
  70482. _viewMatrix: Matrix;
  70483. /** @hidden */
  70484. _camMatrix: Matrix;
  70485. /** @hidden */
  70486. _cameraTransformMatrix: Matrix;
  70487. /** @hidden */
  70488. _cameraRotationMatrix: Matrix;
  70489. /** @hidden */
  70490. _referencePoint: Vector3;
  70491. /** @hidden */
  70492. _transformedReferencePoint: Vector3;
  70493. protected _globalCurrentTarget: Vector3;
  70494. protected _globalCurrentUpVector: Vector3;
  70495. /** @hidden */
  70496. _reset: () => void;
  70497. private _defaultUp;
  70498. /**
  70499. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70500. * This is the base of the follow, arc rotate cameras and Free camera
  70501. * @see http://doc.babylonjs.com/features/cameras
  70502. * @param name Defines the name of the camera in the scene
  70503. * @param position Defines the start position of the camera in the scene
  70504. * @param scene Defines the scene the camera belongs to
  70505. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70506. */
  70507. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70508. /**
  70509. * Gets the position in front of the camera at a given distance.
  70510. * @param distance The distance from the camera we want the position to be
  70511. * @returns the position
  70512. */
  70513. getFrontPosition(distance: number): Vector3;
  70514. /** @hidden */
  70515. _getLockedTargetPosition(): Nullable<Vector3>;
  70516. private _storedPosition;
  70517. private _storedRotation;
  70518. private _storedRotationQuaternion;
  70519. /**
  70520. * Store current camera state of the camera (fov, position, rotation, etc..)
  70521. * @returns the camera
  70522. */
  70523. storeState(): Camera;
  70524. /**
  70525. * Restored camera state. You must call storeState() first
  70526. * @returns whether it was successful or not
  70527. * @hidden
  70528. */
  70529. _restoreStateValues(): boolean;
  70530. /** @hidden */
  70531. _initCache(): void;
  70532. /** @hidden */
  70533. _updateCache(ignoreParentClass?: boolean): void;
  70534. /** @hidden */
  70535. _isSynchronizedViewMatrix(): boolean;
  70536. /** @hidden */
  70537. _computeLocalCameraSpeed(): number;
  70538. /**
  70539. * Defines the target the camera should look at.
  70540. * This will automatically adapt alpha beta and radius to fit within the new target.
  70541. * @param target Defines the new target as a Vector or a mesh
  70542. */
  70543. setTarget(target: Vector3): void;
  70544. /**
  70545. * Return the current target position of the camera. This value is expressed in local space.
  70546. * @returns the target position
  70547. */
  70548. getTarget(): Vector3;
  70549. /** @hidden */
  70550. _decideIfNeedsToMove(): boolean;
  70551. /** @hidden */
  70552. _updatePosition(): void;
  70553. /** @hidden */
  70554. _checkInputs(): void;
  70555. protected _updateCameraRotationMatrix(): void;
  70556. /**
  70557. * 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)
  70558. * @returns the current camera
  70559. */
  70560. private _rotateUpVectorWithCameraRotationMatrix;
  70561. private _cachedRotationZ;
  70562. private _cachedQuaternionRotationZ;
  70563. /** @hidden */
  70564. _getViewMatrix(): Matrix;
  70565. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70566. /**
  70567. * @hidden
  70568. */
  70569. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70570. /**
  70571. * @hidden
  70572. */
  70573. _updateRigCameras(): void;
  70574. private _getRigCamPositionAndTarget;
  70575. /**
  70576. * Gets the current object class name.
  70577. * @return the class name
  70578. */
  70579. getClassName(): string;
  70580. }
  70581. }
  70582. declare module BABYLON {
  70583. /**
  70584. * @ignore
  70585. * This is a list of all the different input types that are available in the application.
  70586. * Fo instance: ArcRotateCameraGamepadInput...
  70587. */
  70588. export var CameraInputTypes: {};
  70589. /**
  70590. * This is the contract to implement in order to create a new input class.
  70591. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70592. */
  70593. export interface ICameraInput<TCamera extends Camera> {
  70594. /**
  70595. * Defines the camera the input is attached to.
  70596. */
  70597. camera: Nullable<TCamera>;
  70598. /**
  70599. * Gets the class name of the current intput.
  70600. * @returns the class name
  70601. */
  70602. getClassName(): string;
  70603. /**
  70604. * Get the friendly name associated with the input class.
  70605. * @returns the input friendly name
  70606. */
  70607. getSimpleName(): string;
  70608. /**
  70609. * Attach the input controls to a specific dom element to get the input from.
  70610. * @param element Defines the element the controls should be listened from
  70611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70612. */
  70613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70614. /**
  70615. * Detach the current controls from the specified dom element.
  70616. * @param element Defines the element to stop listening the inputs from
  70617. */
  70618. detachControl(element: Nullable<HTMLElement>): void;
  70619. /**
  70620. * Update the current camera state depending on the inputs that have been used this frame.
  70621. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70622. */
  70623. checkInputs?: () => void;
  70624. }
  70625. /**
  70626. * Represents a map of input types to input instance or input index to input instance.
  70627. */
  70628. export interface CameraInputsMap<TCamera extends Camera> {
  70629. /**
  70630. * Accessor to the input by input type.
  70631. */
  70632. [name: string]: ICameraInput<TCamera>;
  70633. /**
  70634. * Accessor to the input by input index.
  70635. */
  70636. [idx: number]: ICameraInput<TCamera>;
  70637. }
  70638. /**
  70639. * This represents the input manager used within a camera.
  70640. * It helps dealing with all the different kind of input attached to a camera.
  70641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70642. */
  70643. export class CameraInputsManager<TCamera extends Camera> {
  70644. /**
  70645. * Defines the list of inputs attahed to the camera.
  70646. */
  70647. attached: CameraInputsMap<TCamera>;
  70648. /**
  70649. * Defines the dom element the camera is collecting inputs from.
  70650. * This is null if the controls have not been attached.
  70651. */
  70652. attachedElement: Nullable<HTMLElement>;
  70653. /**
  70654. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70655. */
  70656. noPreventDefault: boolean;
  70657. /**
  70658. * Defined the camera the input manager belongs to.
  70659. */
  70660. camera: TCamera;
  70661. /**
  70662. * Update the current camera state depending on the inputs that have been used this frame.
  70663. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70664. */
  70665. checkInputs: () => void;
  70666. /**
  70667. * Instantiate a new Camera Input Manager.
  70668. * @param camera Defines the camera the input manager blongs to
  70669. */
  70670. constructor(camera: TCamera);
  70671. /**
  70672. * Add an input method to a camera
  70673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70674. * @param input camera input method
  70675. */
  70676. add(input: ICameraInput<TCamera>): void;
  70677. /**
  70678. * Remove a specific input method from a camera
  70679. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70680. * @param inputToRemove camera input method
  70681. */
  70682. remove(inputToRemove: ICameraInput<TCamera>): void;
  70683. /**
  70684. * Remove a specific input type from a camera
  70685. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70686. * @param inputType the type of the input to remove
  70687. */
  70688. removeByType(inputType: string): void;
  70689. private _addCheckInputs;
  70690. /**
  70691. * Attach the input controls to the currently attached dom element to listen the events from.
  70692. * @param input Defines the input to attach
  70693. */
  70694. attachInput(input: ICameraInput<TCamera>): void;
  70695. /**
  70696. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70697. * @param element Defines the dom element to collect the events from
  70698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70699. */
  70700. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70701. /**
  70702. * Detach the current manager inputs controls from a specific dom element.
  70703. * @param element Defines the dom element to collect the events from
  70704. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70705. */
  70706. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70707. /**
  70708. * Rebuild the dynamic inputCheck function from the current list of
  70709. * defined inputs in the manager.
  70710. */
  70711. rebuildInputCheck(): void;
  70712. /**
  70713. * Remove all attached input methods from a camera
  70714. */
  70715. clear(): void;
  70716. /**
  70717. * Serialize the current input manager attached to a camera.
  70718. * This ensures than once parsed,
  70719. * the input associated to the camera will be identical to the current ones
  70720. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70721. */
  70722. serialize(serializedCamera: any): void;
  70723. /**
  70724. * Parses an input manager serialized JSON to restore the previous list of inputs
  70725. * and states associated to a camera.
  70726. * @param parsedCamera Defines the JSON to parse
  70727. */
  70728. parse(parsedCamera: any): void;
  70729. }
  70730. }
  70731. declare module BABYLON {
  70732. /**
  70733. * Gather the list of keyboard event types as constants.
  70734. */
  70735. export class KeyboardEventTypes {
  70736. /**
  70737. * The keydown event is fired when a key becomes active (pressed).
  70738. */
  70739. static readonly KEYDOWN: number;
  70740. /**
  70741. * The keyup event is fired when a key has been released.
  70742. */
  70743. static readonly KEYUP: number;
  70744. }
  70745. /**
  70746. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70747. */
  70748. export class KeyboardInfo {
  70749. /**
  70750. * Defines the type of event (KeyboardEventTypes)
  70751. */
  70752. type: number;
  70753. /**
  70754. * Defines the related dom event
  70755. */
  70756. event: KeyboardEvent;
  70757. /**
  70758. * Instantiates a new keyboard info.
  70759. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70760. * @param type Defines the type of event (KeyboardEventTypes)
  70761. * @param event Defines the related dom event
  70762. */
  70763. constructor(
  70764. /**
  70765. * Defines the type of event (KeyboardEventTypes)
  70766. */
  70767. type: number,
  70768. /**
  70769. * Defines the related dom event
  70770. */
  70771. event: KeyboardEvent);
  70772. }
  70773. /**
  70774. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70775. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  70776. */
  70777. export class KeyboardInfoPre extends KeyboardInfo {
  70778. /**
  70779. * Defines the type of event (KeyboardEventTypes)
  70780. */
  70781. type: number;
  70782. /**
  70783. * Defines the related dom event
  70784. */
  70785. event: KeyboardEvent;
  70786. /**
  70787. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  70788. */
  70789. skipOnPointerObservable: boolean;
  70790. /**
  70791. * Instantiates a new keyboard pre info.
  70792. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70793. * @param type Defines the type of event (KeyboardEventTypes)
  70794. * @param event Defines the related dom event
  70795. */
  70796. constructor(
  70797. /**
  70798. * Defines the type of event (KeyboardEventTypes)
  70799. */
  70800. type: number,
  70801. /**
  70802. * Defines the related dom event
  70803. */
  70804. event: KeyboardEvent);
  70805. }
  70806. }
  70807. declare module BABYLON {
  70808. /**
  70809. * Manage the keyboard inputs to control the movement of a free camera.
  70810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70811. */
  70812. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  70813. /**
  70814. * Defines the camera the input is attached to.
  70815. */
  70816. camera: FreeCamera;
  70817. /**
  70818. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70819. */
  70820. keysUp: number[];
  70821. /**
  70822. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70823. */
  70824. keysDown: number[];
  70825. /**
  70826. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70827. */
  70828. keysLeft: number[];
  70829. /**
  70830. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70831. */
  70832. keysRight: number[];
  70833. private _keys;
  70834. private _onCanvasBlurObserver;
  70835. private _onKeyboardObserver;
  70836. private _engine;
  70837. private _scene;
  70838. /**
  70839. * Attach the input controls to a specific dom element to get the input from.
  70840. * @param element Defines the element the controls should be listened from
  70841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70842. */
  70843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70844. /**
  70845. * Detach the current controls from the specified dom element.
  70846. * @param element Defines the element to stop listening the inputs from
  70847. */
  70848. detachControl(element: Nullable<HTMLElement>): void;
  70849. /**
  70850. * Update the current camera state depending on the inputs that have been used this frame.
  70851. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70852. */
  70853. checkInputs(): void;
  70854. /**
  70855. * Gets the class name of the current intput.
  70856. * @returns the class name
  70857. */
  70858. getClassName(): string;
  70859. /** @hidden */
  70860. _onLostFocus(): void;
  70861. /**
  70862. * Get the friendly name associated with the input class.
  70863. * @returns the input friendly name
  70864. */
  70865. getSimpleName(): string;
  70866. }
  70867. }
  70868. declare module BABYLON {
  70869. /**
  70870. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70871. * separate meshes. This can be use to improve performances.
  70872. * @see http://doc.babylonjs.com/how_to/multi_materials
  70873. */
  70874. export class MultiMaterial extends Material {
  70875. private _subMaterials;
  70876. /**
  70877. * Gets or Sets the list of Materials used within the multi material.
  70878. * They need to be ordered according to the submeshes order in the associated mesh
  70879. */
  70880. subMaterials: Nullable<Material>[];
  70881. /**
  70882. * Function used to align with Node.getChildren()
  70883. * @returns the list of Materials used within the multi material
  70884. */
  70885. getChildren(): Nullable<Material>[];
  70886. /**
  70887. * Instantiates a new Multi Material
  70888. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70889. * separate meshes. This can be use to improve performances.
  70890. * @see http://doc.babylonjs.com/how_to/multi_materials
  70891. * @param name Define the name in the scene
  70892. * @param scene Define the scene the material belongs to
  70893. */
  70894. constructor(name: string, scene: Scene);
  70895. private _hookArray;
  70896. /**
  70897. * Get one of the submaterial by its index in the submaterials array
  70898. * @param index The index to look the sub material at
  70899. * @returns The Material if the index has been defined
  70900. */
  70901. getSubMaterial(index: number): Nullable<Material>;
  70902. /**
  70903. * Get the list of active textures for the whole sub materials list.
  70904. * @returns All the textures that will be used during the rendering
  70905. */
  70906. getActiveTextures(): BaseTexture[];
  70907. /**
  70908. * Gets the current class name of the material e.g. "MultiMaterial"
  70909. * Mainly use in serialization.
  70910. * @returns the class name
  70911. */
  70912. getClassName(): string;
  70913. /**
  70914. * Checks if the material is ready to render the requested sub mesh
  70915. * @param mesh Define the mesh the submesh belongs to
  70916. * @param subMesh Define the sub mesh to look readyness for
  70917. * @param useInstances Define whether or not the material is used with instances
  70918. * @returns true if ready, otherwise false
  70919. */
  70920. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  70921. /**
  70922. * Clones the current material and its related sub materials
  70923. * @param name Define the name of the newly cloned material
  70924. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  70925. * @returns the cloned material
  70926. */
  70927. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  70928. /**
  70929. * Serializes the materials into a JSON representation.
  70930. * @returns the JSON representation
  70931. */
  70932. serialize(): any;
  70933. /**
  70934. * Dispose the material and release its associated resources
  70935. * @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)
  70936. * @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)
  70937. * @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)
  70938. */
  70939. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  70940. /**
  70941. * Creates a MultiMaterial from parsed MultiMaterial data.
  70942. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  70943. * @param scene defines the hosting scene
  70944. * @returns a new MultiMaterial
  70945. */
  70946. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  70947. }
  70948. }
  70949. declare module BABYLON {
  70950. /**
  70951. * Class used to represent data loading progression
  70952. */
  70953. export class SceneLoaderFlags {
  70954. private static _ForceFullSceneLoadingForIncremental;
  70955. private static _ShowLoadingScreen;
  70956. private static _CleanBoneMatrixWeights;
  70957. private static _loggingLevel;
  70958. /**
  70959. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  70960. */
  70961. static ForceFullSceneLoadingForIncremental: boolean;
  70962. /**
  70963. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  70964. */
  70965. static ShowLoadingScreen: boolean;
  70966. /**
  70967. * Defines the current logging level (while loading the scene)
  70968. * @ignorenaming
  70969. */
  70970. static loggingLevel: number;
  70971. /**
  70972. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  70973. */
  70974. static CleanBoneMatrixWeights: boolean;
  70975. }
  70976. }
  70977. declare module BABYLON {
  70978. /**
  70979. * 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.
  70980. * @see https://doc.babylonjs.com/how_to/transformnode
  70981. */
  70982. export class TransformNode extends Node {
  70983. /**
  70984. * Object will not rotate to face the camera
  70985. */
  70986. static BILLBOARDMODE_NONE: number;
  70987. /**
  70988. * Object will rotate to face the camera but only on the x axis
  70989. */
  70990. static BILLBOARDMODE_X: number;
  70991. /**
  70992. * Object will rotate to face the camera but only on the y axis
  70993. */
  70994. static BILLBOARDMODE_Y: number;
  70995. /**
  70996. * Object will rotate to face the camera but only on the z axis
  70997. */
  70998. static BILLBOARDMODE_Z: number;
  70999. /**
  71000. * Object will rotate to face the camera
  71001. */
  71002. static BILLBOARDMODE_ALL: number;
  71003. private _forward;
  71004. private _forwardInverted;
  71005. private _up;
  71006. private _right;
  71007. private _rightInverted;
  71008. private _position;
  71009. private _rotation;
  71010. private _rotationQuaternion;
  71011. protected _scaling: Vector3;
  71012. protected _isDirty: boolean;
  71013. private _transformToBoneReferal;
  71014. private _billboardMode;
  71015. /**
  71016. * Gets or sets the billboard mode. Default is 0.
  71017. *
  71018. * | Value | Type | Description |
  71019. * | --- | --- | --- |
  71020. * | 0 | BILLBOARDMODE_NONE | |
  71021. * | 1 | BILLBOARDMODE_X | |
  71022. * | 2 | BILLBOARDMODE_Y | |
  71023. * | 4 | BILLBOARDMODE_Z | |
  71024. * | 7 | BILLBOARDMODE_ALL | |
  71025. *
  71026. */
  71027. billboardMode: number;
  71028. private _preserveParentRotationForBillboard;
  71029. /**
  71030. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71031. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71032. */
  71033. preserveParentRotationForBillboard: boolean;
  71034. /**
  71035. * 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
  71036. */
  71037. scalingDeterminant: number;
  71038. private _infiniteDistance;
  71039. /**
  71040. * Gets or sets the distance of the object to max, often used by skybox
  71041. */
  71042. infiniteDistance: boolean;
  71043. /**
  71044. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71045. * By default the system will update normals to compensate
  71046. */
  71047. ignoreNonUniformScaling: boolean;
  71048. /**
  71049. * 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
  71050. */
  71051. reIntegrateRotationIntoRotationQuaternion: boolean;
  71052. /** @hidden */
  71053. _poseMatrix: Nullable<Matrix>;
  71054. /** @hidden */
  71055. _localMatrix: Matrix;
  71056. private _usePivotMatrix;
  71057. private _absolutePosition;
  71058. private _pivotMatrix;
  71059. private _pivotMatrixInverse;
  71060. protected _postMultiplyPivotMatrix: boolean;
  71061. protected _isWorldMatrixFrozen: boolean;
  71062. /** @hidden */
  71063. _indexInSceneTransformNodesArray: number;
  71064. /**
  71065. * An event triggered after the world matrix is updated
  71066. */
  71067. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71068. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71069. /**
  71070. * Gets a string identifying the name of the class
  71071. * @returns "TransformNode" string
  71072. */
  71073. getClassName(): string;
  71074. /**
  71075. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71076. */
  71077. position: Vector3;
  71078. /**
  71079. * 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)).
  71080. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71081. */
  71082. rotation: Vector3;
  71083. /**
  71084. * 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)).
  71085. */
  71086. scaling: Vector3;
  71087. /**
  71088. * 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).
  71089. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71090. */
  71091. rotationQuaternion: Nullable<Quaternion>;
  71092. /**
  71093. * The forward direction of that transform in world space.
  71094. */
  71095. readonly forward: Vector3;
  71096. /**
  71097. * The up direction of that transform in world space.
  71098. */
  71099. readonly up: Vector3;
  71100. /**
  71101. * The right direction of that transform in world space.
  71102. */
  71103. readonly right: Vector3;
  71104. /**
  71105. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71106. * @param matrix the matrix to copy the pose from
  71107. * @returns this TransformNode.
  71108. */
  71109. updatePoseMatrix(matrix: Matrix): TransformNode;
  71110. /**
  71111. * Returns the mesh Pose matrix.
  71112. * @returns the pose matrix
  71113. */
  71114. getPoseMatrix(): Matrix;
  71115. /** @hidden */
  71116. _isSynchronized(): boolean;
  71117. /** @hidden */
  71118. _initCache(): void;
  71119. /**
  71120. * Flag the transform node as dirty (Forcing it to update everything)
  71121. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71122. * @returns this transform node
  71123. */
  71124. markAsDirty(property: string): TransformNode;
  71125. /**
  71126. * Returns the current mesh absolute position.
  71127. * Returns a Vector3.
  71128. */
  71129. readonly absolutePosition: Vector3;
  71130. /**
  71131. * Sets a new matrix to apply before all other transformation
  71132. * @param matrix defines the transform matrix
  71133. * @returns the current TransformNode
  71134. */
  71135. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71136. /**
  71137. * Sets a new pivot matrix to the current node
  71138. * @param matrix defines the new pivot matrix to use
  71139. * @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
  71140. * @returns the current TransformNode
  71141. */
  71142. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71143. /**
  71144. * Returns the mesh pivot matrix.
  71145. * Default : Identity.
  71146. * @returns the matrix
  71147. */
  71148. getPivotMatrix(): Matrix;
  71149. /**
  71150. * Prevents the World matrix to be computed any longer.
  71151. * @returns the TransformNode.
  71152. */
  71153. freezeWorldMatrix(): TransformNode;
  71154. /**
  71155. * Allows back the World matrix computation.
  71156. * @returns the TransformNode.
  71157. */
  71158. unfreezeWorldMatrix(): this;
  71159. /**
  71160. * True if the World matrix has been frozen.
  71161. */
  71162. readonly isWorldMatrixFrozen: boolean;
  71163. /**
  71164. * Retuns the mesh absolute position in the World.
  71165. * @returns a Vector3.
  71166. */
  71167. getAbsolutePosition(): Vector3;
  71168. /**
  71169. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71170. * @param absolutePosition the absolute position to set
  71171. * @returns the TransformNode.
  71172. */
  71173. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71174. /**
  71175. * Sets the mesh position in its local space.
  71176. * @param vector3 the position to set in localspace
  71177. * @returns the TransformNode.
  71178. */
  71179. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71180. /**
  71181. * Returns the mesh position in the local space from the current World matrix values.
  71182. * @returns a new Vector3.
  71183. */
  71184. getPositionExpressedInLocalSpace(): Vector3;
  71185. /**
  71186. * Translates the mesh along the passed Vector3 in its local space.
  71187. * @param vector3 the distance to translate in localspace
  71188. * @returns the TransformNode.
  71189. */
  71190. locallyTranslate(vector3: Vector3): TransformNode;
  71191. private static _lookAtVectorCache;
  71192. /**
  71193. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71194. * @param targetPoint the position (must be in same space as current mesh) to look at
  71195. * @param yawCor optional yaw (y-axis) correction in radians
  71196. * @param pitchCor optional pitch (x-axis) correction in radians
  71197. * @param rollCor optional roll (z-axis) correction in radians
  71198. * @param space the choosen space of the target
  71199. * @returns the TransformNode.
  71200. */
  71201. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71202. /**
  71203. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71204. * This Vector3 is expressed in the World space.
  71205. * @param localAxis axis to rotate
  71206. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71207. */
  71208. getDirection(localAxis: Vector3): Vector3;
  71209. /**
  71210. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71211. * localAxis is expressed in the mesh local space.
  71212. * result is computed in the Wordl space from the mesh World matrix.
  71213. * @param localAxis axis to rotate
  71214. * @param result the resulting transformnode
  71215. * @returns this TransformNode.
  71216. */
  71217. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71218. /**
  71219. * Sets this transform node rotation to the given local axis.
  71220. * @param localAxis the axis in local space
  71221. * @param yawCor optional yaw (y-axis) correction in radians
  71222. * @param pitchCor optional pitch (x-axis) correction in radians
  71223. * @param rollCor optional roll (z-axis) correction in radians
  71224. * @returns this TransformNode
  71225. */
  71226. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71227. /**
  71228. * Sets a new pivot point to the current node
  71229. * @param point defines the new pivot point to use
  71230. * @param space defines if the point is in world or local space (local by default)
  71231. * @returns the current TransformNode
  71232. */
  71233. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71234. /**
  71235. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71236. * @returns the pivot point
  71237. */
  71238. getPivotPoint(): Vector3;
  71239. /**
  71240. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71241. * @param result the vector3 to store the result
  71242. * @returns this TransformNode.
  71243. */
  71244. getPivotPointToRef(result: Vector3): TransformNode;
  71245. /**
  71246. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71247. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71248. */
  71249. getAbsolutePivotPoint(): Vector3;
  71250. /**
  71251. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71252. * @param result vector3 to store the result
  71253. * @returns this TransformNode.
  71254. */
  71255. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71256. /**
  71257. * Defines the passed node as the parent of the current node.
  71258. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71259. * @see https://doc.babylonjs.com/how_to/parenting
  71260. * @param node the node ot set as the parent
  71261. * @returns this TransformNode.
  71262. */
  71263. setParent(node: Nullable<Node>): TransformNode;
  71264. private _nonUniformScaling;
  71265. /**
  71266. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71267. */
  71268. readonly nonUniformScaling: boolean;
  71269. /** @hidden */
  71270. _updateNonUniformScalingState(value: boolean): boolean;
  71271. /**
  71272. * Attach the current TransformNode to another TransformNode associated with a bone
  71273. * @param bone Bone affecting the TransformNode
  71274. * @param affectedTransformNode TransformNode associated with the bone
  71275. * @returns this object
  71276. */
  71277. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71278. /**
  71279. * Detach the transform node if its associated with a bone
  71280. * @returns this object
  71281. */
  71282. detachFromBone(): TransformNode;
  71283. private static _rotationAxisCache;
  71284. /**
  71285. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71286. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71287. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71288. * The passed axis is also normalized.
  71289. * @param axis the axis to rotate around
  71290. * @param amount the amount to rotate in radians
  71291. * @param space Space to rotate in (Default: local)
  71292. * @returns the TransformNode.
  71293. */
  71294. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71295. /**
  71296. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71297. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71298. * The passed axis is also normalized. .
  71299. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71300. * @param point the point to rotate around
  71301. * @param axis the axis to rotate around
  71302. * @param amount the amount to rotate in radians
  71303. * @returns the TransformNode
  71304. */
  71305. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71306. /**
  71307. * Translates the mesh along the axis vector for the passed distance in the given space.
  71308. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71309. * @param axis the axis to translate in
  71310. * @param distance the distance to translate
  71311. * @param space Space to rotate in (Default: local)
  71312. * @returns the TransformNode.
  71313. */
  71314. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71315. /**
  71316. * Adds a rotation step to the mesh current rotation.
  71317. * x, y, z are Euler angles expressed in radians.
  71318. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71319. * This means this rotation is made in the mesh local space only.
  71320. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71321. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71322. * ```javascript
  71323. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71324. * ```
  71325. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71326. * 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.
  71327. * @param x Rotation to add
  71328. * @param y Rotation to add
  71329. * @param z Rotation to add
  71330. * @returns the TransformNode.
  71331. */
  71332. addRotation(x: number, y: number, z: number): TransformNode;
  71333. /**
  71334. * @hidden
  71335. */
  71336. protected _getEffectiveParent(): Nullable<Node>;
  71337. /**
  71338. * Computes the world matrix of the node
  71339. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71340. * @returns the world matrix
  71341. */
  71342. computeWorldMatrix(force?: boolean): Matrix;
  71343. protected _afterComputeWorldMatrix(): void;
  71344. /**
  71345. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71346. * @param func callback function to add
  71347. *
  71348. * @returns the TransformNode.
  71349. */
  71350. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71351. /**
  71352. * Removes a registered callback function.
  71353. * @param func callback function to remove
  71354. * @returns the TransformNode.
  71355. */
  71356. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71357. /**
  71358. * Gets the position of the current mesh in camera space
  71359. * @param camera defines the camera to use
  71360. * @returns a position
  71361. */
  71362. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71363. /**
  71364. * Returns the distance from the mesh to the active camera
  71365. * @param camera defines the camera to use
  71366. * @returns the distance
  71367. */
  71368. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71369. /**
  71370. * Clone the current transform node
  71371. * @param name Name of the new clone
  71372. * @param newParent New parent for the clone
  71373. * @param doNotCloneChildren Do not clone children hierarchy
  71374. * @returns the new transform node
  71375. */
  71376. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71377. /**
  71378. * Serializes the objects information.
  71379. * @param currentSerializationObject defines the object to serialize in
  71380. * @returns the serialized object
  71381. */
  71382. serialize(currentSerializationObject?: any): any;
  71383. /**
  71384. * Returns a new TransformNode object parsed from the source provided.
  71385. * @param parsedTransformNode is the source.
  71386. * @param scene the scne the object belongs to
  71387. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71388. * @returns a new TransformNode object parsed from the source provided.
  71389. */
  71390. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71391. /**
  71392. * Get all child-transformNodes of this node
  71393. * @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
  71394. * @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
  71395. * @returns an array of TransformNode
  71396. */
  71397. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71398. /**
  71399. * Releases resources associated with this transform node.
  71400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71402. */
  71403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71404. }
  71405. }
  71406. declare module BABYLON {
  71407. /**
  71408. * Class used to override all child animations of a given target
  71409. */
  71410. export class AnimationPropertiesOverride {
  71411. /**
  71412. * Gets or sets a value indicating if animation blending must be used
  71413. */
  71414. enableBlending: boolean;
  71415. /**
  71416. * Gets or sets the blending speed to use when enableBlending is true
  71417. */
  71418. blendingSpeed: number;
  71419. /**
  71420. * Gets or sets the default loop mode to use
  71421. */
  71422. loopMode: number;
  71423. }
  71424. }
  71425. declare module BABYLON {
  71426. /**
  71427. * Class used to store bone information
  71428. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71429. */
  71430. export class Bone extends Node {
  71431. /**
  71432. * defines the bone name
  71433. */
  71434. name: string;
  71435. private static _tmpVecs;
  71436. private static _tmpQuat;
  71437. private static _tmpMats;
  71438. /**
  71439. * Gets the list of child bones
  71440. */
  71441. children: Bone[];
  71442. /** Gets the animations associated with this bone */
  71443. animations: Animation[];
  71444. /**
  71445. * Gets or sets bone length
  71446. */
  71447. length: number;
  71448. /**
  71449. * @hidden Internal only
  71450. * Set this value to map this bone to a different index in the transform matrices
  71451. * Set this value to -1 to exclude the bone from the transform matrices
  71452. */
  71453. _index: Nullable<number>;
  71454. private _skeleton;
  71455. private _localMatrix;
  71456. private _restPose;
  71457. private _baseMatrix;
  71458. private _absoluteTransform;
  71459. private _invertedAbsoluteTransform;
  71460. private _parent;
  71461. private _scalingDeterminant;
  71462. private _worldTransform;
  71463. private _localScaling;
  71464. private _localRotation;
  71465. private _localPosition;
  71466. private _needToDecompose;
  71467. private _needToCompose;
  71468. /** @hidden */
  71469. _linkedTransformNode: Nullable<TransformNode>;
  71470. /** @hidden */
  71471. _waitingTransformNodeId: Nullable<string>;
  71472. /** @hidden */
  71473. /** @hidden */
  71474. _matrix: Matrix;
  71475. /**
  71476. * Create a new bone
  71477. * @param name defines the bone name
  71478. * @param skeleton defines the parent skeleton
  71479. * @param parentBone defines the parent (can be null if the bone is the root)
  71480. * @param localMatrix defines the local matrix
  71481. * @param restPose defines the rest pose matrix
  71482. * @param baseMatrix defines the base matrix
  71483. * @param index defines index of the bone in the hiearchy
  71484. */
  71485. constructor(
  71486. /**
  71487. * defines the bone name
  71488. */
  71489. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71490. /**
  71491. * Gets the current object class name.
  71492. * @return the class name
  71493. */
  71494. getClassName(): string;
  71495. /**
  71496. * Gets the parent skeleton
  71497. * @returns a skeleton
  71498. */
  71499. getSkeleton(): Skeleton;
  71500. /**
  71501. * Gets parent bone
  71502. * @returns a bone or null if the bone is the root of the bone hierarchy
  71503. */
  71504. getParent(): Nullable<Bone>;
  71505. /**
  71506. * Returns an array containing the root bones
  71507. * @returns an array containing the root bones
  71508. */
  71509. getChildren(): Array<Bone>;
  71510. /**
  71511. * Sets the parent bone
  71512. * @param parent defines the parent (can be null if the bone is the root)
  71513. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71514. */
  71515. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71516. /**
  71517. * Gets the local matrix
  71518. * @returns a matrix
  71519. */
  71520. getLocalMatrix(): Matrix;
  71521. /**
  71522. * Gets the base matrix (initial matrix which remains unchanged)
  71523. * @returns a matrix
  71524. */
  71525. getBaseMatrix(): Matrix;
  71526. /**
  71527. * Gets the rest pose matrix
  71528. * @returns a matrix
  71529. */
  71530. getRestPose(): Matrix;
  71531. /**
  71532. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71533. */
  71534. getWorldMatrix(): Matrix;
  71535. /**
  71536. * Sets the local matrix to rest pose matrix
  71537. */
  71538. returnToRest(): void;
  71539. /**
  71540. * Gets the inverse of the absolute transform matrix.
  71541. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71542. * @returns a matrix
  71543. */
  71544. getInvertedAbsoluteTransform(): Matrix;
  71545. /**
  71546. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71547. * @returns a matrix
  71548. */
  71549. getAbsoluteTransform(): Matrix;
  71550. /**
  71551. * Links with the given transform node.
  71552. * The local matrix of this bone is copied from the transform node every frame.
  71553. * @param transformNode defines the transform node to link to
  71554. */
  71555. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71556. /** Gets or sets current position (in local space) */
  71557. position: Vector3;
  71558. /** Gets or sets current rotation (in local space) */
  71559. rotation: Vector3;
  71560. /** Gets or sets current rotation quaternion (in local space) */
  71561. rotationQuaternion: Quaternion;
  71562. /** Gets or sets current scaling (in local space) */
  71563. scaling: Vector3;
  71564. /**
  71565. * Gets the animation properties override
  71566. */
  71567. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71568. private _decompose;
  71569. private _compose;
  71570. /**
  71571. * Update the base and local matrices
  71572. * @param matrix defines the new base or local matrix
  71573. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71574. * @param updateLocalMatrix defines if the local matrix should be updated
  71575. */
  71576. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71577. /** @hidden */
  71578. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71579. /**
  71580. * Flag the bone as dirty (Forcing it to update everything)
  71581. */
  71582. markAsDirty(): void;
  71583. /** @hidden */
  71584. _markAsDirtyAndCompose(): void;
  71585. private _markAsDirtyAndDecompose;
  71586. /**
  71587. * Translate the bone in local or world space
  71588. * @param vec The amount to translate the bone
  71589. * @param space The space that the translation is in
  71590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71591. */
  71592. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71593. /**
  71594. * Set the postion of the bone in local or world space
  71595. * @param position The position to set the bone
  71596. * @param space The space that the position is in
  71597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71598. */
  71599. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71600. /**
  71601. * Set the absolute position of the bone (world space)
  71602. * @param position The position to set the bone
  71603. * @param mesh The mesh that this bone is attached to
  71604. */
  71605. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71606. /**
  71607. * Scale the bone on the x, y and z axes (in local space)
  71608. * @param x The amount to scale the bone on the x axis
  71609. * @param y The amount to scale the bone on the y axis
  71610. * @param z The amount to scale the bone on the z axis
  71611. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71612. */
  71613. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  71614. /**
  71615. * Set the bone scaling in local space
  71616. * @param scale defines the scaling vector
  71617. */
  71618. setScale(scale: Vector3): void;
  71619. /**
  71620. * Gets the current scaling in local space
  71621. * @returns the current scaling vector
  71622. */
  71623. getScale(): Vector3;
  71624. /**
  71625. * Gets the current scaling in local space and stores it in a target vector
  71626. * @param result defines the target vector
  71627. */
  71628. getScaleToRef(result: Vector3): void;
  71629. /**
  71630. * Set the yaw, pitch, and roll of the bone in local or world space
  71631. * @param yaw The rotation of the bone on the y axis
  71632. * @param pitch The rotation of the bone on the x axis
  71633. * @param roll The rotation of the bone on the z axis
  71634. * @param space The space that the axes of rotation are in
  71635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71636. */
  71637. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  71638. /**
  71639. * Add a rotation to the bone on an axis in local or world space
  71640. * @param axis The axis to rotate the bone on
  71641. * @param amount The amount to rotate the bone
  71642. * @param space The space that the axis is in
  71643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71644. */
  71645. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  71646. /**
  71647. * Set the rotation of the bone to a particular axis angle in local or world space
  71648. * @param axis The axis to rotate the bone on
  71649. * @param angle The angle that the bone should be rotated to
  71650. * @param space The space that the axis is in
  71651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71652. */
  71653. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  71654. /**
  71655. * Set the euler rotation of the bone in local of world space
  71656. * @param rotation The euler rotation that the bone should be set to
  71657. * @param space The space that the rotation is in
  71658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71659. */
  71660. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71661. /**
  71662. * Set the quaternion rotation of the bone in local of world space
  71663. * @param quat The quaternion rotation that the bone should be set to
  71664. * @param space The space that the rotation is in
  71665. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71666. */
  71667. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  71668. /**
  71669. * Set the rotation matrix of the bone in local of world space
  71670. * @param rotMat The rotation matrix that the bone should be set to
  71671. * @param space The space that the rotation is in
  71672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71673. */
  71674. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  71675. private _rotateWithMatrix;
  71676. private _getNegativeRotationToRef;
  71677. /**
  71678. * Get the position of the bone in local or world space
  71679. * @param space The space that the returned position is in
  71680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71681. * @returns The position of the bone
  71682. */
  71683. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71684. /**
  71685. * Copy the position of the bone to a vector3 in local or world space
  71686. * @param space The space that the returned position is in
  71687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71688. * @param result The vector3 to copy the position to
  71689. */
  71690. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  71691. /**
  71692. * Get the absolute position of the bone (world space)
  71693. * @param mesh The mesh that this bone is attached to
  71694. * @returns The absolute position of the bone
  71695. */
  71696. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  71697. /**
  71698. * Copy the absolute position of the bone (world space) to the result param
  71699. * @param mesh The mesh that this bone is attached to
  71700. * @param result The vector3 to copy the absolute position to
  71701. */
  71702. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  71703. /**
  71704. * Compute the absolute transforms of this bone and its children
  71705. */
  71706. computeAbsoluteTransforms(): void;
  71707. /**
  71708. * Get the world direction from an axis that is in the local space of the bone
  71709. * @param localAxis The local direction that is used to compute the world direction
  71710. * @param mesh The mesh that this bone is attached to
  71711. * @returns The world direction
  71712. */
  71713. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71714. /**
  71715. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  71716. * @param localAxis The local direction that is used to compute the world direction
  71717. * @param mesh The mesh that this bone is attached to
  71718. * @param result The vector3 that the world direction will be copied to
  71719. */
  71720. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71721. /**
  71722. * Get the euler rotation of the bone in local or world space
  71723. * @param space The space that the rotation should be in
  71724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71725. * @returns The euler rotation
  71726. */
  71727. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71728. /**
  71729. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  71730. * @param space The space that the rotation should be in
  71731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71732. * @param result The vector3 that the rotation should be copied to
  71733. */
  71734. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71735. /**
  71736. * Get the quaternion rotation of the bone in either local or world space
  71737. * @param space The space that the rotation should be in
  71738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71739. * @returns The quaternion rotation
  71740. */
  71741. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  71742. /**
  71743. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  71744. * @param space The space that the rotation should be in
  71745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71746. * @param result The quaternion that the rotation should be copied to
  71747. */
  71748. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  71749. /**
  71750. * Get the rotation matrix of the bone in local or world space
  71751. * @param space The space that the rotation should be in
  71752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71753. * @returns The rotation matrix
  71754. */
  71755. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  71756. /**
  71757. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  71758. * @param space The space that the rotation should be in
  71759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71760. * @param result The quaternion that the rotation should be copied to
  71761. */
  71762. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  71763. /**
  71764. * Get the world position of a point that is in the local space of the bone
  71765. * @param position The local position
  71766. * @param mesh The mesh that this bone is attached to
  71767. * @returns The world position
  71768. */
  71769. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71770. /**
  71771. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  71772. * @param position The local position
  71773. * @param mesh The mesh that this bone is attached to
  71774. * @param result The vector3 that the world position should be copied to
  71775. */
  71776. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71777. /**
  71778. * Get the local position of a point that is in world space
  71779. * @param position The world position
  71780. * @param mesh The mesh that this bone is attached to
  71781. * @returns The local position
  71782. */
  71783. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71784. /**
  71785. * Get the local position of a point that is in world space and copy it to the result param
  71786. * @param position The world position
  71787. * @param mesh The mesh that this bone is attached to
  71788. * @param result The vector3 that the local position should be copied to
  71789. */
  71790. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71791. }
  71792. }
  71793. declare module BABYLON {
  71794. interface Engine {
  71795. /**
  71796. * Creates a raw texture
  71797. * @param data defines the data to store in the texture
  71798. * @param width defines the width of the texture
  71799. * @param height defines the height of the texture
  71800. * @param format defines the format of the data
  71801. * @param generateMipMaps defines if the engine should generate the mip levels
  71802. * @param invertY defines if data must be stored with Y axis inverted
  71803. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71804. * @param compression defines the compression used (null by default)
  71805. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71806. * @returns the raw texture inside an InternalTexture
  71807. */
  71808. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  71809. /**
  71810. * Update a raw texture
  71811. * @param texture defines the texture to update
  71812. * @param data defines the data to store in the texture
  71813. * @param format defines the format of the data
  71814. * @param invertY defines if data must be stored with Y axis inverted
  71815. */
  71816. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71817. /**
  71818. * Update a raw texture
  71819. * @param texture defines the texture to update
  71820. * @param data defines the data to store in the texture
  71821. * @param format defines the format of the data
  71822. * @param invertY defines if data must be stored with Y axis inverted
  71823. * @param compression defines the compression used (null by default)
  71824. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71825. */
  71826. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  71827. /**
  71828. * Creates a new raw cube texture
  71829. * @param data defines the array of data to use to create each face
  71830. * @param size defines the size of the textures
  71831. * @param format defines the format of the data
  71832. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71833. * @param generateMipMaps defines if the engine should generate the mip levels
  71834. * @param invertY defines if data must be stored with Y axis inverted
  71835. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71836. * @param compression defines the compression used (null by default)
  71837. * @returns the cube texture as an InternalTexture
  71838. */
  71839. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  71840. /**
  71841. * Update a raw cube texture
  71842. * @param texture defines the texture to udpdate
  71843. * @param data defines the data to store
  71844. * @param format defines the data format
  71845. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71846. * @param invertY defines if data must be stored with Y axis inverted
  71847. */
  71848. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  71849. /**
  71850. * Update a raw cube texture
  71851. * @param texture defines the texture to udpdate
  71852. * @param data defines the data to store
  71853. * @param format defines the data format
  71854. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71855. * @param invertY defines if data must be stored with Y axis inverted
  71856. * @param compression defines the compression used (null by default)
  71857. */
  71858. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  71859. /**
  71860. * Update a raw cube texture
  71861. * @param texture defines the texture to udpdate
  71862. * @param data defines the data to store
  71863. * @param format defines the data format
  71864. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71865. * @param invertY defines if data must be stored with Y axis inverted
  71866. * @param compression defines the compression used (null by default)
  71867. * @param level defines which level of the texture to update
  71868. */
  71869. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  71870. /**
  71871. * Creates a new raw cube texture from a specified url
  71872. * @param url defines the url where the data is located
  71873. * @param scene defines the current scene
  71874. * @param size defines the size of the textures
  71875. * @param format defines the format of the data
  71876. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71877. * @param noMipmap defines if the engine should avoid generating the mip levels
  71878. * @param callback defines a callback used to extract texture data from loaded data
  71879. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71880. * @param onLoad defines a callback called when texture is loaded
  71881. * @param onError defines a callback called if there is an error
  71882. * @returns the cube texture as an InternalTexture
  71883. */
  71884. 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;
  71885. /**
  71886. * Creates a new raw cube texture from a specified url
  71887. * @param url defines the url where the data is located
  71888. * @param scene defines the current scene
  71889. * @param size defines the size of the textures
  71890. * @param format defines the format of the data
  71891. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71892. * @param noMipmap defines if the engine should avoid generating the mip levels
  71893. * @param callback defines a callback used to extract texture data from loaded data
  71894. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71895. * @param onLoad defines a callback called when texture is loaded
  71896. * @param onError defines a callback called if there is an error
  71897. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71898. * @param invertY defines if data must be stored with Y axis inverted
  71899. * @returns the cube texture as an InternalTexture
  71900. */
  71901. 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;
  71902. /**
  71903. * Creates a new raw 3D texture
  71904. * @param data defines the data used to create the texture
  71905. * @param width defines the width of the texture
  71906. * @param height defines the height of the texture
  71907. * @param depth defines the depth of the texture
  71908. * @param format defines the format of the texture
  71909. * @param generateMipMaps defines if the engine must generate mip levels
  71910. * @param invertY defines if data must be stored with Y axis inverted
  71911. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71912. * @param compression defines the compressed used (can be null)
  71913. * @param textureType defines the compressed used (can be null)
  71914. * @returns a new raw 3D texture (stored in an InternalTexture)
  71915. */
  71916. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  71917. /**
  71918. * Update a raw 3D texture
  71919. * @param texture defines the texture to update
  71920. * @param data defines the data to store
  71921. * @param format defines the data format
  71922. * @param invertY defines if data must be stored with Y axis inverted
  71923. */
  71924. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71925. /**
  71926. * Update a raw 3D texture
  71927. * @param texture defines the texture to update
  71928. * @param data defines the data to store
  71929. * @param format defines the data format
  71930. * @param invertY defines if data must be stored with Y axis inverted
  71931. * @param compression defines the used compression (can be null)
  71932. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  71933. */
  71934. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  71935. }
  71936. }
  71937. declare module BABYLON {
  71938. /**
  71939. * Raw texture can help creating a texture directly from an array of data.
  71940. * This can be super useful if you either get the data from an uncompressed source or
  71941. * if you wish to create your texture pixel by pixel.
  71942. */
  71943. export class RawTexture extends Texture {
  71944. /**
  71945. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  71946. */
  71947. format: number;
  71948. private _engine;
  71949. /**
  71950. * Instantiates a new RawTexture.
  71951. * Raw texture can help creating a texture directly from an array of data.
  71952. * This can be super useful if you either get the data from an uncompressed source or
  71953. * if you wish to create your texture pixel by pixel.
  71954. * @param data define the array of data to use to create the texture
  71955. * @param width define the width of the texture
  71956. * @param height define the height of the texture
  71957. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  71958. * @param scene define the scene the texture belongs to
  71959. * @param generateMipMaps define whether mip maps should be generated or not
  71960. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  71961. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  71962. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  71963. */
  71964. constructor(data: ArrayBufferView, width: number, height: number,
  71965. /**
  71966. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  71967. */
  71968. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  71969. /**
  71970. * Updates the texture underlying data.
  71971. * @param data Define the new data of the texture
  71972. */
  71973. update(data: ArrayBufferView): void;
  71974. /**
  71975. * Creates a luminance texture from some data.
  71976. * @param data Define the texture data
  71977. * @param width Define the width of the texture
  71978. * @param height Define the height of the texture
  71979. * @param scene Define the scene the texture belongs to
  71980. * @param generateMipMaps Define whether or not to create mip maps for the texture
  71981. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  71982. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  71983. * @returns the luminance texture
  71984. */
  71985. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  71986. /**
  71987. * Creates a luminance alpha texture from some data.
  71988. * @param data Define the texture data
  71989. * @param width Define the width of the texture
  71990. * @param height Define the height of the texture
  71991. * @param scene Define the scene the texture belongs to
  71992. * @param generateMipMaps Define whether or not to create mip maps for the texture
  71993. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  71994. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  71995. * @returns the luminance alpha texture
  71996. */
  71997. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  71998. /**
  71999. * Creates an alpha texture from some data.
  72000. * @param data Define the texture data
  72001. * @param width Define the width of the texture
  72002. * @param height Define the height of the texture
  72003. * @param scene Define the scene the texture belongs to
  72004. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72005. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72006. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72007. * @returns the alpha texture
  72008. */
  72009. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72010. /**
  72011. * Creates a RGB texture from some data.
  72012. * @param data Define the texture data
  72013. * @param width Define the width of the texture
  72014. * @param height Define the height of the texture
  72015. * @param scene Define the scene the texture belongs to
  72016. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72017. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72018. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72019. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72020. * @returns the RGB alpha texture
  72021. */
  72022. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72023. /**
  72024. * Creates a RGBA texture from some data.
  72025. * @param data Define the texture data
  72026. * @param width Define the width of the texture
  72027. * @param height Define the height of the texture
  72028. * @param scene Define the scene the texture belongs to
  72029. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72030. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72031. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72032. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72033. * @returns the RGBA texture
  72034. */
  72035. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72036. /**
  72037. * Creates a R texture from some data.
  72038. * @param data Define the texture data
  72039. * @param width Define the width of the texture
  72040. * @param height Define the height of the texture
  72041. * @param scene Define the scene the texture belongs to
  72042. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72043. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72044. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72045. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72046. * @returns the R texture
  72047. */
  72048. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72049. }
  72050. }
  72051. declare module BABYLON {
  72052. /**
  72053. * Defines a runtime animation
  72054. */
  72055. export class RuntimeAnimation {
  72056. private _events;
  72057. /**
  72058. * The current frame of the runtime animation
  72059. */
  72060. private _currentFrame;
  72061. /**
  72062. * The animation used by the runtime animation
  72063. */
  72064. private _animation;
  72065. /**
  72066. * The target of the runtime animation
  72067. */
  72068. private _target;
  72069. /**
  72070. * The initiating animatable
  72071. */
  72072. private _host;
  72073. /**
  72074. * The original value of the runtime animation
  72075. */
  72076. private _originalValue;
  72077. /**
  72078. * The original blend value of the runtime animation
  72079. */
  72080. private _originalBlendValue;
  72081. /**
  72082. * The offsets cache of the runtime animation
  72083. */
  72084. private _offsetsCache;
  72085. /**
  72086. * The high limits cache of the runtime animation
  72087. */
  72088. private _highLimitsCache;
  72089. /**
  72090. * Specifies if the runtime animation has been stopped
  72091. */
  72092. private _stopped;
  72093. /**
  72094. * The blending factor of the runtime animation
  72095. */
  72096. private _blendingFactor;
  72097. /**
  72098. * The BabylonJS scene
  72099. */
  72100. private _scene;
  72101. /**
  72102. * The current value of the runtime animation
  72103. */
  72104. private _currentValue;
  72105. /** @hidden */
  72106. _animationState: _IAnimationState;
  72107. /**
  72108. * The active target of the runtime animation
  72109. */
  72110. private _activeTargets;
  72111. private _currentActiveTarget;
  72112. private _directTarget;
  72113. /**
  72114. * The target path of the runtime animation
  72115. */
  72116. private _targetPath;
  72117. /**
  72118. * The weight of the runtime animation
  72119. */
  72120. private _weight;
  72121. /**
  72122. * The ratio offset of the runtime animation
  72123. */
  72124. private _ratioOffset;
  72125. /**
  72126. * The previous delay of the runtime animation
  72127. */
  72128. private _previousDelay;
  72129. /**
  72130. * The previous ratio of the runtime animation
  72131. */
  72132. private _previousRatio;
  72133. private _enableBlending;
  72134. private _keys;
  72135. private _minFrame;
  72136. private _maxFrame;
  72137. private _minValue;
  72138. private _maxValue;
  72139. private _targetIsArray;
  72140. /**
  72141. * Gets the current frame of the runtime animation
  72142. */
  72143. readonly currentFrame: number;
  72144. /**
  72145. * Gets the weight of the runtime animation
  72146. */
  72147. readonly weight: number;
  72148. /**
  72149. * Gets the current value of the runtime animation
  72150. */
  72151. readonly currentValue: any;
  72152. /**
  72153. * Gets the target path of the runtime animation
  72154. */
  72155. readonly targetPath: string;
  72156. /**
  72157. * Gets the actual target of the runtime animation
  72158. */
  72159. readonly target: any;
  72160. /** @hidden */
  72161. _onLoop: () => void;
  72162. /**
  72163. * Create a new RuntimeAnimation object
  72164. * @param target defines the target of the animation
  72165. * @param animation defines the source animation object
  72166. * @param scene defines the hosting scene
  72167. * @param host defines the initiating Animatable
  72168. */
  72169. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72170. private _preparePath;
  72171. /**
  72172. * Gets the animation from the runtime animation
  72173. */
  72174. readonly animation: Animation;
  72175. /**
  72176. * Resets the runtime animation to the beginning
  72177. * @param restoreOriginal defines whether to restore the target property to the original value
  72178. */
  72179. reset(restoreOriginal?: boolean): void;
  72180. /**
  72181. * Specifies if the runtime animation is stopped
  72182. * @returns Boolean specifying if the runtime animation is stopped
  72183. */
  72184. isStopped(): boolean;
  72185. /**
  72186. * Disposes of the runtime animation
  72187. */
  72188. dispose(): void;
  72189. /**
  72190. * Apply the interpolated value to the target
  72191. * @param currentValue defines the value computed by the animation
  72192. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72193. */
  72194. setValue(currentValue: any, weight: number): void;
  72195. private _getOriginalValues;
  72196. private _setValue;
  72197. /**
  72198. * Gets the loop pmode of the runtime animation
  72199. * @returns Loop Mode
  72200. */
  72201. private _getCorrectLoopMode;
  72202. /**
  72203. * Move the current animation to a given frame
  72204. * @param frame defines the frame to move to
  72205. */
  72206. goToFrame(frame: number): void;
  72207. /**
  72208. * @hidden Internal use only
  72209. */
  72210. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72211. /**
  72212. * Execute the current animation
  72213. * @param delay defines the delay to add to the current frame
  72214. * @param from defines the lower bound of the animation range
  72215. * @param to defines the upper bound of the animation range
  72216. * @param loop defines if the current animation must loop
  72217. * @param speedRatio defines the current speed ratio
  72218. * @param weight defines the weight of the animation (default is -1 so no weight)
  72219. * @param onLoop optional callback called when animation loops
  72220. * @returns a boolean indicating if the animation is running
  72221. */
  72222. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72223. }
  72224. }
  72225. declare module BABYLON {
  72226. /**
  72227. * Class used to store an actual running animation
  72228. */
  72229. export class Animatable {
  72230. /** defines the target object */
  72231. target: any;
  72232. /** defines the starting frame number (default is 0) */
  72233. fromFrame: number;
  72234. /** defines the ending frame number (default is 100) */
  72235. toFrame: number;
  72236. /** defines if the animation must loop (default is false) */
  72237. loopAnimation: boolean;
  72238. /** defines a callback to call when animation ends if it is not looping */
  72239. onAnimationEnd?: (() => void) | null | undefined;
  72240. /** defines a callback to call when animation loops */
  72241. onAnimationLoop?: (() => void) | null | undefined;
  72242. private _localDelayOffset;
  72243. private _pausedDelay;
  72244. private _runtimeAnimations;
  72245. private _paused;
  72246. private _scene;
  72247. private _speedRatio;
  72248. private _weight;
  72249. private _syncRoot;
  72250. /**
  72251. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72252. * This will only apply for non looping animation (default is true)
  72253. */
  72254. disposeOnEnd: boolean;
  72255. /**
  72256. * Gets a boolean indicating if the animation has started
  72257. */
  72258. animationStarted: boolean;
  72259. /**
  72260. * Observer raised when the animation ends
  72261. */
  72262. onAnimationEndObservable: Observable<Animatable>;
  72263. /**
  72264. * Observer raised when the animation loops
  72265. */
  72266. onAnimationLoopObservable: Observable<Animatable>;
  72267. /**
  72268. * Gets the root Animatable used to synchronize and normalize animations
  72269. */
  72270. readonly syncRoot: Nullable<Animatable>;
  72271. /**
  72272. * Gets the current frame of the first RuntimeAnimation
  72273. * Used to synchronize Animatables
  72274. */
  72275. readonly masterFrame: number;
  72276. /**
  72277. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72278. */
  72279. weight: number;
  72280. /**
  72281. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72282. */
  72283. speedRatio: number;
  72284. /**
  72285. * Creates a new Animatable
  72286. * @param scene defines the hosting scene
  72287. * @param target defines the target object
  72288. * @param fromFrame defines the starting frame number (default is 0)
  72289. * @param toFrame defines the ending frame number (default is 100)
  72290. * @param loopAnimation defines if the animation must loop (default is false)
  72291. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72292. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72293. * @param animations defines a group of animation to add to the new Animatable
  72294. * @param onAnimationLoop defines a callback to call when animation loops
  72295. */
  72296. constructor(scene: Scene,
  72297. /** defines the target object */
  72298. target: any,
  72299. /** defines the starting frame number (default is 0) */
  72300. fromFrame?: number,
  72301. /** defines the ending frame number (default is 100) */
  72302. toFrame?: number,
  72303. /** defines if the animation must loop (default is false) */
  72304. loopAnimation?: boolean, speedRatio?: number,
  72305. /** defines a callback to call when animation ends if it is not looping */
  72306. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72307. /** defines a callback to call when animation loops */
  72308. onAnimationLoop?: (() => void) | null | undefined);
  72309. /**
  72310. * Synchronize and normalize current Animatable with a source Animatable
  72311. * This is useful when using animation weights and when animations are not of the same length
  72312. * @param root defines the root Animatable to synchronize with
  72313. * @returns the current Animatable
  72314. */
  72315. syncWith(root: Animatable): Animatable;
  72316. /**
  72317. * Gets the list of runtime animations
  72318. * @returns an array of RuntimeAnimation
  72319. */
  72320. getAnimations(): RuntimeAnimation[];
  72321. /**
  72322. * Adds more animations to the current animatable
  72323. * @param target defines the target of the animations
  72324. * @param animations defines the new animations to add
  72325. */
  72326. appendAnimations(target: any, animations: Animation[]): void;
  72327. /**
  72328. * Gets the source animation for a specific property
  72329. * @param property defines the propertyu to look for
  72330. * @returns null or the source animation for the given property
  72331. */
  72332. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72333. /**
  72334. * Gets the runtime animation for a specific property
  72335. * @param property defines the propertyu to look for
  72336. * @returns null or the runtime animation for the given property
  72337. */
  72338. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72339. /**
  72340. * Resets the animatable to its original state
  72341. */
  72342. reset(): void;
  72343. /**
  72344. * Allows the animatable to blend with current running animations
  72345. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72346. * @param blendingSpeed defines the blending speed to use
  72347. */
  72348. enableBlending(blendingSpeed: number): void;
  72349. /**
  72350. * Disable animation blending
  72351. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72352. */
  72353. disableBlending(): void;
  72354. /**
  72355. * Jump directly to a given frame
  72356. * @param frame defines the frame to jump to
  72357. */
  72358. goToFrame(frame: number): void;
  72359. /**
  72360. * Pause the animation
  72361. */
  72362. pause(): void;
  72363. /**
  72364. * Restart the animation
  72365. */
  72366. restart(): void;
  72367. private _raiseOnAnimationEnd;
  72368. /**
  72369. * Stop and delete the current animation
  72370. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72371. * @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)
  72372. */
  72373. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72374. /**
  72375. * Wait asynchronously for the animation to end
  72376. * @returns a promise which will be fullfilled when the animation ends
  72377. */
  72378. waitAsync(): Promise<Animatable>;
  72379. /** @hidden */
  72380. _animate(delay: number): boolean;
  72381. }
  72382. interface Scene {
  72383. /** @hidden */
  72384. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72385. /** @hidden */
  72386. _processLateAnimationBindingsForMatrices(holder: {
  72387. totalWeight: number;
  72388. animations: RuntimeAnimation[];
  72389. originalValue: Matrix;
  72390. }): any;
  72391. /** @hidden */
  72392. _processLateAnimationBindingsForQuaternions(holder: {
  72393. totalWeight: number;
  72394. animations: RuntimeAnimation[];
  72395. originalValue: Quaternion;
  72396. }, refQuaternion: Quaternion): Quaternion;
  72397. /** @hidden */
  72398. _processLateAnimationBindings(): void;
  72399. /**
  72400. * Will start the animation sequence of a given target
  72401. * @param target defines the target
  72402. * @param from defines from which frame should animation start
  72403. * @param to defines until which frame should animation run.
  72404. * @param weight defines the weight to apply to the animation (1.0 by default)
  72405. * @param loop defines if the animation loops
  72406. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72407. * @param onAnimationEnd defines the function to be executed when the animation ends
  72408. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72409. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72410. * @param onAnimationLoop defines the callback to call when an animation loops
  72411. * @returns the animatable object created for this animation
  72412. */
  72413. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72414. /**
  72415. * Will start the animation sequence of a given target
  72416. * @param target defines the target
  72417. * @param from defines from which frame should animation start
  72418. * @param to defines until which frame should animation run.
  72419. * @param loop defines if the animation loops
  72420. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72421. * @param onAnimationEnd defines the function to be executed when the animation ends
  72422. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72423. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72424. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72425. * @param onAnimationLoop defines the callback to call when an animation loops
  72426. * @returns the animatable object created for this animation
  72427. */
  72428. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72429. /**
  72430. * Will start the animation sequence of a given target and its hierarchy
  72431. * @param target defines the target
  72432. * @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.
  72433. * @param from defines from which frame should animation start
  72434. * @param to defines until which frame should animation run.
  72435. * @param loop defines if the animation loops
  72436. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72437. * @param onAnimationEnd defines the function to be executed when the animation ends
  72438. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72439. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72440. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72441. * @param onAnimationLoop defines the callback to call when an animation loops
  72442. * @returns the list of created animatables
  72443. */
  72444. 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[];
  72445. /**
  72446. * Begin a new animation on a given node
  72447. * @param target defines the target where the animation will take place
  72448. * @param animations defines the list of animations to start
  72449. * @param from defines the initial value
  72450. * @param to defines the final value
  72451. * @param loop defines if you want animation to loop (off by default)
  72452. * @param speedRatio defines the speed ratio to apply to all animations
  72453. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72454. * @param onAnimationLoop defines the callback to call when an animation loops
  72455. * @returns the list of created animatables
  72456. */
  72457. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72458. /**
  72459. * Begin a new animation on a given node and its hierarchy
  72460. * @param target defines the root node where the animation will take place
  72461. * @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.
  72462. * @param animations defines the list of animations to start
  72463. * @param from defines the initial value
  72464. * @param to defines the final value
  72465. * @param loop defines if you want animation to loop (off by default)
  72466. * @param speedRatio defines the speed ratio to apply to all animations
  72467. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72468. * @param onAnimationLoop defines the callback to call when an animation loops
  72469. * @returns the list of animatables created for all nodes
  72470. */
  72471. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72472. /**
  72473. * Gets the animatable associated with a specific target
  72474. * @param target defines the target of the animatable
  72475. * @returns the required animatable if found
  72476. */
  72477. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72478. /**
  72479. * Gets all animatables associated with a given target
  72480. * @param target defines the target to look animatables for
  72481. * @returns an array of Animatables
  72482. */
  72483. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72484. /**
  72485. * Stops and removes all animations that have been applied to the scene
  72486. */
  72487. stopAllAnimations(): void;
  72488. }
  72489. interface Bone {
  72490. /**
  72491. * Copy an animation range from another bone
  72492. * @param source defines the source bone
  72493. * @param rangeName defines the range name to copy
  72494. * @param frameOffset defines the frame offset
  72495. * @param rescaleAsRequired defines if rescaling must be applied if required
  72496. * @param skelDimensionsRatio defines the scaling ratio
  72497. * @returns true if operation was successful
  72498. */
  72499. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72500. }
  72501. }
  72502. declare module BABYLON {
  72503. /**
  72504. * Class used to handle skinning animations
  72505. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72506. */
  72507. export class Skeleton implements IAnimatable {
  72508. /** defines the skeleton name */
  72509. name: string;
  72510. /** defines the skeleton Id */
  72511. id: string;
  72512. /**
  72513. * Defines the list of child bones
  72514. */
  72515. bones: Bone[];
  72516. /**
  72517. * Defines an estimate of the dimension of the skeleton at rest
  72518. */
  72519. dimensionsAtRest: Vector3;
  72520. /**
  72521. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72522. */
  72523. needInitialSkinMatrix: boolean;
  72524. /**
  72525. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72526. */
  72527. overrideMesh: Nullable<AbstractMesh>;
  72528. /**
  72529. * Gets the list of animations attached to this skeleton
  72530. */
  72531. animations: Array<Animation>;
  72532. private _scene;
  72533. private _isDirty;
  72534. private _transformMatrices;
  72535. private _transformMatrixTexture;
  72536. private _meshesWithPoseMatrix;
  72537. private _animatables;
  72538. private _identity;
  72539. private _synchronizedWithMesh;
  72540. private _ranges;
  72541. private _lastAbsoluteTransformsUpdateId;
  72542. private _canUseTextureForBones;
  72543. private _uniqueId;
  72544. /** @hidden */
  72545. _numBonesWithLinkedTransformNode: number;
  72546. /** @hidden */
  72547. _hasWaitingData: Nullable<boolean>;
  72548. /**
  72549. * Specifies if the skeleton should be serialized
  72550. */
  72551. doNotSerialize: boolean;
  72552. private _useTextureToStoreBoneMatrices;
  72553. /**
  72554. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72555. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  72556. */
  72557. useTextureToStoreBoneMatrices: boolean;
  72558. private _animationPropertiesOverride;
  72559. /**
  72560. * Gets or sets the animation properties override
  72561. */
  72562. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72563. /**
  72564. * List of inspectable custom properties (used by the Inspector)
  72565. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72566. */
  72567. inspectableCustomProperties: IInspectable[];
  72568. /**
  72569. * An observable triggered before computing the skeleton's matrices
  72570. */
  72571. onBeforeComputeObservable: Observable<Skeleton>;
  72572. /**
  72573. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72574. */
  72575. readonly isUsingTextureForMatrices: boolean;
  72576. /**
  72577. * Gets the unique ID of this skeleton
  72578. */
  72579. readonly uniqueId: number;
  72580. /**
  72581. * Creates a new skeleton
  72582. * @param name defines the skeleton name
  72583. * @param id defines the skeleton Id
  72584. * @param scene defines the hosting scene
  72585. */
  72586. constructor(
  72587. /** defines the skeleton name */
  72588. name: string,
  72589. /** defines the skeleton Id */
  72590. id: string, scene: Scene);
  72591. /**
  72592. * Gets the current object class name.
  72593. * @return the class name
  72594. */
  72595. getClassName(): string;
  72596. /**
  72597. * Returns an array containing the root bones
  72598. * @returns an array containing the root bones
  72599. */
  72600. getChildren(): Array<Bone>;
  72601. /**
  72602. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72603. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72604. * @returns a Float32Array containing matrices data
  72605. */
  72606. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72607. /**
  72608. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72609. * @returns a raw texture containing the data
  72610. */
  72611. getTransformMatrixTexture(): Nullable<RawTexture>;
  72612. /**
  72613. * Gets the current hosting scene
  72614. * @returns a scene object
  72615. */
  72616. getScene(): Scene;
  72617. /**
  72618. * Gets a string representing the current skeleton data
  72619. * @param fullDetails defines a boolean indicating if we want a verbose version
  72620. * @returns a string representing the current skeleton data
  72621. */
  72622. toString(fullDetails?: boolean): string;
  72623. /**
  72624. * Get bone's index searching by name
  72625. * @param name defines bone's name to search for
  72626. * @return the indice of the bone. Returns -1 if not found
  72627. */
  72628. getBoneIndexByName(name: string): number;
  72629. /**
  72630. * Creater a new animation range
  72631. * @param name defines the name of the range
  72632. * @param from defines the start key
  72633. * @param to defines the end key
  72634. */
  72635. createAnimationRange(name: string, from: number, to: number): void;
  72636. /**
  72637. * Delete a specific animation range
  72638. * @param name defines the name of the range
  72639. * @param deleteFrames defines if frames must be removed as well
  72640. */
  72641. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  72642. /**
  72643. * Gets a specific animation range
  72644. * @param name defines the name of the range to look for
  72645. * @returns the requested animation range or null if not found
  72646. */
  72647. getAnimationRange(name: string): Nullable<AnimationRange>;
  72648. /**
  72649. * Gets the list of all animation ranges defined on this skeleton
  72650. * @returns an array
  72651. */
  72652. getAnimationRanges(): Nullable<AnimationRange>[];
  72653. /**
  72654. * Copy animation range from a source skeleton.
  72655. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  72656. * @param source defines the source skeleton
  72657. * @param name defines the name of the range to copy
  72658. * @param rescaleAsRequired defines if rescaling must be applied if required
  72659. * @returns true if operation was successful
  72660. */
  72661. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  72662. /**
  72663. * Forces the skeleton to go to rest pose
  72664. */
  72665. returnToRest(): void;
  72666. private _getHighestAnimationFrame;
  72667. /**
  72668. * Begin a specific animation range
  72669. * @param name defines the name of the range to start
  72670. * @param loop defines if looping must be turned on (false by default)
  72671. * @param speedRatio defines the speed ratio to apply (1 by default)
  72672. * @param onAnimationEnd defines a callback which will be called when animation will end
  72673. * @returns a new animatable
  72674. */
  72675. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  72676. /** @hidden */
  72677. _markAsDirty(): void;
  72678. /** @hidden */
  72679. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72680. /** @hidden */
  72681. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72682. private _computeTransformMatrices;
  72683. /**
  72684. * Build all resources required to render a skeleton
  72685. */
  72686. prepare(): void;
  72687. /**
  72688. * Gets the list of animatables currently running for this skeleton
  72689. * @returns an array of animatables
  72690. */
  72691. getAnimatables(): IAnimatable[];
  72692. /**
  72693. * Clone the current skeleton
  72694. * @param name defines the name of the new skeleton
  72695. * @param id defines the id of the new skeleton
  72696. * @returns the new skeleton
  72697. */
  72698. clone(name: string, id: string): Skeleton;
  72699. /**
  72700. * Enable animation blending for this skeleton
  72701. * @param blendingSpeed defines the blending speed to apply
  72702. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72703. */
  72704. enableBlending(blendingSpeed?: number): void;
  72705. /**
  72706. * Releases all resources associated with the current skeleton
  72707. */
  72708. dispose(): void;
  72709. /**
  72710. * Serialize the skeleton in a JSON object
  72711. * @returns a JSON object
  72712. */
  72713. serialize(): any;
  72714. /**
  72715. * Creates a new skeleton from serialized data
  72716. * @param parsedSkeleton defines the serialized data
  72717. * @param scene defines the hosting scene
  72718. * @returns a new skeleton
  72719. */
  72720. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  72721. /**
  72722. * Compute all node absolute transforms
  72723. * @param forceUpdate defines if computation must be done even if cache is up to date
  72724. */
  72725. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  72726. /**
  72727. * Gets the root pose matrix
  72728. * @returns a matrix
  72729. */
  72730. getPoseMatrix(): Nullable<Matrix>;
  72731. /**
  72732. * Sorts bones per internal index
  72733. */
  72734. sortBones(): void;
  72735. private _sortBones;
  72736. }
  72737. }
  72738. declare module BABYLON {
  72739. /**
  72740. * Defines a target to use with MorphTargetManager
  72741. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72742. */
  72743. export class MorphTarget implements IAnimatable {
  72744. /** defines the name of the target */
  72745. name: string;
  72746. /**
  72747. * Gets or sets the list of animations
  72748. */
  72749. animations: Animation[];
  72750. private _scene;
  72751. private _positions;
  72752. private _normals;
  72753. private _tangents;
  72754. private _influence;
  72755. /**
  72756. * Observable raised when the influence changes
  72757. */
  72758. onInfluenceChanged: Observable<boolean>;
  72759. /** @hidden */
  72760. _onDataLayoutChanged: Observable<void>;
  72761. /**
  72762. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  72763. */
  72764. influence: number;
  72765. /**
  72766. * Gets or sets the id of the morph Target
  72767. */
  72768. id: string;
  72769. private _animationPropertiesOverride;
  72770. /**
  72771. * Gets or sets the animation properties override
  72772. */
  72773. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72774. /**
  72775. * Creates a new MorphTarget
  72776. * @param name defines the name of the target
  72777. * @param influence defines the influence to use
  72778. * @param scene defines the scene the morphtarget belongs to
  72779. */
  72780. constructor(
  72781. /** defines the name of the target */
  72782. name: string, influence?: number, scene?: Nullable<Scene>);
  72783. /**
  72784. * Gets a boolean defining if the target contains position data
  72785. */
  72786. readonly hasPositions: boolean;
  72787. /**
  72788. * Gets a boolean defining if the target contains normal data
  72789. */
  72790. readonly hasNormals: boolean;
  72791. /**
  72792. * Gets a boolean defining if the target contains tangent data
  72793. */
  72794. readonly hasTangents: boolean;
  72795. /**
  72796. * Affects position data to this target
  72797. * @param data defines the position data to use
  72798. */
  72799. setPositions(data: Nullable<FloatArray>): void;
  72800. /**
  72801. * Gets the position data stored in this target
  72802. * @returns a FloatArray containing the position data (or null if not present)
  72803. */
  72804. getPositions(): Nullable<FloatArray>;
  72805. /**
  72806. * Affects normal data to this target
  72807. * @param data defines the normal data to use
  72808. */
  72809. setNormals(data: Nullable<FloatArray>): void;
  72810. /**
  72811. * Gets the normal data stored in this target
  72812. * @returns a FloatArray containing the normal data (or null if not present)
  72813. */
  72814. getNormals(): Nullable<FloatArray>;
  72815. /**
  72816. * Affects tangent data to this target
  72817. * @param data defines the tangent data to use
  72818. */
  72819. setTangents(data: Nullable<FloatArray>): void;
  72820. /**
  72821. * Gets the tangent data stored in this target
  72822. * @returns a FloatArray containing the tangent data (or null if not present)
  72823. */
  72824. getTangents(): Nullable<FloatArray>;
  72825. /**
  72826. * Serializes the current target into a Serialization object
  72827. * @returns the serialized object
  72828. */
  72829. serialize(): any;
  72830. /**
  72831. * Returns the string "MorphTarget"
  72832. * @returns "MorphTarget"
  72833. */
  72834. getClassName(): string;
  72835. /**
  72836. * Creates a new target from serialized data
  72837. * @param serializationObject defines the serialized data to use
  72838. * @returns a new MorphTarget
  72839. */
  72840. static Parse(serializationObject: any): MorphTarget;
  72841. /**
  72842. * Creates a MorphTarget from mesh data
  72843. * @param mesh defines the source mesh
  72844. * @param name defines the name to use for the new target
  72845. * @param influence defines the influence to attach to the target
  72846. * @returns a new MorphTarget
  72847. */
  72848. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  72849. }
  72850. }
  72851. declare module BABYLON {
  72852. /**
  72853. * This class is used to deform meshes using morphing between different targets
  72854. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72855. */
  72856. export class MorphTargetManager {
  72857. private _targets;
  72858. private _targetInfluenceChangedObservers;
  72859. private _targetDataLayoutChangedObservers;
  72860. private _activeTargets;
  72861. private _scene;
  72862. private _influences;
  72863. private _supportsNormals;
  72864. private _supportsTangents;
  72865. private _vertexCount;
  72866. private _uniqueId;
  72867. private _tempInfluences;
  72868. /**
  72869. * Creates a new MorphTargetManager
  72870. * @param scene defines the current scene
  72871. */
  72872. constructor(scene?: Nullable<Scene>);
  72873. /**
  72874. * Gets the unique ID of this manager
  72875. */
  72876. readonly uniqueId: number;
  72877. /**
  72878. * Gets the number of vertices handled by this manager
  72879. */
  72880. readonly vertexCount: number;
  72881. /**
  72882. * Gets a boolean indicating if this manager supports morphing of normals
  72883. */
  72884. readonly supportsNormals: boolean;
  72885. /**
  72886. * Gets a boolean indicating if this manager supports morphing of tangents
  72887. */
  72888. readonly supportsTangents: boolean;
  72889. /**
  72890. * Gets the number of targets stored in this manager
  72891. */
  72892. readonly numTargets: number;
  72893. /**
  72894. * Gets the number of influencers (ie. the number of targets with influences > 0)
  72895. */
  72896. readonly numInfluencers: number;
  72897. /**
  72898. * Gets the list of influences (one per target)
  72899. */
  72900. readonly influences: Float32Array;
  72901. /**
  72902. * Gets the active target at specified index. An active target is a target with an influence > 0
  72903. * @param index defines the index to check
  72904. * @returns the requested target
  72905. */
  72906. getActiveTarget(index: number): MorphTarget;
  72907. /**
  72908. * Gets the target at specified index
  72909. * @param index defines the index to check
  72910. * @returns the requested target
  72911. */
  72912. getTarget(index: number): MorphTarget;
  72913. /**
  72914. * Add a new target to this manager
  72915. * @param target defines the target to add
  72916. */
  72917. addTarget(target: MorphTarget): void;
  72918. /**
  72919. * Removes a target from the manager
  72920. * @param target defines the target to remove
  72921. */
  72922. removeTarget(target: MorphTarget): void;
  72923. /**
  72924. * Serializes the current manager into a Serialization object
  72925. * @returns the serialized object
  72926. */
  72927. serialize(): any;
  72928. private _syncActiveTargets;
  72929. /**
  72930. * Syncrhonize the targets with all the meshes using this morph target manager
  72931. */
  72932. synchronize(): void;
  72933. /**
  72934. * Creates a new MorphTargetManager from serialized data
  72935. * @param serializationObject defines the serialized data
  72936. * @param scene defines the hosting scene
  72937. * @returns the new MorphTargetManager
  72938. */
  72939. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  72940. }
  72941. }
  72942. declare module BABYLON {
  72943. /**
  72944. * Groups all the scene component constants in one place to ease maintenance.
  72945. * @hidden
  72946. */
  72947. export class SceneComponentConstants {
  72948. static readonly NAME_EFFECTLAYER: string;
  72949. static readonly NAME_LAYER: string;
  72950. static readonly NAME_LENSFLARESYSTEM: string;
  72951. static readonly NAME_BOUNDINGBOXRENDERER: string;
  72952. static readonly NAME_PARTICLESYSTEM: string;
  72953. static readonly NAME_GAMEPAD: string;
  72954. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  72955. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  72956. static readonly NAME_DEPTHRENDERER: string;
  72957. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  72958. static readonly NAME_SPRITE: string;
  72959. static readonly NAME_OUTLINERENDERER: string;
  72960. static readonly NAME_PROCEDURALTEXTURE: string;
  72961. static readonly NAME_SHADOWGENERATOR: string;
  72962. static readonly NAME_OCTREE: string;
  72963. static readonly NAME_PHYSICSENGINE: string;
  72964. static readonly NAME_AUDIO: string;
  72965. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  72966. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  72967. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  72968. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  72969. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  72970. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  72971. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  72972. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  72973. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  72974. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  72975. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  72976. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  72977. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  72978. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  72979. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  72980. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  72981. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  72982. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  72983. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  72984. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  72985. static readonly STEP_AFTERRENDER_AUDIO: number;
  72986. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  72987. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  72988. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  72989. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  72990. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  72991. static readonly STEP_POINTERMOVE_SPRITE: number;
  72992. static readonly STEP_POINTERDOWN_SPRITE: number;
  72993. static readonly STEP_POINTERUP_SPRITE: number;
  72994. }
  72995. /**
  72996. * This represents a scene component.
  72997. *
  72998. * This is used to decouple the dependency the scene is having on the different workloads like
  72999. * layers, post processes...
  73000. */
  73001. export interface ISceneComponent {
  73002. /**
  73003. * The name of the component. Each component must have a unique name.
  73004. */
  73005. name: string;
  73006. /**
  73007. * The scene the component belongs to.
  73008. */
  73009. scene: Scene;
  73010. /**
  73011. * Register the component to one instance of a scene.
  73012. */
  73013. register(): void;
  73014. /**
  73015. * Rebuilds the elements related to this component in case of
  73016. * context lost for instance.
  73017. */
  73018. rebuild(): void;
  73019. /**
  73020. * Disposes the component and the associated ressources.
  73021. */
  73022. dispose(): void;
  73023. }
  73024. /**
  73025. * This represents a SERIALIZABLE scene component.
  73026. *
  73027. * This extends Scene Component to add Serialization methods on top.
  73028. */
  73029. export interface ISceneSerializableComponent extends ISceneComponent {
  73030. /**
  73031. * Adds all the elements from the container to the scene
  73032. * @param container the container holding the elements
  73033. */
  73034. addFromContainer(container: AbstractScene): void;
  73035. /**
  73036. * Removes all the elements in the container from the scene
  73037. * @param container contains the elements to remove
  73038. * @param dispose if the removed element should be disposed (default: false)
  73039. */
  73040. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73041. /**
  73042. * Serializes the component data to the specified json object
  73043. * @param serializationObject The object to serialize to
  73044. */
  73045. serialize(serializationObject: any): void;
  73046. }
  73047. /**
  73048. * Strong typing of a Mesh related stage step action
  73049. */
  73050. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73051. /**
  73052. * Strong typing of a Evaluate Sub Mesh related stage step action
  73053. */
  73054. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73055. /**
  73056. * Strong typing of a Active Mesh related stage step action
  73057. */
  73058. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73059. /**
  73060. * Strong typing of a Camera related stage step action
  73061. */
  73062. export type CameraStageAction = (camera: Camera) => void;
  73063. /**
  73064. * Strong typing of a Camera Frame buffer related stage step action
  73065. */
  73066. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73067. /**
  73068. * Strong typing of a Render Target related stage step action
  73069. */
  73070. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73071. /**
  73072. * Strong typing of a RenderingGroup related stage step action
  73073. */
  73074. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73075. /**
  73076. * Strong typing of a Mesh Render related stage step action
  73077. */
  73078. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73079. /**
  73080. * Strong typing of a simple stage step action
  73081. */
  73082. export type SimpleStageAction = () => void;
  73083. /**
  73084. * Strong typing of a render target action.
  73085. */
  73086. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73087. /**
  73088. * Strong typing of a pointer move action.
  73089. */
  73090. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73091. /**
  73092. * Strong typing of a pointer up/down action.
  73093. */
  73094. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73095. /**
  73096. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73097. * @hidden
  73098. */
  73099. export class Stage<T extends Function> extends Array<{
  73100. index: number;
  73101. component: ISceneComponent;
  73102. action: T;
  73103. }> {
  73104. /**
  73105. * Hide ctor from the rest of the world.
  73106. * @param items The items to add.
  73107. */
  73108. private constructor();
  73109. /**
  73110. * Creates a new Stage.
  73111. * @returns A new instance of a Stage
  73112. */
  73113. static Create<T extends Function>(): Stage<T>;
  73114. /**
  73115. * Registers a step in an ordered way in the targeted stage.
  73116. * @param index Defines the position to register the step in
  73117. * @param component Defines the component attached to the step
  73118. * @param action Defines the action to launch during the step
  73119. */
  73120. registerStep(index: number, component: ISceneComponent, action: T): void;
  73121. /**
  73122. * Clears all the steps from the stage.
  73123. */
  73124. clear(): void;
  73125. }
  73126. }
  73127. declare module BABYLON {
  73128. /**
  73129. * Class used to represent a specific level of detail of a mesh
  73130. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73131. */
  73132. export class MeshLODLevel {
  73133. /** Defines the distance where this level should star being displayed */
  73134. distance: number;
  73135. /** Defines the mesh to use to render this level */
  73136. mesh: Nullable<Mesh>;
  73137. /**
  73138. * Creates a new LOD level
  73139. * @param distance defines the distance where this level should star being displayed
  73140. * @param mesh defines the mesh to use to render this level
  73141. */
  73142. constructor(
  73143. /** Defines the distance where this level should star being displayed */
  73144. distance: number,
  73145. /** Defines the mesh to use to render this level */
  73146. mesh: Nullable<Mesh>);
  73147. }
  73148. }
  73149. declare module BABYLON {
  73150. /**
  73151. * Interface describing all the common properties and methods a shadow light needs to implement.
  73152. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73153. * as well as binding the different shadow properties to the effects.
  73154. */
  73155. export interface IShadowLight extends Light {
  73156. /**
  73157. * The light id in the scene (used in scene.findLighById for instance)
  73158. */
  73159. id: string;
  73160. /**
  73161. * The position the shdow will be casted from.
  73162. */
  73163. position: Vector3;
  73164. /**
  73165. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73166. */
  73167. direction: Vector3;
  73168. /**
  73169. * The transformed position. Position of the light in world space taking parenting in account.
  73170. */
  73171. transformedPosition: Vector3;
  73172. /**
  73173. * The transformed direction. Direction of the light in world space taking parenting in account.
  73174. */
  73175. transformedDirection: Vector3;
  73176. /**
  73177. * The friendly name of the light in the scene.
  73178. */
  73179. name: string;
  73180. /**
  73181. * Defines the shadow projection clipping minimum z value.
  73182. */
  73183. shadowMinZ: number;
  73184. /**
  73185. * Defines the shadow projection clipping maximum z value.
  73186. */
  73187. shadowMaxZ: number;
  73188. /**
  73189. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73190. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73191. */
  73192. computeTransformedInformation(): boolean;
  73193. /**
  73194. * Gets the scene the light belongs to.
  73195. * @returns The scene
  73196. */
  73197. getScene(): Scene;
  73198. /**
  73199. * Callback defining a custom Projection Matrix Builder.
  73200. * This can be used to override the default projection matrix computation.
  73201. */
  73202. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73203. /**
  73204. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73205. * @param matrix The materix to updated with the projection information
  73206. * @param viewMatrix The transform matrix of the light
  73207. * @param renderList The list of mesh to render in the map
  73208. * @returns The current light
  73209. */
  73210. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73211. /**
  73212. * Gets the current depth scale used in ESM.
  73213. * @returns The scale
  73214. */
  73215. getDepthScale(): number;
  73216. /**
  73217. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73218. * @returns true if a cube texture needs to be use
  73219. */
  73220. needCube(): boolean;
  73221. /**
  73222. * Detects if the projection matrix requires to be recomputed this frame.
  73223. * @returns true if it requires to be recomputed otherwise, false.
  73224. */
  73225. needProjectionMatrixCompute(): boolean;
  73226. /**
  73227. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73228. */
  73229. forceProjectionMatrixCompute(): void;
  73230. /**
  73231. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73232. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73233. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73234. */
  73235. getShadowDirection(faceIndex?: number): Vector3;
  73236. /**
  73237. * Gets the minZ used for shadow according to both the scene and the light.
  73238. * @param activeCamera The camera we are returning the min for
  73239. * @returns the depth min z
  73240. */
  73241. getDepthMinZ(activeCamera: Camera): number;
  73242. /**
  73243. * Gets the maxZ used for shadow according to both the scene and the light.
  73244. * @param activeCamera The camera we are returning the max for
  73245. * @returns the depth max z
  73246. */
  73247. getDepthMaxZ(activeCamera: Camera): number;
  73248. }
  73249. /**
  73250. * Base implementation IShadowLight
  73251. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73252. */
  73253. export abstract class ShadowLight extends Light implements IShadowLight {
  73254. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73255. protected _position: Vector3;
  73256. protected _setPosition(value: Vector3): void;
  73257. /**
  73258. * Sets the position the shadow will be casted from. Also use as the light position for both
  73259. * point and spot lights.
  73260. */
  73261. /**
  73262. * Sets the position the shadow will be casted from. Also use as the light position for both
  73263. * point and spot lights.
  73264. */
  73265. position: Vector3;
  73266. protected _direction: Vector3;
  73267. protected _setDirection(value: Vector3): void;
  73268. /**
  73269. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73270. * Also use as the light direction on spot and directional lights.
  73271. */
  73272. /**
  73273. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73274. * Also use as the light direction on spot and directional lights.
  73275. */
  73276. direction: Vector3;
  73277. private _shadowMinZ;
  73278. /**
  73279. * Gets the shadow projection clipping minimum z value.
  73280. */
  73281. /**
  73282. * Sets the shadow projection clipping minimum z value.
  73283. */
  73284. shadowMinZ: number;
  73285. private _shadowMaxZ;
  73286. /**
  73287. * Sets the shadow projection clipping maximum z value.
  73288. */
  73289. /**
  73290. * Gets the shadow projection clipping maximum z value.
  73291. */
  73292. shadowMaxZ: number;
  73293. /**
  73294. * Callback defining a custom Projection Matrix Builder.
  73295. * This can be used to override the default projection matrix computation.
  73296. */
  73297. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73298. /**
  73299. * The transformed position. Position of the light in world space taking parenting in account.
  73300. */
  73301. transformedPosition: Vector3;
  73302. /**
  73303. * The transformed direction. Direction of the light in world space taking parenting in account.
  73304. */
  73305. transformedDirection: Vector3;
  73306. private _needProjectionMatrixCompute;
  73307. /**
  73308. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73309. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73310. */
  73311. computeTransformedInformation(): boolean;
  73312. /**
  73313. * Return the depth scale used for the shadow map.
  73314. * @returns the depth scale.
  73315. */
  73316. getDepthScale(): number;
  73317. /**
  73318. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73319. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73320. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73321. */
  73322. getShadowDirection(faceIndex?: number): Vector3;
  73323. /**
  73324. * Returns the ShadowLight absolute position in the World.
  73325. * @returns the position vector in world space
  73326. */
  73327. getAbsolutePosition(): Vector3;
  73328. /**
  73329. * Sets the ShadowLight direction toward the passed target.
  73330. * @param target The point to target in local space
  73331. * @returns the updated ShadowLight direction
  73332. */
  73333. setDirectionToTarget(target: Vector3): Vector3;
  73334. /**
  73335. * Returns the light rotation in euler definition.
  73336. * @returns the x y z rotation in local space.
  73337. */
  73338. getRotation(): Vector3;
  73339. /**
  73340. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73341. * @returns true if a cube texture needs to be use
  73342. */
  73343. needCube(): boolean;
  73344. /**
  73345. * Detects if the projection matrix requires to be recomputed this frame.
  73346. * @returns true if it requires to be recomputed otherwise, false.
  73347. */
  73348. needProjectionMatrixCompute(): boolean;
  73349. /**
  73350. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73351. */
  73352. forceProjectionMatrixCompute(): void;
  73353. /** @hidden */
  73354. _initCache(): void;
  73355. /** @hidden */
  73356. _isSynchronized(): boolean;
  73357. /**
  73358. * Computes the world matrix of the node
  73359. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73360. * @returns the world matrix
  73361. */
  73362. computeWorldMatrix(force?: boolean): Matrix;
  73363. /**
  73364. * Gets the minZ used for shadow according to both the scene and the light.
  73365. * @param activeCamera The camera we are returning the min for
  73366. * @returns the depth min z
  73367. */
  73368. getDepthMinZ(activeCamera: Camera): number;
  73369. /**
  73370. * Gets the maxZ used for shadow according to both the scene and the light.
  73371. * @param activeCamera The camera we are returning the max for
  73372. * @returns the depth max z
  73373. */
  73374. getDepthMaxZ(activeCamera: Camera): number;
  73375. /**
  73376. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73377. * @param matrix The materix to updated with the projection information
  73378. * @param viewMatrix The transform matrix of the light
  73379. * @param renderList The list of mesh to render in the map
  73380. * @returns The current light
  73381. */
  73382. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73383. }
  73384. }
  73385. declare module BABYLON {
  73386. /**
  73387. * "Static Class" containing the most commonly used helper while dealing with material for
  73388. * rendering purpose.
  73389. *
  73390. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73391. *
  73392. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73393. */
  73394. export class MaterialHelper {
  73395. /**
  73396. * Bind the current view position to an effect.
  73397. * @param effect The effect to be bound
  73398. * @param scene The scene the eyes position is used from
  73399. */
  73400. static BindEyePosition(effect: Effect, scene: Scene): void;
  73401. /**
  73402. * Helps preparing the defines values about the UVs in used in the effect.
  73403. * UVs are shared as much as we can accross channels in the shaders.
  73404. * @param texture The texture we are preparing the UVs for
  73405. * @param defines The defines to update
  73406. * @param key The channel key "diffuse", "specular"... used in the shader
  73407. */
  73408. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73409. /**
  73410. * Binds a texture matrix value to its corrsponding uniform
  73411. * @param texture The texture to bind the matrix for
  73412. * @param uniformBuffer The uniform buffer receivin the data
  73413. * @param key The channel key "diffuse", "specular"... used in the shader
  73414. */
  73415. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73416. /**
  73417. * Gets the current status of the fog (should it be enabled?)
  73418. * @param mesh defines the mesh to evaluate for fog support
  73419. * @param scene defines the hosting scene
  73420. * @returns true if fog must be enabled
  73421. */
  73422. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73423. /**
  73424. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73425. * @param mesh defines the current mesh
  73426. * @param scene defines the current scene
  73427. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73428. * @param pointsCloud defines if point cloud rendering has to be turned on
  73429. * @param fogEnabled defines if fog has to be turned on
  73430. * @param alphaTest defines if alpha testing has to be turned on
  73431. * @param defines defines the current list of defines
  73432. */
  73433. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73434. /**
  73435. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73436. * @param scene defines the current scene
  73437. * @param engine defines the current engine
  73438. * @param defines specifies the list of active defines
  73439. * @param useInstances defines if instances have to be turned on
  73440. * @param useClipPlane defines if clip plane have to be turned on
  73441. */
  73442. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73443. /**
  73444. * Prepares the defines for bones
  73445. * @param mesh The mesh containing the geometry data we will draw
  73446. * @param defines The defines to update
  73447. */
  73448. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73449. /**
  73450. * Prepares the defines for morph targets
  73451. * @param mesh The mesh containing the geometry data we will draw
  73452. * @param defines The defines to update
  73453. */
  73454. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73455. /**
  73456. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73457. * @param mesh The mesh containing the geometry data we will draw
  73458. * @param defines The defines to update
  73459. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73460. * @param useBones Precise whether bones should be used or not (override mesh info)
  73461. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73462. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73463. * @returns false if defines are considered not dirty and have not been checked
  73464. */
  73465. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73466. /**
  73467. * Prepares the defines related to multiview
  73468. * @param scene The scene we are intending to draw
  73469. * @param defines The defines to update
  73470. */
  73471. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73472. /**
  73473. * Prepares the defines related to the light information passed in parameter
  73474. * @param scene The scene we are intending to draw
  73475. * @param mesh The mesh the effect is compiling for
  73476. * @param defines The defines to update
  73477. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73478. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73479. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73480. * @returns true if normals will be required for the rest of the effect
  73481. */
  73482. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73483. /**
  73484. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  73485. * that won t be acctive due to defines being turned off.
  73486. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73487. * @param samplersList The samplers list
  73488. * @param defines The defines helping in the list generation
  73489. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73490. */
  73491. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73492. /**
  73493. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73494. * @param defines The defines to update while falling back
  73495. * @param fallbacks The authorized effect fallbacks
  73496. * @param maxSimultaneousLights The maximum number of lights allowed
  73497. * @param rank the current rank of the Effect
  73498. * @returns The newly affected rank
  73499. */
  73500. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73501. /**
  73502. * Prepares the list of attributes required for morph targets according to the effect defines.
  73503. * @param attribs The current list of supported attribs
  73504. * @param mesh The mesh to prepare the morph targets attributes for
  73505. * @param defines The current Defines of the effect
  73506. */
  73507. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73508. /**
  73509. * Prepares the list of attributes required for bones according to the effect defines.
  73510. * @param attribs The current list of supported attribs
  73511. * @param mesh The mesh to prepare the bones attributes for
  73512. * @param defines The current Defines of the effect
  73513. * @param fallbacks The current efffect fallback strategy
  73514. */
  73515. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73516. /**
  73517. * Check and prepare the list of attributes required for instances according to the effect defines.
  73518. * @param attribs The current list of supported attribs
  73519. * @param defines The current MaterialDefines of the effect
  73520. */
  73521. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73522. /**
  73523. * Add the list of attributes required for instances to the attribs array.
  73524. * @param attribs The current list of supported attribs
  73525. */
  73526. static PushAttributesForInstances(attribs: string[]): void;
  73527. /**
  73528. * Binds the light shadow information to the effect for the given mesh.
  73529. * @param light The light containing the generator
  73530. * @param scene The scene the lights belongs to
  73531. * @param mesh The mesh we are binding the information to render
  73532. * @param lightIndex The light index in the effect used to render the mesh
  73533. * @param effect The effect we are binding the data to
  73534. */
  73535. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73536. /**
  73537. * Binds the light information to the effect.
  73538. * @param light The light containing the generator
  73539. * @param effect The effect we are binding the data to
  73540. * @param lightIndex The light index in the effect used to render
  73541. */
  73542. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73543. /**
  73544. * Binds the lights information from the scene to the effect for the given mesh.
  73545. * @param scene The scene the lights belongs to
  73546. * @param mesh The mesh we are binding the information to render
  73547. * @param effect The effect we are binding the data to
  73548. * @param defines The generated defines for the effect
  73549. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73550. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73551. */
  73552. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73553. private static _tempFogColor;
  73554. /**
  73555. * Binds the fog information from the scene to the effect for the given mesh.
  73556. * @param scene The scene the lights belongs to
  73557. * @param mesh The mesh we are binding the information to render
  73558. * @param effect The effect we are binding the data to
  73559. * @param linearSpace Defines if the fog effect is applied in linear space
  73560. */
  73561. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73562. /**
  73563. * Binds the bones information from the mesh to the effect.
  73564. * @param mesh The mesh we are binding the information to render
  73565. * @param effect The effect we are binding the data to
  73566. */
  73567. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73568. /**
  73569. * Binds the morph targets information from the mesh to the effect.
  73570. * @param abstractMesh The mesh we are binding the information to render
  73571. * @param effect The effect we are binding the data to
  73572. */
  73573. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73574. /**
  73575. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73576. * @param defines The generated defines used in the effect
  73577. * @param effect The effect we are binding the data to
  73578. * @param scene The scene we are willing to render with logarithmic scale for
  73579. */
  73580. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73581. /**
  73582. * Binds the clip plane information from the scene to the effect.
  73583. * @param scene The scene the clip plane information are extracted from
  73584. * @param effect The effect we are binding the data to
  73585. */
  73586. static BindClipPlane(effect: Effect, scene: Scene): void;
  73587. }
  73588. }
  73589. declare module BABYLON {
  73590. /** @hidden */
  73591. export var shadowMapPixelShader: {
  73592. name: string;
  73593. shader: string;
  73594. };
  73595. }
  73596. declare module BABYLON {
  73597. /** @hidden */
  73598. export var bonesDeclaration: {
  73599. name: string;
  73600. shader: string;
  73601. };
  73602. }
  73603. declare module BABYLON {
  73604. /** @hidden */
  73605. export var morphTargetsVertexGlobalDeclaration: {
  73606. name: string;
  73607. shader: string;
  73608. };
  73609. }
  73610. declare module BABYLON {
  73611. /** @hidden */
  73612. export var morphTargetsVertexDeclaration: {
  73613. name: string;
  73614. shader: string;
  73615. };
  73616. }
  73617. declare module BABYLON {
  73618. /** @hidden */
  73619. export var instancesDeclaration: {
  73620. name: string;
  73621. shader: string;
  73622. };
  73623. }
  73624. declare module BABYLON {
  73625. /** @hidden */
  73626. export var helperFunctions: {
  73627. name: string;
  73628. shader: string;
  73629. };
  73630. }
  73631. declare module BABYLON {
  73632. /** @hidden */
  73633. export var morphTargetsVertex: {
  73634. name: string;
  73635. shader: string;
  73636. };
  73637. }
  73638. declare module BABYLON {
  73639. /** @hidden */
  73640. export var instancesVertex: {
  73641. name: string;
  73642. shader: string;
  73643. };
  73644. }
  73645. declare module BABYLON {
  73646. /** @hidden */
  73647. export var bonesVertex: {
  73648. name: string;
  73649. shader: string;
  73650. };
  73651. }
  73652. declare module BABYLON {
  73653. /** @hidden */
  73654. export var shadowMapVertexShader: {
  73655. name: string;
  73656. shader: string;
  73657. };
  73658. }
  73659. declare module BABYLON {
  73660. /** @hidden */
  73661. export var depthBoxBlurPixelShader: {
  73662. name: string;
  73663. shader: string;
  73664. };
  73665. }
  73666. declare module BABYLON {
  73667. /**
  73668. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73669. */
  73670. export interface ICustomShaderOptions {
  73671. /**
  73672. * Gets or sets the custom shader name to use
  73673. */
  73674. shaderName: string;
  73675. /**
  73676. * The list of attribute names used in the shader
  73677. */
  73678. attributes?: string[];
  73679. /**
  73680. * The list of unifrom names used in the shader
  73681. */
  73682. uniforms?: string[];
  73683. /**
  73684. * The list of sampler names used in the shader
  73685. */
  73686. samplers?: string[];
  73687. /**
  73688. * The list of defines used in the shader
  73689. */
  73690. defines?: string[];
  73691. }
  73692. /**
  73693. * Interface to implement to create a shadow generator compatible with BJS.
  73694. */
  73695. export interface IShadowGenerator {
  73696. /**
  73697. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73698. * @returns The render target texture if present otherwise, null
  73699. */
  73700. getShadowMap(): Nullable<RenderTargetTexture>;
  73701. /**
  73702. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73703. * @returns The render target texture if the shadow map is present otherwise, null
  73704. */
  73705. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73706. /**
  73707. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73708. * @param subMesh The submesh we want to render in the shadow map
  73709. * @param useInstances Defines wether will draw in the map using instances
  73710. * @returns true if ready otherwise, false
  73711. */
  73712. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73713. /**
  73714. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73715. * @param defines Defines of the material we want to update
  73716. * @param lightIndex Index of the light in the enabled light list of the material
  73717. */
  73718. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73719. /**
  73720. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73721. * defined in the generator but impacting the effect).
  73722. * It implies the unifroms available on the materials are the standard BJS ones.
  73723. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73724. * @param effect The effect we are binfing the information for
  73725. */
  73726. bindShadowLight(lightIndex: string, effect: Effect): void;
  73727. /**
  73728. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73729. * (eq to shadow prjection matrix * light transform matrix)
  73730. * @returns The transform matrix used to create the shadow map
  73731. */
  73732. getTransformMatrix(): Matrix;
  73733. /**
  73734. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73735. * Cube and 2D textures for instance.
  73736. */
  73737. recreateShadowMap(): void;
  73738. /**
  73739. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73740. * @param onCompiled Callback triggered at the and of the effects compilation
  73741. * @param options Sets of optional options forcing the compilation with different modes
  73742. */
  73743. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73744. useInstances: boolean;
  73745. }>): void;
  73746. /**
  73747. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73748. * @param options Sets of optional options forcing the compilation with different modes
  73749. * @returns A promise that resolves when the compilation completes
  73750. */
  73751. forceCompilationAsync(options?: Partial<{
  73752. useInstances: boolean;
  73753. }>): Promise<void>;
  73754. /**
  73755. * Serializes the shadow generator setup to a json object.
  73756. * @returns The serialized JSON object
  73757. */
  73758. serialize(): any;
  73759. /**
  73760. * Disposes the Shadow map and related Textures and effects.
  73761. */
  73762. dispose(): void;
  73763. }
  73764. /**
  73765. * Default implementation IShadowGenerator.
  73766. * This is the main object responsible of generating shadows in the framework.
  73767. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73768. */
  73769. export class ShadowGenerator implements IShadowGenerator {
  73770. /**
  73771. * Shadow generator mode None: no filtering applied.
  73772. */
  73773. static readonly FILTER_NONE: number;
  73774. /**
  73775. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73776. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73777. */
  73778. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73779. /**
  73780. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73781. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73782. */
  73783. static readonly FILTER_POISSONSAMPLING: number;
  73784. /**
  73785. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73786. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73787. */
  73788. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73789. /**
  73790. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73791. * edge artifacts on steep falloff.
  73792. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73793. */
  73794. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73795. /**
  73796. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73797. * edge artifacts on steep falloff.
  73798. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73799. */
  73800. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73801. /**
  73802. * Shadow generator mode PCF: Percentage Closer Filtering
  73803. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73804. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73805. */
  73806. static readonly FILTER_PCF: number;
  73807. /**
  73808. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73809. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73810. * Contact Hardening
  73811. */
  73812. static readonly FILTER_PCSS: number;
  73813. /**
  73814. * Reserved for PCF and PCSS
  73815. * Highest Quality.
  73816. *
  73817. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73818. *
  73819. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73820. */
  73821. static readonly QUALITY_HIGH: number;
  73822. /**
  73823. * Reserved for PCF and PCSS
  73824. * Good tradeoff for quality/perf cross devices
  73825. *
  73826. * Execute PCF on a 3*3 kernel.
  73827. *
  73828. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73829. */
  73830. static readonly QUALITY_MEDIUM: number;
  73831. /**
  73832. * Reserved for PCF and PCSS
  73833. * The lowest quality but the fastest.
  73834. *
  73835. * Execute PCF on a 1*1 kernel.
  73836. *
  73837. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73838. */
  73839. static readonly QUALITY_LOW: number;
  73840. /** Gets or sets the custom shader name to use */
  73841. customShaderOptions: ICustomShaderOptions;
  73842. /**
  73843. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73844. */
  73845. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73846. /**
  73847. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73848. */
  73849. onAfterShadowMapRenderObservable: Observable<Effect>;
  73850. /**
  73851. * Observable triggered before a mesh is rendered in the shadow map.
  73852. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73853. */
  73854. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73855. /**
  73856. * Observable triggered after a mesh is rendered in the shadow map.
  73857. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73858. */
  73859. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73860. private _bias;
  73861. /**
  73862. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73863. */
  73864. /**
  73865. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73866. */
  73867. bias: number;
  73868. private _normalBias;
  73869. /**
  73870. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73871. */
  73872. /**
  73873. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73874. */
  73875. normalBias: number;
  73876. private _blurBoxOffset;
  73877. /**
  73878. * Gets the blur box offset: offset applied during the blur pass.
  73879. * Only useful if useKernelBlur = false
  73880. */
  73881. /**
  73882. * Sets the blur box offset: offset applied during the blur pass.
  73883. * Only useful if useKernelBlur = false
  73884. */
  73885. blurBoxOffset: number;
  73886. private _blurScale;
  73887. /**
  73888. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73889. * 2 means half of the size.
  73890. */
  73891. /**
  73892. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73893. * 2 means half of the size.
  73894. */
  73895. blurScale: number;
  73896. private _blurKernel;
  73897. /**
  73898. * Gets the blur kernel: kernel size of the blur pass.
  73899. * Only useful if useKernelBlur = true
  73900. */
  73901. /**
  73902. * Sets the blur kernel: kernel size of the blur pass.
  73903. * Only useful if useKernelBlur = true
  73904. */
  73905. blurKernel: number;
  73906. private _useKernelBlur;
  73907. /**
  73908. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73909. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73910. */
  73911. /**
  73912. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73913. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73914. */
  73915. useKernelBlur: boolean;
  73916. private _depthScale;
  73917. /**
  73918. * Gets the depth scale used in ESM mode.
  73919. */
  73920. /**
  73921. * Sets the depth scale used in ESM mode.
  73922. * This can override the scale stored on the light.
  73923. */
  73924. depthScale: number;
  73925. private _filter;
  73926. /**
  73927. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73928. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73929. */
  73930. /**
  73931. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73932. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73933. */
  73934. filter: number;
  73935. /**
  73936. * Gets if the current filter is set to Poisson Sampling.
  73937. */
  73938. /**
  73939. * Sets the current filter to Poisson Sampling.
  73940. */
  73941. usePoissonSampling: boolean;
  73942. /**
  73943. * Gets if the current filter is set to ESM.
  73944. */
  73945. /**
  73946. * Sets the current filter is to ESM.
  73947. */
  73948. useExponentialShadowMap: boolean;
  73949. /**
  73950. * Gets if the current filter is set to filtered ESM.
  73951. */
  73952. /**
  73953. * Gets if the current filter is set to filtered ESM.
  73954. */
  73955. useBlurExponentialShadowMap: boolean;
  73956. /**
  73957. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73958. * exponential to prevent steep falloff artifacts).
  73959. */
  73960. /**
  73961. * Sets the current filter to "close ESM" (using the inverse of the
  73962. * exponential to prevent steep falloff artifacts).
  73963. */
  73964. useCloseExponentialShadowMap: boolean;
  73965. /**
  73966. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73967. * exponential to prevent steep falloff artifacts).
  73968. */
  73969. /**
  73970. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73971. * exponential to prevent steep falloff artifacts).
  73972. */
  73973. useBlurCloseExponentialShadowMap: boolean;
  73974. /**
  73975. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73976. */
  73977. /**
  73978. * Sets the current filter to "PCF" (percentage closer filtering).
  73979. */
  73980. usePercentageCloserFiltering: boolean;
  73981. private _filteringQuality;
  73982. /**
  73983. * Gets the PCF or PCSS Quality.
  73984. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73985. */
  73986. /**
  73987. * Sets the PCF or PCSS Quality.
  73988. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73989. */
  73990. filteringQuality: number;
  73991. /**
  73992. * Gets if the current filter is set to "PCSS" (contact hardening).
  73993. */
  73994. /**
  73995. * Sets the current filter to "PCSS" (contact hardening).
  73996. */
  73997. useContactHardeningShadow: boolean;
  73998. private _contactHardeningLightSizeUVRatio;
  73999. /**
  74000. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74001. * Using a ratio helps keeping shape stability independently of the map size.
  74002. *
  74003. * It does not account for the light projection as it was having too much
  74004. * instability during the light setup or during light position changes.
  74005. *
  74006. * Only valid if useContactHardeningShadow is true.
  74007. */
  74008. /**
  74009. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74010. * Using a ratio helps keeping shape stability independently of the map size.
  74011. *
  74012. * It does not account for the light projection as it was having too much
  74013. * instability during the light setup or during light position changes.
  74014. *
  74015. * Only valid if useContactHardeningShadow is true.
  74016. */
  74017. contactHardeningLightSizeUVRatio: number;
  74018. private _darkness;
  74019. /** Gets or sets the actual darkness of a shadow */
  74020. darkness: number;
  74021. /**
  74022. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74023. * 0 means strongest and 1 would means no shadow.
  74024. * @returns the darkness.
  74025. */
  74026. getDarkness(): number;
  74027. /**
  74028. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74029. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74030. * @returns the shadow generator allowing fluent coding.
  74031. */
  74032. setDarkness(darkness: number): ShadowGenerator;
  74033. private _transparencyShadow;
  74034. /** Gets or sets the ability to have transparent shadow */
  74035. transparencyShadow: boolean;
  74036. /**
  74037. * Sets the ability to have transparent shadow (boolean).
  74038. * @param transparent True if transparent else False
  74039. * @returns the shadow generator allowing fluent coding
  74040. */
  74041. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74042. private _shadowMap;
  74043. private _shadowMap2;
  74044. /**
  74045. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74046. * @returns The render target texture if present otherwise, null
  74047. */
  74048. getShadowMap(): Nullable<RenderTargetTexture>;
  74049. /**
  74050. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74051. * @returns The render target texture if the shadow map is present otherwise, null
  74052. */
  74053. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74054. /**
  74055. * Gets the class name of that object
  74056. * @returns "ShadowGenerator"
  74057. */
  74058. getClassName(): string;
  74059. /**
  74060. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74061. * @param mesh Mesh to add
  74062. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74063. * @returns the Shadow Generator itself
  74064. */
  74065. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74066. /**
  74067. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74068. * @param mesh Mesh to remove
  74069. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74070. * @returns the Shadow Generator itself
  74071. */
  74072. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74073. /**
  74074. * Controls the extent to which the shadows fade out at the edge of the frustum
  74075. * Used only by directionals and spots
  74076. */
  74077. frustumEdgeFalloff: number;
  74078. private _light;
  74079. /**
  74080. * Returns the associated light object.
  74081. * @returns the light generating the shadow
  74082. */
  74083. getLight(): IShadowLight;
  74084. /**
  74085. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74086. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74087. * It might on the other hand introduce peter panning.
  74088. */
  74089. forceBackFacesOnly: boolean;
  74090. private _scene;
  74091. private _lightDirection;
  74092. private _effect;
  74093. private _viewMatrix;
  74094. private _projectionMatrix;
  74095. private _transformMatrix;
  74096. private _cachedPosition;
  74097. private _cachedDirection;
  74098. private _cachedDefines;
  74099. private _currentRenderID;
  74100. private _boxBlurPostprocess;
  74101. private _kernelBlurXPostprocess;
  74102. private _kernelBlurYPostprocess;
  74103. private _blurPostProcesses;
  74104. private _mapSize;
  74105. private _currentFaceIndex;
  74106. private _currentFaceIndexCache;
  74107. private _textureType;
  74108. private _defaultTextureMatrix;
  74109. /** @hidden */
  74110. static _SceneComponentInitialization: (scene: Scene) => void;
  74111. /**
  74112. * Creates a ShadowGenerator object.
  74113. * A ShadowGenerator is the required tool to use the shadows.
  74114. * Each light casting shadows needs to use its own ShadowGenerator.
  74115. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74116. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74117. * @param light The light object generating the shadows.
  74118. * @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.
  74119. */
  74120. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74121. private _initializeGenerator;
  74122. private _initializeShadowMap;
  74123. private _initializeBlurRTTAndPostProcesses;
  74124. private _renderForShadowMap;
  74125. private _renderSubMeshForShadowMap;
  74126. private _applyFilterValues;
  74127. /**
  74128. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74129. * @param onCompiled Callback triggered at the and of the effects compilation
  74130. * @param options Sets of optional options forcing the compilation with different modes
  74131. */
  74132. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74133. useInstances: boolean;
  74134. }>): void;
  74135. /**
  74136. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74137. * @param options Sets of optional options forcing the compilation with different modes
  74138. * @returns A promise that resolves when the compilation completes
  74139. */
  74140. forceCompilationAsync(options?: Partial<{
  74141. useInstances: boolean;
  74142. }>): Promise<void>;
  74143. /**
  74144. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74145. * @param subMesh The submesh we want to render in the shadow map
  74146. * @param useInstances Defines wether will draw in the map using instances
  74147. * @returns true if ready otherwise, false
  74148. */
  74149. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74150. /**
  74151. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74152. * @param defines Defines of the material we want to update
  74153. * @param lightIndex Index of the light in the enabled light list of the material
  74154. */
  74155. prepareDefines(defines: any, lightIndex: number): void;
  74156. /**
  74157. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74158. * defined in the generator but impacting the effect).
  74159. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74160. * @param effect The effect we are binfing the information for
  74161. */
  74162. bindShadowLight(lightIndex: string, effect: Effect): void;
  74163. /**
  74164. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74165. * (eq to shadow prjection matrix * light transform matrix)
  74166. * @returns The transform matrix used to create the shadow map
  74167. */
  74168. getTransformMatrix(): Matrix;
  74169. /**
  74170. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74171. * Cube and 2D textures for instance.
  74172. */
  74173. recreateShadowMap(): void;
  74174. private _disposeBlurPostProcesses;
  74175. private _disposeRTTandPostProcesses;
  74176. /**
  74177. * Disposes the ShadowGenerator.
  74178. * Returns nothing.
  74179. */
  74180. dispose(): void;
  74181. /**
  74182. * Serializes the shadow generator setup to a json object.
  74183. * @returns The serialized JSON object
  74184. */
  74185. serialize(): any;
  74186. /**
  74187. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74188. * @param parsedShadowGenerator The JSON object to parse
  74189. * @param scene The scene to create the shadow map for
  74190. * @returns The parsed shadow generator
  74191. */
  74192. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74193. }
  74194. }
  74195. declare module BABYLON {
  74196. /**
  74197. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74198. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74199. * 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.
  74200. */
  74201. export abstract class Light extends Node {
  74202. /**
  74203. * Falloff Default: light is falling off following the material specification:
  74204. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74205. */
  74206. static readonly FALLOFF_DEFAULT: number;
  74207. /**
  74208. * Falloff Physical: light is falling off following the inverse squared distance law.
  74209. */
  74210. static readonly FALLOFF_PHYSICAL: number;
  74211. /**
  74212. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74213. * to enhance interoperability with other engines.
  74214. */
  74215. static readonly FALLOFF_GLTF: number;
  74216. /**
  74217. * Falloff Standard: light is falling off like in the standard material
  74218. * to enhance interoperability with other materials.
  74219. */
  74220. static readonly FALLOFF_STANDARD: number;
  74221. /**
  74222. * If every light affecting the material is in this lightmapMode,
  74223. * material.lightmapTexture adds or multiplies
  74224. * (depends on material.useLightmapAsShadowmap)
  74225. * after every other light calculations.
  74226. */
  74227. static readonly LIGHTMAP_DEFAULT: number;
  74228. /**
  74229. * material.lightmapTexture as only diffuse lighting from this light
  74230. * adds only specular lighting from this light
  74231. * adds dynamic shadows
  74232. */
  74233. static readonly LIGHTMAP_SPECULAR: number;
  74234. /**
  74235. * material.lightmapTexture as only lighting
  74236. * no light calculation from this light
  74237. * only adds dynamic shadows from this light
  74238. */
  74239. static readonly LIGHTMAP_SHADOWSONLY: number;
  74240. /**
  74241. * Each light type uses the default quantity according to its type:
  74242. * point/spot lights use luminous intensity
  74243. * directional lights use illuminance
  74244. */
  74245. static readonly INTENSITYMODE_AUTOMATIC: number;
  74246. /**
  74247. * lumen (lm)
  74248. */
  74249. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74250. /**
  74251. * candela (lm/sr)
  74252. */
  74253. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74254. /**
  74255. * lux (lm/m^2)
  74256. */
  74257. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74258. /**
  74259. * nit (cd/m^2)
  74260. */
  74261. static readonly INTENSITYMODE_LUMINANCE: number;
  74262. /**
  74263. * Light type const id of the point light.
  74264. */
  74265. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74266. /**
  74267. * Light type const id of the directional light.
  74268. */
  74269. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74270. /**
  74271. * Light type const id of the spot light.
  74272. */
  74273. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74274. /**
  74275. * Light type const id of the hemispheric light.
  74276. */
  74277. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74278. /**
  74279. * Diffuse gives the basic color to an object.
  74280. */
  74281. diffuse: Color3;
  74282. /**
  74283. * Specular produces a highlight color on an object.
  74284. * Note: This is note affecting PBR materials.
  74285. */
  74286. specular: Color3;
  74287. /**
  74288. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74289. * falling off base on range or angle.
  74290. * This can be set to any values in Light.FALLOFF_x.
  74291. *
  74292. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74293. * other types of materials.
  74294. */
  74295. falloffType: number;
  74296. /**
  74297. * Strength of the light.
  74298. * Note: By default it is define in the framework own unit.
  74299. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74300. */
  74301. intensity: number;
  74302. private _range;
  74303. protected _inverseSquaredRange: number;
  74304. /**
  74305. * Defines how far from the source the light is impacting in scene units.
  74306. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74307. */
  74308. /**
  74309. * Defines how far from the source the light is impacting in scene units.
  74310. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74311. */
  74312. range: number;
  74313. /**
  74314. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74315. * of light.
  74316. */
  74317. private _photometricScale;
  74318. private _intensityMode;
  74319. /**
  74320. * Gets the photometric scale used to interpret the intensity.
  74321. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74322. */
  74323. /**
  74324. * Sets the photometric scale used to interpret the intensity.
  74325. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74326. */
  74327. intensityMode: number;
  74328. private _radius;
  74329. /**
  74330. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74331. */
  74332. /**
  74333. * sets the light radius used by PBR Materials to simulate soft area lights.
  74334. */
  74335. radius: number;
  74336. private _renderPriority;
  74337. /**
  74338. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74339. * exceeding the number allowed of the materials.
  74340. */
  74341. renderPriority: number;
  74342. private _shadowEnabled;
  74343. /**
  74344. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74345. * the current shadow generator.
  74346. */
  74347. /**
  74348. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74349. * the current shadow generator.
  74350. */
  74351. shadowEnabled: boolean;
  74352. private _includedOnlyMeshes;
  74353. /**
  74354. * Gets the only meshes impacted by this light.
  74355. */
  74356. /**
  74357. * Sets the only meshes impacted by this light.
  74358. */
  74359. includedOnlyMeshes: AbstractMesh[];
  74360. private _excludedMeshes;
  74361. /**
  74362. * Gets the meshes not impacted by this light.
  74363. */
  74364. /**
  74365. * Sets the meshes not impacted by this light.
  74366. */
  74367. excludedMeshes: AbstractMesh[];
  74368. private _excludeWithLayerMask;
  74369. /**
  74370. * Gets the layer id use to find what meshes are not impacted by the light.
  74371. * Inactive if 0
  74372. */
  74373. /**
  74374. * Sets the layer id use to find what meshes are not impacted by the light.
  74375. * Inactive if 0
  74376. */
  74377. excludeWithLayerMask: number;
  74378. private _includeOnlyWithLayerMask;
  74379. /**
  74380. * Gets the layer id use to find what meshes are impacted by the light.
  74381. * Inactive if 0
  74382. */
  74383. /**
  74384. * Sets the layer id use to find what meshes are impacted by the light.
  74385. * Inactive if 0
  74386. */
  74387. includeOnlyWithLayerMask: number;
  74388. private _lightmapMode;
  74389. /**
  74390. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74391. */
  74392. /**
  74393. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74394. */
  74395. lightmapMode: number;
  74396. /**
  74397. * Shadow generator associted to the light.
  74398. * @hidden Internal use only.
  74399. */
  74400. _shadowGenerator: Nullable<IShadowGenerator>;
  74401. /**
  74402. * @hidden Internal use only.
  74403. */
  74404. _excludedMeshesIds: string[];
  74405. /**
  74406. * @hidden Internal use only.
  74407. */
  74408. _includedOnlyMeshesIds: string[];
  74409. /**
  74410. * The current light unifom buffer.
  74411. * @hidden Internal use only.
  74412. */
  74413. _uniformBuffer: UniformBuffer;
  74414. /**
  74415. * Creates a Light object in the scene.
  74416. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74417. * @param name The firendly name of the light
  74418. * @param scene The scene the light belongs too
  74419. */
  74420. constructor(name: string, scene: Scene);
  74421. protected abstract _buildUniformLayout(): void;
  74422. /**
  74423. * Sets the passed Effect "effect" with the Light information.
  74424. * @param effect The effect to update
  74425. * @param lightIndex The index of the light in the effect to update
  74426. * @returns The light
  74427. */
  74428. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74429. /**
  74430. * Returns the string "Light".
  74431. * @returns the class name
  74432. */
  74433. getClassName(): string;
  74434. /** @hidden */
  74435. readonly _isLight: boolean;
  74436. /**
  74437. * Converts the light information to a readable string for debug purpose.
  74438. * @param fullDetails Supports for multiple levels of logging within scene loading
  74439. * @returns the human readable light info
  74440. */
  74441. toString(fullDetails?: boolean): string;
  74442. /** @hidden */
  74443. protected _syncParentEnabledState(): void;
  74444. /**
  74445. * Set the enabled state of this node.
  74446. * @param value - the new enabled state
  74447. */
  74448. setEnabled(value: boolean): void;
  74449. /**
  74450. * Returns the Light associated shadow generator if any.
  74451. * @return the associated shadow generator.
  74452. */
  74453. getShadowGenerator(): Nullable<IShadowGenerator>;
  74454. /**
  74455. * Returns a Vector3, the absolute light position in the World.
  74456. * @returns the world space position of the light
  74457. */
  74458. getAbsolutePosition(): Vector3;
  74459. /**
  74460. * Specifies if the light will affect the passed mesh.
  74461. * @param mesh The mesh to test against the light
  74462. * @return true the mesh is affected otherwise, false.
  74463. */
  74464. canAffectMesh(mesh: AbstractMesh): boolean;
  74465. /**
  74466. * Sort function to order lights for rendering.
  74467. * @param a First Light object to compare to second.
  74468. * @param b Second Light object to compare first.
  74469. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74470. */
  74471. static CompareLightsPriority(a: Light, b: Light): number;
  74472. /**
  74473. * Releases resources associated with this node.
  74474. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74475. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74476. */
  74477. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74478. /**
  74479. * Returns the light type ID (integer).
  74480. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74481. */
  74482. getTypeID(): number;
  74483. /**
  74484. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74485. * @returns the scaled intensity in intensity mode unit
  74486. */
  74487. getScaledIntensity(): number;
  74488. /**
  74489. * Returns a new Light object, named "name", from the current one.
  74490. * @param name The name of the cloned light
  74491. * @returns the new created light
  74492. */
  74493. clone(name: string): Nullable<Light>;
  74494. /**
  74495. * Serializes the current light into a Serialization object.
  74496. * @returns the serialized object.
  74497. */
  74498. serialize(): any;
  74499. /**
  74500. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74501. * This new light is named "name" and added to the passed scene.
  74502. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74503. * @param name The friendly name of the light
  74504. * @param scene The scene the new light will belong to
  74505. * @returns the constructor function
  74506. */
  74507. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74508. /**
  74509. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74510. * @param parsedLight The JSON representation of the light
  74511. * @param scene The scene to create the parsed light in
  74512. * @returns the created light after parsing
  74513. */
  74514. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74515. private _hookArrayForExcluded;
  74516. private _hookArrayForIncludedOnly;
  74517. private _resyncMeshes;
  74518. /**
  74519. * Forces the meshes to update their light related information in their rendering used effects
  74520. * @hidden Internal Use Only
  74521. */
  74522. _markMeshesAsLightDirty(): void;
  74523. /**
  74524. * Recomputes the cached photometric scale if needed.
  74525. */
  74526. private _computePhotometricScale;
  74527. /**
  74528. * Returns the Photometric Scale according to the light type and intensity mode.
  74529. */
  74530. private _getPhotometricScale;
  74531. /**
  74532. * Reorder the light in the scene according to their defined priority.
  74533. * @hidden Internal Use Only
  74534. */
  74535. _reorderLightsInScene(): void;
  74536. /**
  74537. * Prepares the list of defines specific to the light type.
  74538. * @param defines the list of defines
  74539. * @param lightIndex defines the index of the light for the effect
  74540. */
  74541. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74542. }
  74543. }
  74544. declare module BABYLON {
  74545. /**
  74546. * Creates an instance based on a source mesh.
  74547. */
  74548. export class InstancedMesh extends AbstractMesh {
  74549. private _sourceMesh;
  74550. private _currentLOD;
  74551. /** @hidden */
  74552. _indexInSourceMeshInstanceArray: number;
  74553. constructor(name: string, source: Mesh);
  74554. /**
  74555. * Returns the string "InstancedMesh".
  74556. */
  74557. getClassName(): string;
  74558. /** Gets the list of lights affecting that mesh */
  74559. readonly lightSources: Light[];
  74560. _resyncLightSources(): void;
  74561. _resyncLighSource(light: Light): void;
  74562. _removeLightSource(light: Light): void;
  74563. /**
  74564. * If the source mesh receives shadows
  74565. */
  74566. readonly receiveShadows: boolean;
  74567. /**
  74568. * The material of the source mesh
  74569. */
  74570. readonly material: Nullable<Material>;
  74571. /**
  74572. * Visibility of the source mesh
  74573. */
  74574. readonly visibility: number;
  74575. /**
  74576. * Skeleton of the source mesh
  74577. */
  74578. readonly skeleton: Nullable<Skeleton>;
  74579. /**
  74580. * Rendering ground id of the source mesh
  74581. */
  74582. renderingGroupId: number;
  74583. /**
  74584. * Returns the total number of vertices (integer).
  74585. */
  74586. getTotalVertices(): number;
  74587. /**
  74588. * Returns a positive integer : the total number of indices in this mesh geometry.
  74589. * @returns the numner of indices or zero if the mesh has no geometry.
  74590. */
  74591. getTotalIndices(): number;
  74592. /**
  74593. * The source mesh of the instance
  74594. */
  74595. readonly sourceMesh: Mesh;
  74596. /**
  74597. * Is this node ready to be used/rendered
  74598. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74599. * @return {boolean} is it ready
  74600. */
  74601. isReady(completeCheck?: boolean): boolean;
  74602. /**
  74603. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74604. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74605. * @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.
  74606. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74607. */
  74608. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74609. /**
  74610. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74611. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74612. * The `data` are either a numeric array either a Float32Array.
  74613. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74614. * 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).
  74615. * Note that a new underlying VertexBuffer object is created each call.
  74616. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74617. *
  74618. * Possible `kind` values :
  74619. * - VertexBuffer.PositionKind
  74620. * - VertexBuffer.UVKind
  74621. * - VertexBuffer.UV2Kind
  74622. * - VertexBuffer.UV3Kind
  74623. * - VertexBuffer.UV4Kind
  74624. * - VertexBuffer.UV5Kind
  74625. * - VertexBuffer.UV6Kind
  74626. * - VertexBuffer.ColorKind
  74627. * - VertexBuffer.MatricesIndicesKind
  74628. * - VertexBuffer.MatricesIndicesExtraKind
  74629. * - VertexBuffer.MatricesWeightsKind
  74630. * - VertexBuffer.MatricesWeightsExtraKind
  74631. *
  74632. * Returns the Mesh.
  74633. */
  74634. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74635. /**
  74636. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74637. * If the mesh has no geometry, it is simply returned as it is.
  74638. * The `data` are either a numeric array either a Float32Array.
  74639. * No new underlying VertexBuffer object is created.
  74640. * 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.
  74641. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74642. *
  74643. * Possible `kind` values :
  74644. * - VertexBuffer.PositionKind
  74645. * - VertexBuffer.UVKind
  74646. * - VertexBuffer.UV2Kind
  74647. * - VertexBuffer.UV3Kind
  74648. * - VertexBuffer.UV4Kind
  74649. * - VertexBuffer.UV5Kind
  74650. * - VertexBuffer.UV6Kind
  74651. * - VertexBuffer.ColorKind
  74652. * - VertexBuffer.MatricesIndicesKind
  74653. * - VertexBuffer.MatricesIndicesExtraKind
  74654. * - VertexBuffer.MatricesWeightsKind
  74655. * - VertexBuffer.MatricesWeightsExtraKind
  74656. *
  74657. * Returns the Mesh.
  74658. */
  74659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74660. /**
  74661. * Sets the mesh indices.
  74662. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74663. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74664. * This method creates a new index buffer each call.
  74665. * Returns the Mesh.
  74666. */
  74667. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74668. /**
  74669. * Boolean : True if the mesh owns the requested kind of data.
  74670. */
  74671. isVerticesDataPresent(kind: string): boolean;
  74672. /**
  74673. * Returns an array of indices (IndicesArray).
  74674. */
  74675. getIndices(): Nullable<IndicesArray>;
  74676. readonly _positions: Nullable<Vector3[]>;
  74677. /**
  74678. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74679. * This means the mesh underlying bounding box and sphere are recomputed.
  74680. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74681. * @returns the current mesh
  74682. */
  74683. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74684. /** @hidden */
  74685. _preActivate(): InstancedMesh;
  74686. /** @hidden */
  74687. _activate(renderId: number, intermediateRendering: boolean): boolean;
  74688. /** @hidden */
  74689. _postActivate(): void;
  74690. getWorldMatrix(): Matrix;
  74691. readonly isAnInstance: boolean;
  74692. /**
  74693. * Returns the current associated LOD AbstractMesh.
  74694. */
  74695. getLOD(camera: Camera): AbstractMesh;
  74696. /** @hidden */
  74697. _syncSubMeshes(): InstancedMesh;
  74698. /** @hidden */
  74699. _generatePointsArray(): boolean;
  74700. /**
  74701. * Creates a new InstancedMesh from the current mesh.
  74702. * - name (string) : the cloned mesh name
  74703. * - newParent (optional Node) : the optional Node to parent the clone to.
  74704. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74705. *
  74706. * Returns the clone.
  74707. */
  74708. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74709. /**
  74710. * Disposes the InstancedMesh.
  74711. * Returns nothing.
  74712. */
  74713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74714. }
  74715. }
  74716. declare module BABYLON {
  74717. /**
  74718. * Defines the options associated with the creation of a shader material.
  74719. */
  74720. export interface IShaderMaterialOptions {
  74721. /**
  74722. * Does the material work in alpha blend mode
  74723. */
  74724. needAlphaBlending: boolean;
  74725. /**
  74726. * Does the material work in alpha test mode
  74727. */
  74728. needAlphaTesting: boolean;
  74729. /**
  74730. * The list of attribute names used in the shader
  74731. */
  74732. attributes: string[];
  74733. /**
  74734. * The list of unifrom names used in the shader
  74735. */
  74736. uniforms: string[];
  74737. /**
  74738. * The list of UBO names used in the shader
  74739. */
  74740. uniformBuffers: string[];
  74741. /**
  74742. * The list of sampler names used in the shader
  74743. */
  74744. samplers: string[];
  74745. /**
  74746. * The list of defines used in the shader
  74747. */
  74748. defines: string[];
  74749. }
  74750. /**
  74751. * 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.
  74752. *
  74753. * This returned material effects how the mesh will look based on the code in the shaders.
  74754. *
  74755. * @see http://doc.babylonjs.com/how_to/shader_material
  74756. */
  74757. export class ShaderMaterial extends Material {
  74758. private _shaderPath;
  74759. private _options;
  74760. private _textures;
  74761. private _textureArrays;
  74762. private _floats;
  74763. private _ints;
  74764. private _floatsArrays;
  74765. private _colors3;
  74766. private _colors3Arrays;
  74767. private _colors4;
  74768. private _vectors2;
  74769. private _vectors3;
  74770. private _vectors4;
  74771. private _matrices;
  74772. private _matrices3x3;
  74773. private _matrices2x2;
  74774. private _vectors2Arrays;
  74775. private _vectors3Arrays;
  74776. private _cachedWorldViewMatrix;
  74777. private _cachedWorldViewProjectionMatrix;
  74778. private _renderId;
  74779. /**
  74780. * Instantiate a new shader material.
  74781. * 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.
  74782. * This returned material effects how the mesh will look based on the code in the shaders.
  74783. * @see http://doc.babylonjs.com/how_to/shader_material
  74784. * @param name Define the name of the material in the scene
  74785. * @param scene Define the scene the material belongs to
  74786. * @param shaderPath Defines the route to the shader code in one of three ways:
  74787. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74788. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74789. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74790. * @param options Define the options used to create the shader
  74791. */
  74792. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74793. /**
  74794. * Gets the options used to compile the shader.
  74795. * They can be modified to trigger a new compilation
  74796. */
  74797. readonly options: IShaderMaterialOptions;
  74798. /**
  74799. * Gets the current class name of the material e.g. "ShaderMaterial"
  74800. * Mainly use in serialization.
  74801. * @returns the class name
  74802. */
  74803. getClassName(): string;
  74804. /**
  74805. * Specifies if the material will require alpha blending
  74806. * @returns a boolean specifying if alpha blending is needed
  74807. */
  74808. needAlphaBlending(): boolean;
  74809. /**
  74810. * Specifies if this material should be rendered in alpha test mode
  74811. * @returns a boolean specifying if an alpha test is needed.
  74812. */
  74813. needAlphaTesting(): boolean;
  74814. private _checkUniform;
  74815. /**
  74816. * Set a texture in the shader.
  74817. * @param name Define the name of the uniform samplers as defined in the shader
  74818. * @param texture Define the texture to bind to this sampler
  74819. * @return the material itself allowing "fluent" like uniform updates
  74820. */
  74821. setTexture(name: string, texture: Texture): ShaderMaterial;
  74822. /**
  74823. * Set a texture array in the shader.
  74824. * @param name Define the name of the uniform sampler array as defined in the shader
  74825. * @param textures Define the list of textures to bind to this sampler
  74826. * @return the material itself allowing "fluent" like uniform updates
  74827. */
  74828. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74829. /**
  74830. * Set a float in the shader.
  74831. * @param name Define the name of the uniform as defined in the shader
  74832. * @param value Define the value to give to the uniform
  74833. * @return the material itself allowing "fluent" like uniform updates
  74834. */
  74835. setFloat(name: string, value: number): ShaderMaterial;
  74836. /**
  74837. * Set a int in the shader.
  74838. * @param name Define the name of the uniform as defined in the shader
  74839. * @param value Define the value to give to the uniform
  74840. * @return the material itself allowing "fluent" like uniform updates
  74841. */
  74842. setInt(name: string, value: number): ShaderMaterial;
  74843. /**
  74844. * Set an array of floats in the shader.
  74845. * @param name Define the name of the uniform as defined in the shader
  74846. * @param value Define the value to give to the uniform
  74847. * @return the material itself allowing "fluent" like uniform updates
  74848. */
  74849. setFloats(name: string, value: number[]): ShaderMaterial;
  74850. /**
  74851. * Set a vec3 in the shader from a Color3.
  74852. * @param name Define the name of the uniform as defined in the shader
  74853. * @param value Define the value to give to the uniform
  74854. * @return the material itself allowing "fluent" like uniform updates
  74855. */
  74856. setColor3(name: string, value: Color3): ShaderMaterial;
  74857. /**
  74858. * Set a vec3 array in the shader from a Color3 array.
  74859. * @param name Define the name of the uniform as defined in the shader
  74860. * @param value Define the value to give to the uniform
  74861. * @return the material itself allowing "fluent" like uniform updates
  74862. */
  74863. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74864. /**
  74865. * Set a vec4 in the shader from a Color4.
  74866. * @param name Define the name of the uniform as defined in the shader
  74867. * @param value Define the value to give to the uniform
  74868. * @return the material itself allowing "fluent" like uniform updates
  74869. */
  74870. setColor4(name: string, value: Color4): ShaderMaterial;
  74871. /**
  74872. * Set a vec2 in the shader from a Vector2.
  74873. * @param name Define the name of the uniform as defined in the shader
  74874. * @param value Define the value to give to the uniform
  74875. * @return the material itself allowing "fluent" like uniform updates
  74876. */
  74877. setVector2(name: string, value: Vector2): ShaderMaterial;
  74878. /**
  74879. * Set a vec3 in the shader from a Vector3.
  74880. * @param name Define the name of the uniform as defined in the shader
  74881. * @param value Define the value to give to the uniform
  74882. * @return the material itself allowing "fluent" like uniform updates
  74883. */
  74884. setVector3(name: string, value: Vector3): ShaderMaterial;
  74885. /**
  74886. * Set a vec4 in the shader from a Vector4.
  74887. * @param name Define the name of the uniform as defined in the shader
  74888. * @param value Define the value to give to the uniform
  74889. * @return the material itself allowing "fluent" like uniform updates
  74890. */
  74891. setVector4(name: string, value: Vector4): ShaderMaterial;
  74892. /**
  74893. * Set a mat4 in the shader from a Matrix.
  74894. * @param name Define the name of the uniform as defined in the shader
  74895. * @param value Define the value to give to the uniform
  74896. * @return the material itself allowing "fluent" like uniform updates
  74897. */
  74898. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74899. /**
  74900. * Set a mat3 in the shader from a Float32Array.
  74901. * @param name Define the name of the uniform as defined in the shader
  74902. * @param value Define the value to give to the uniform
  74903. * @return the material itself allowing "fluent" like uniform updates
  74904. */
  74905. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74906. /**
  74907. * Set a mat2 in the shader from a Float32Array.
  74908. * @param name Define the name of the uniform as defined in the shader
  74909. * @param value Define the value to give to the uniform
  74910. * @return the material itself allowing "fluent" like uniform updates
  74911. */
  74912. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74913. /**
  74914. * Set a vec2 array in the shader from a number array.
  74915. * @param name Define the name of the uniform as defined in the shader
  74916. * @param value Define the value to give to the uniform
  74917. * @return the material itself allowing "fluent" like uniform updates
  74918. */
  74919. setArray2(name: string, value: number[]): ShaderMaterial;
  74920. /**
  74921. * Set a vec3 array in the shader from a number array.
  74922. * @param name Define the name of the uniform as defined in the shader
  74923. * @param value Define the value to give to the uniform
  74924. * @return the material itself allowing "fluent" like uniform updates
  74925. */
  74926. setArray3(name: string, value: number[]): ShaderMaterial;
  74927. private _checkCache;
  74928. /**
  74929. * Specifies that the submesh is ready to be used
  74930. * @param mesh defines the mesh to check
  74931. * @param subMesh defines which submesh to check
  74932. * @param useInstances specifies that instances should be used
  74933. * @returns a boolean indicating that the submesh is ready or not
  74934. */
  74935. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  74936. /**
  74937. * Checks if the material is ready to render the requested mesh
  74938. * @param mesh Define the mesh to render
  74939. * @param useInstances Define whether or not the material is used with instances
  74940. * @returns true if ready, otherwise false
  74941. */
  74942. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74943. /**
  74944. * Binds the world matrix to the material
  74945. * @param world defines the world transformation matrix
  74946. */
  74947. bindOnlyWorldMatrix(world: Matrix): void;
  74948. /**
  74949. * Binds the material to the mesh
  74950. * @param world defines the world transformation matrix
  74951. * @param mesh defines the mesh to bind the material to
  74952. */
  74953. bind(world: Matrix, mesh?: Mesh): void;
  74954. /**
  74955. * Gets the active textures from the material
  74956. * @returns an array of textures
  74957. */
  74958. getActiveTextures(): BaseTexture[];
  74959. /**
  74960. * Specifies if the material uses a texture
  74961. * @param texture defines the texture to check against the material
  74962. * @returns a boolean specifying if the material uses the texture
  74963. */
  74964. hasTexture(texture: BaseTexture): boolean;
  74965. /**
  74966. * Makes a duplicate of the material, and gives it a new name
  74967. * @param name defines the new name for the duplicated material
  74968. * @returns the cloned material
  74969. */
  74970. clone(name: string): ShaderMaterial;
  74971. /**
  74972. * Disposes the material
  74973. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74974. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74975. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74976. */
  74977. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74978. /**
  74979. * Serializes this material in a JSON representation
  74980. * @returns the serialized material object
  74981. */
  74982. serialize(): any;
  74983. /**
  74984. * Creates a shader material from parsed shader material data
  74985. * @param source defines the JSON represnetation of the material
  74986. * @param scene defines the hosting scene
  74987. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74988. * @returns a new material
  74989. */
  74990. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74991. }
  74992. }
  74993. declare module BABYLON {
  74994. /** @hidden */
  74995. export var clipPlaneFragmentDeclaration: {
  74996. name: string;
  74997. shader: string;
  74998. };
  74999. }
  75000. declare module BABYLON {
  75001. /** @hidden */
  75002. export var clipPlaneFragment: {
  75003. name: string;
  75004. shader: string;
  75005. };
  75006. }
  75007. declare module BABYLON {
  75008. /** @hidden */
  75009. export var colorPixelShader: {
  75010. name: string;
  75011. shader: string;
  75012. };
  75013. }
  75014. declare module BABYLON {
  75015. /** @hidden */
  75016. export var clipPlaneVertexDeclaration: {
  75017. name: string;
  75018. shader: string;
  75019. };
  75020. }
  75021. declare module BABYLON {
  75022. /** @hidden */
  75023. export var clipPlaneVertex: {
  75024. name: string;
  75025. shader: string;
  75026. };
  75027. }
  75028. declare module BABYLON {
  75029. /** @hidden */
  75030. export var colorVertexShader: {
  75031. name: string;
  75032. shader: string;
  75033. };
  75034. }
  75035. declare module BABYLON {
  75036. /**
  75037. * Line mesh
  75038. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75039. */
  75040. export class LinesMesh extends Mesh {
  75041. /**
  75042. * If vertex color should be applied to the mesh
  75043. */
  75044. readonly useVertexColor?: boolean | undefined;
  75045. /**
  75046. * If vertex alpha should be applied to the mesh
  75047. */
  75048. readonly useVertexAlpha?: boolean | undefined;
  75049. /**
  75050. * Color of the line (Default: White)
  75051. */
  75052. color: Color3;
  75053. /**
  75054. * Alpha of the line (Default: 1)
  75055. */
  75056. alpha: number;
  75057. /**
  75058. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75059. * This margin is expressed in world space coordinates, so its value may vary.
  75060. * Default value is 0.1
  75061. */
  75062. intersectionThreshold: number;
  75063. private _colorShader;
  75064. private color4;
  75065. /**
  75066. * Creates a new LinesMesh
  75067. * @param name defines the name
  75068. * @param scene defines the hosting scene
  75069. * @param parent defines the parent mesh if any
  75070. * @param source defines the optional source LinesMesh used to clone data from
  75071. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75072. * When false, achieved by calling a clone(), also passing False.
  75073. * This will make creation of children, recursive.
  75074. * @param useVertexColor defines if this LinesMesh supports vertex color
  75075. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75076. */
  75077. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75078. /**
  75079. * If vertex color should be applied to the mesh
  75080. */
  75081. useVertexColor?: boolean | undefined,
  75082. /**
  75083. * If vertex alpha should be applied to the mesh
  75084. */
  75085. useVertexAlpha?: boolean | undefined);
  75086. private _addClipPlaneDefine;
  75087. private _removeClipPlaneDefine;
  75088. isReady(): boolean;
  75089. /**
  75090. * Returns the string "LineMesh"
  75091. */
  75092. getClassName(): string;
  75093. /**
  75094. * @hidden
  75095. */
  75096. /**
  75097. * @hidden
  75098. */
  75099. material: Material;
  75100. /**
  75101. * @hidden
  75102. */
  75103. readonly checkCollisions: boolean;
  75104. /** @hidden */
  75105. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75106. /** @hidden */
  75107. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75108. /**
  75109. * Disposes of the line mesh
  75110. * @param doNotRecurse If children should be disposed
  75111. */
  75112. dispose(doNotRecurse?: boolean): void;
  75113. /**
  75114. * Returns a new LineMesh object cloned from the current one.
  75115. */
  75116. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75117. /**
  75118. * Creates a new InstancedLinesMesh object from the mesh model.
  75119. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75120. * @param name defines the name of the new instance
  75121. * @returns a new InstancedLinesMesh
  75122. */
  75123. createInstance(name: string): InstancedLinesMesh;
  75124. }
  75125. /**
  75126. * Creates an instance based on a source LinesMesh
  75127. */
  75128. export class InstancedLinesMesh extends InstancedMesh {
  75129. /**
  75130. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75131. * This margin is expressed in world space coordinates, so its value may vary.
  75132. * Initilized with the intersectionThreshold value of the source LinesMesh
  75133. */
  75134. intersectionThreshold: number;
  75135. constructor(name: string, source: LinesMesh);
  75136. /**
  75137. * Returns the string "InstancedLinesMesh".
  75138. */
  75139. getClassName(): string;
  75140. }
  75141. }
  75142. declare module BABYLON {
  75143. /**
  75144. * Mesh representing the gorund
  75145. */
  75146. export class GroundMesh extends Mesh {
  75147. /** If octree should be generated */
  75148. generateOctree: boolean;
  75149. private _heightQuads;
  75150. /** @hidden */
  75151. _subdivisionsX: number;
  75152. /** @hidden */
  75153. _subdivisionsY: number;
  75154. /** @hidden */
  75155. _width: number;
  75156. /** @hidden */
  75157. _height: number;
  75158. /** @hidden */
  75159. _minX: number;
  75160. /** @hidden */
  75161. _maxX: number;
  75162. /** @hidden */
  75163. _minZ: number;
  75164. /** @hidden */
  75165. _maxZ: number;
  75166. constructor(name: string, scene: Scene);
  75167. /**
  75168. * "GroundMesh"
  75169. * @returns "GroundMesh"
  75170. */
  75171. getClassName(): string;
  75172. /**
  75173. * The minimum of x and y subdivisions
  75174. */
  75175. readonly subdivisions: number;
  75176. /**
  75177. * X subdivisions
  75178. */
  75179. readonly subdivisionsX: number;
  75180. /**
  75181. * Y subdivisions
  75182. */
  75183. readonly subdivisionsY: number;
  75184. /**
  75185. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75186. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75187. * @param chunksCount the number of subdivisions for x and y
  75188. * @param octreeBlocksSize (Default: 32)
  75189. */
  75190. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75191. /**
  75192. * Returns a height (y) value in the Worl system :
  75193. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75194. * @param x x coordinate
  75195. * @param z z coordinate
  75196. * @returns the ground y position if (x, z) are outside the ground surface.
  75197. */
  75198. getHeightAtCoordinates(x: number, z: number): number;
  75199. /**
  75200. * Returns a normalized vector (Vector3) orthogonal to the ground
  75201. * at the ground coordinates (x, z) expressed in the World system.
  75202. * @param x x coordinate
  75203. * @param z z coordinate
  75204. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75205. */
  75206. getNormalAtCoordinates(x: number, z: number): Vector3;
  75207. /**
  75208. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75209. * at the ground coordinates (x, z) expressed in the World system.
  75210. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75211. * @param x x coordinate
  75212. * @param z z coordinate
  75213. * @param ref vector to store the result
  75214. * @returns the GroundMesh.
  75215. */
  75216. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75217. /**
  75218. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75219. * if the ground has been updated.
  75220. * This can be used in the render loop.
  75221. * @returns the GroundMesh.
  75222. */
  75223. updateCoordinateHeights(): GroundMesh;
  75224. private _getFacetAt;
  75225. private _initHeightQuads;
  75226. private _computeHeightQuads;
  75227. /**
  75228. * Serializes this ground mesh
  75229. * @param serializationObject object to write serialization to
  75230. */
  75231. serialize(serializationObject: any): void;
  75232. /**
  75233. * Parses a serialized ground mesh
  75234. * @param parsedMesh the serialized mesh
  75235. * @param scene the scene to create the ground mesh in
  75236. * @returns the created ground mesh
  75237. */
  75238. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75239. }
  75240. }
  75241. declare module BABYLON {
  75242. /**
  75243. * Interface for Physics-Joint data
  75244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75245. */
  75246. export interface PhysicsJointData {
  75247. /**
  75248. * The main pivot of the joint
  75249. */
  75250. mainPivot?: Vector3;
  75251. /**
  75252. * The connected pivot of the joint
  75253. */
  75254. connectedPivot?: Vector3;
  75255. /**
  75256. * The main axis of the joint
  75257. */
  75258. mainAxis?: Vector3;
  75259. /**
  75260. * The connected axis of the joint
  75261. */
  75262. connectedAxis?: Vector3;
  75263. /**
  75264. * The collision of the joint
  75265. */
  75266. collision?: boolean;
  75267. /**
  75268. * Native Oimo/Cannon/Energy data
  75269. */
  75270. nativeParams?: any;
  75271. }
  75272. /**
  75273. * This is a holder class for the physics joint created by the physics plugin
  75274. * It holds a set of functions to control the underlying joint
  75275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75276. */
  75277. export class PhysicsJoint {
  75278. /**
  75279. * The type of the physics joint
  75280. */
  75281. type: number;
  75282. /**
  75283. * The data for the physics joint
  75284. */
  75285. jointData: PhysicsJointData;
  75286. private _physicsJoint;
  75287. protected _physicsPlugin: IPhysicsEnginePlugin;
  75288. /**
  75289. * Initializes the physics joint
  75290. * @param type The type of the physics joint
  75291. * @param jointData The data for the physics joint
  75292. */
  75293. constructor(
  75294. /**
  75295. * The type of the physics joint
  75296. */
  75297. type: number,
  75298. /**
  75299. * The data for the physics joint
  75300. */
  75301. jointData: PhysicsJointData);
  75302. /**
  75303. * Gets the physics joint
  75304. */
  75305. /**
  75306. * Sets the physics joint
  75307. */
  75308. physicsJoint: any;
  75309. /**
  75310. * Sets the physics plugin
  75311. */
  75312. physicsPlugin: IPhysicsEnginePlugin;
  75313. /**
  75314. * Execute a function that is physics-plugin specific.
  75315. * @param {Function} func the function that will be executed.
  75316. * It accepts two parameters: the physics world and the physics joint
  75317. */
  75318. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75319. /**
  75320. * Distance-Joint type
  75321. */
  75322. static DistanceJoint: number;
  75323. /**
  75324. * Hinge-Joint type
  75325. */
  75326. static HingeJoint: number;
  75327. /**
  75328. * Ball-and-Socket joint type
  75329. */
  75330. static BallAndSocketJoint: number;
  75331. /**
  75332. * Wheel-Joint type
  75333. */
  75334. static WheelJoint: number;
  75335. /**
  75336. * Slider-Joint type
  75337. */
  75338. static SliderJoint: number;
  75339. /**
  75340. * Prismatic-Joint type
  75341. */
  75342. static PrismaticJoint: number;
  75343. /**
  75344. * Universal-Joint type
  75345. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75346. */
  75347. static UniversalJoint: number;
  75348. /**
  75349. * Hinge-Joint 2 type
  75350. */
  75351. static Hinge2Joint: number;
  75352. /**
  75353. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75354. */
  75355. static PointToPointJoint: number;
  75356. /**
  75357. * Spring-Joint type
  75358. */
  75359. static SpringJoint: number;
  75360. /**
  75361. * Lock-Joint type
  75362. */
  75363. static LockJoint: number;
  75364. }
  75365. /**
  75366. * A class representing a physics distance joint
  75367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75368. */
  75369. export class DistanceJoint extends PhysicsJoint {
  75370. /**
  75371. *
  75372. * @param jointData The data for the Distance-Joint
  75373. */
  75374. constructor(jointData: DistanceJointData);
  75375. /**
  75376. * Update the predefined distance.
  75377. * @param maxDistance The maximum preferred distance
  75378. * @param minDistance The minimum preferred distance
  75379. */
  75380. updateDistance(maxDistance: number, minDistance?: number): void;
  75381. }
  75382. /**
  75383. * Represents a Motor-Enabled Joint
  75384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75385. */
  75386. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75387. /**
  75388. * Initializes the Motor-Enabled Joint
  75389. * @param type The type of the joint
  75390. * @param jointData The physica joint data for the joint
  75391. */
  75392. constructor(type: number, jointData: PhysicsJointData);
  75393. /**
  75394. * Set the motor values.
  75395. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75396. * @param force the force to apply
  75397. * @param maxForce max force for this motor.
  75398. */
  75399. setMotor(force?: number, maxForce?: number): void;
  75400. /**
  75401. * Set the motor's limits.
  75402. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75403. * @param upperLimit The upper limit of the motor
  75404. * @param lowerLimit The lower limit of the motor
  75405. */
  75406. setLimit(upperLimit: number, lowerLimit?: number): void;
  75407. }
  75408. /**
  75409. * This class represents a single physics Hinge-Joint
  75410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75411. */
  75412. export class HingeJoint extends MotorEnabledJoint {
  75413. /**
  75414. * Initializes the Hinge-Joint
  75415. * @param jointData The joint data for the Hinge-Joint
  75416. */
  75417. constructor(jointData: PhysicsJointData);
  75418. /**
  75419. * Set the motor values.
  75420. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75421. * @param {number} force the force to apply
  75422. * @param {number} maxForce max force for this motor.
  75423. */
  75424. setMotor(force?: number, maxForce?: number): void;
  75425. /**
  75426. * Set the motor's limits.
  75427. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75428. * @param upperLimit The upper limit of the motor
  75429. * @param lowerLimit The lower limit of the motor
  75430. */
  75431. setLimit(upperLimit: number, lowerLimit?: number): void;
  75432. }
  75433. /**
  75434. * This class represents a dual hinge physics joint (same as wheel joint)
  75435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75436. */
  75437. export class Hinge2Joint extends MotorEnabledJoint {
  75438. /**
  75439. * Initializes the Hinge2-Joint
  75440. * @param jointData The joint data for the Hinge2-Joint
  75441. */
  75442. constructor(jointData: PhysicsJointData);
  75443. /**
  75444. * Set the motor values.
  75445. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75446. * @param {number} targetSpeed the speed the motor is to reach
  75447. * @param {number} maxForce max force for this motor.
  75448. * @param {motorIndex} the motor's index, 0 or 1.
  75449. */
  75450. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75451. /**
  75452. * Set the motor limits.
  75453. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75454. * @param {number} upperLimit the upper limit
  75455. * @param {number} lowerLimit lower limit
  75456. * @param {motorIndex} the motor's index, 0 or 1.
  75457. */
  75458. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75459. }
  75460. /**
  75461. * Interface for a motor enabled joint
  75462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75463. */
  75464. export interface IMotorEnabledJoint {
  75465. /**
  75466. * Physics joint
  75467. */
  75468. physicsJoint: any;
  75469. /**
  75470. * Sets the motor of the motor-enabled joint
  75471. * @param force The force of the motor
  75472. * @param maxForce The maximum force of the motor
  75473. * @param motorIndex The index of the motor
  75474. */
  75475. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75476. /**
  75477. * Sets the limit of the motor
  75478. * @param upperLimit The upper limit of the motor
  75479. * @param lowerLimit The lower limit of the motor
  75480. * @param motorIndex The index of the motor
  75481. */
  75482. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75483. }
  75484. /**
  75485. * Joint data for a Distance-Joint
  75486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75487. */
  75488. export interface DistanceJointData extends PhysicsJointData {
  75489. /**
  75490. * Max distance the 2 joint objects can be apart
  75491. */
  75492. maxDistance: number;
  75493. }
  75494. /**
  75495. * Joint data from a spring joint
  75496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75497. */
  75498. export interface SpringJointData extends PhysicsJointData {
  75499. /**
  75500. * Length of the spring
  75501. */
  75502. length: number;
  75503. /**
  75504. * Stiffness of the spring
  75505. */
  75506. stiffness: number;
  75507. /**
  75508. * Damping of the spring
  75509. */
  75510. damping: number;
  75511. /** this callback will be called when applying the force to the impostors. */
  75512. forceApplicationCallback: () => void;
  75513. }
  75514. }
  75515. declare module BABYLON {
  75516. /**
  75517. * Holds the data for the raycast result
  75518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75519. */
  75520. export class PhysicsRaycastResult {
  75521. private _hasHit;
  75522. private _hitDistance;
  75523. private _hitNormalWorld;
  75524. private _hitPointWorld;
  75525. private _rayFromWorld;
  75526. private _rayToWorld;
  75527. /**
  75528. * Gets if there was a hit
  75529. */
  75530. readonly hasHit: boolean;
  75531. /**
  75532. * Gets the distance from the hit
  75533. */
  75534. readonly hitDistance: number;
  75535. /**
  75536. * Gets the hit normal/direction in the world
  75537. */
  75538. readonly hitNormalWorld: Vector3;
  75539. /**
  75540. * Gets the hit point in the world
  75541. */
  75542. readonly hitPointWorld: Vector3;
  75543. /**
  75544. * Gets the ray "start point" of the ray in the world
  75545. */
  75546. readonly rayFromWorld: Vector3;
  75547. /**
  75548. * Gets the ray "end point" of the ray in the world
  75549. */
  75550. readonly rayToWorld: Vector3;
  75551. /**
  75552. * Sets the hit data (normal & point in world space)
  75553. * @param hitNormalWorld defines the normal in world space
  75554. * @param hitPointWorld defines the point in world space
  75555. */
  75556. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  75557. /**
  75558. * Sets the distance from the start point to the hit point
  75559. * @param distance
  75560. */
  75561. setHitDistance(distance: number): void;
  75562. /**
  75563. * Calculates the distance manually
  75564. */
  75565. calculateHitDistance(): void;
  75566. /**
  75567. * Resets all the values to default
  75568. * @param from The from point on world space
  75569. * @param to The to point on world space
  75570. */
  75571. reset(from?: Vector3, to?: Vector3): void;
  75572. }
  75573. /**
  75574. * Interface for the size containing width and height
  75575. */
  75576. interface IXYZ {
  75577. /**
  75578. * X
  75579. */
  75580. x: number;
  75581. /**
  75582. * Y
  75583. */
  75584. y: number;
  75585. /**
  75586. * Z
  75587. */
  75588. z: number;
  75589. }
  75590. }
  75591. declare module BABYLON {
  75592. /**
  75593. * Interface used to describe a physics joint
  75594. */
  75595. export interface PhysicsImpostorJoint {
  75596. /** Defines the main impostor to which the joint is linked */
  75597. mainImpostor: PhysicsImpostor;
  75598. /** Defines the impostor that is connected to the main impostor using this joint */
  75599. connectedImpostor: PhysicsImpostor;
  75600. /** Defines the joint itself */
  75601. joint: PhysicsJoint;
  75602. }
  75603. /** @hidden */
  75604. export interface IPhysicsEnginePlugin {
  75605. world: any;
  75606. name: string;
  75607. setGravity(gravity: Vector3): void;
  75608. setTimeStep(timeStep: number): void;
  75609. getTimeStep(): number;
  75610. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  75611. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75612. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75613. generatePhysicsBody(impostor: PhysicsImpostor): void;
  75614. removePhysicsBody(impostor: PhysicsImpostor): void;
  75615. generateJoint(joint: PhysicsImpostorJoint): void;
  75616. removeJoint(joint: PhysicsImpostorJoint): void;
  75617. isSupported(): boolean;
  75618. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  75619. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  75620. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75621. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75622. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75623. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75624. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  75625. getBodyMass(impostor: PhysicsImpostor): number;
  75626. getBodyFriction(impostor: PhysicsImpostor): number;
  75627. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  75628. getBodyRestitution(impostor: PhysicsImpostor): number;
  75629. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  75630. getBodyPressure?(impostor: PhysicsImpostor): number;
  75631. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  75632. getBodyStiffness?(impostor: PhysicsImpostor): number;
  75633. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  75634. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  75635. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  75636. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  75637. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  75638. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75639. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75640. sleepBody(impostor: PhysicsImpostor): void;
  75641. wakeUpBody(impostor: PhysicsImpostor): void;
  75642. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75643. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  75644. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  75645. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75646. getRadius(impostor: PhysicsImpostor): number;
  75647. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  75648. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  75649. dispose(): void;
  75650. }
  75651. /**
  75652. * Interface used to define a physics engine
  75653. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  75654. */
  75655. export interface IPhysicsEngine {
  75656. /**
  75657. * Gets the gravity vector used by the simulation
  75658. */
  75659. gravity: Vector3;
  75660. /**
  75661. * Sets the gravity vector used by the simulation
  75662. * @param gravity defines the gravity vector to use
  75663. */
  75664. setGravity(gravity: Vector3): void;
  75665. /**
  75666. * Set the time step of the physics engine.
  75667. * Default is 1/60.
  75668. * To slow it down, enter 1/600 for example.
  75669. * To speed it up, 1/30
  75670. * @param newTimeStep the new timestep to apply to this world.
  75671. */
  75672. setTimeStep(newTimeStep: number): void;
  75673. /**
  75674. * Get the time step of the physics engine.
  75675. * @returns the current time step
  75676. */
  75677. getTimeStep(): number;
  75678. /**
  75679. * Release all resources
  75680. */
  75681. dispose(): void;
  75682. /**
  75683. * Gets the name of the current physics plugin
  75684. * @returns the name of the plugin
  75685. */
  75686. getPhysicsPluginName(): string;
  75687. /**
  75688. * Adding a new impostor for the impostor tracking.
  75689. * This will be done by the impostor itself.
  75690. * @param impostor the impostor to add
  75691. */
  75692. addImpostor(impostor: PhysicsImpostor): void;
  75693. /**
  75694. * Remove an impostor from the engine.
  75695. * This impostor and its mesh will not longer be updated by the physics engine.
  75696. * @param impostor the impostor to remove
  75697. */
  75698. removeImpostor(impostor: PhysicsImpostor): void;
  75699. /**
  75700. * Add a joint to the physics engine
  75701. * @param mainImpostor defines the main impostor to which the joint is added.
  75702. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  75703. * @param joint defines the joint that will connect both impostors.
  75704. */
  75705. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75706. /**
  75707. * Removes a joint from the simulation
  75708. * @param mainImpostor defines the impostor used with the joint
  75709. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  75710. * @param joint defines the joint to remove
  75711. */
  75712. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75713. /**
  75714. * Gets the current plugin used to run the simulation
  75715. * @returns current plugin
  75716. */
  75717. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75718. /**
  75719. * Gets the list of physic impostors
  75720. * @returns an array of PhysicsImpostor
  75721. */
  75722. getImpostors(): Array<PhysicsImpostor>;
  75723. /**
  75724. * Gets the impostor for a physics enabled object
  75725. * @param object defines the object impersonated by the impostor
  75726. * @returns the PhysicsImpostor or null if not found
  75727. */
  75728. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75729. /**
  75730. * Gets the impostor for a physics body object
  75731. * @param body defines physics body used by the impostor
  75732. * @returns the PhysicsImpostor or null if not found
  75733. */
  75734. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75735. /**
  75736. * Does a raycast in the physics world
  75737. * @param from when should the ray start?
  75738. * @param to when should the ray end?
  75739. * @returns PhysicsRaycastResult
  75740. */
  75741. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75742. /**
  75743. * Called by the scene. No need to call it.
  75744. * @param delta defines the timespam between frames
  75745. */
  75746. _step(delta: number): void;
  75747. }
  75748. }
  75749. declare module BABYLON {
  75750. /**
  75751. * The interface for the physics imposter parameters
  75752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75753. */
  75754. export interface PhysicsImpostorParameters {
  75755. /**
  75756. * The mass of the physics imposter
  75757. */
  75758. mass: number;
  75759. /**
  75760. * The friction of the physics imposter
  75761. */
  75762. friction?: number;
  75763. /**
  75764. * The coefficient of restitution of the physics imposter
  75765. */
  75766. restitution?: number;
  75767. /**
  75768. * The native options of the physics imposter
  75769. */
  75770. nativeOptions?: any;
  75771. /**
  75772. * Specifies if the parent should be ignored
  75773. */
  75774. ignoreParent?: boolean;
  75775. /**
  75776. * Specifies if bi-directional transformations should be disabled
  75777. */
  75778. disableBidirectionalTransformation?: boolean;
  75779. /**
  75780. * The pressure inside the physics imposter, soft object only
  75781. */
  75782. pressure?: number;
  75783. /**
  75784. * The stiffness the physics imposter, soft object only
  75785. */
  75786. stiffness?: number;
  75787. /**
  75788. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  75789. */
  75790. velocityIterations?: number;
  75791. /**
  75792. * The number of iterations used in maintaining consistent vertex positions, soft object only
  75793. */
  75794. positionIterations?: number;
  75795. /**
  75796. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  75797. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  75798. * Add to fix multiple points
  75799. */
  75800. fixedPoints?: number;
  75801. /**
  75802. * The collision margin around a soft object
  75803. */
  75804. margin?: number;
  75805. /**
  75806. * The collision margin around a soft object
  75807. */
  75808. damping?: number;
  75809. /**
  75810. * The path for a rope based on an extrusion
  75811. */
  75812. path?: any;
  75813. /**
  75814. * The shape of an extrusion used for a rope based on an extrusion
  75815. */
  75816. shape?: any;
  75817. }
  75818. /**
  75819. * Interface for a physics-enabled object
  75820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75821. */
  75822. export interface IPhysicsEnabledObject {
  75823. /**
  75824. * The position of the physics-enabled object
  75825. */
  75826. position: Vector3;
  75827. /**
  75828. * The rotation of the physics-enabled object
  75829. */
  75830. rotationQuaternion: Nullable<Quaternion>;
  75831. /**
  75832. * The scale of the physics-enabled object
  75833. */
  75834. scaling: Vector3;
  75835. /**
  75836. * The rotation of the physics-enabled object
  75837. */
  75838. rotation?: Vector3;
  75839. /**
  75840. * The parent of the physics-enabled object
  75841. */
  75842. parent?: any;
  75843. /**
  75844. * The bounding info of the physics-enabled object
  75845. * @returns The bounding info of the physics-enabled object
  75846. */
  75847. getBoundingInfo(): BoundingInfo;
  75848. /**
  75849. * Computes the world matrix
  75850. * @param force Specifies if the world matrix should be computed by force
  75851. * @returns A world matrix
  75852. */
  75853. computeWorldMatrix(force: boolean): Matrix;
  75854. /**
  75855. * Gets the world matrix
  75856. * @returns A world matrix
  75857. */
  75858. getWorldMatrix?(): Matrix;
  75859. /**
  75860. * Gets the child meshes
  75861. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  75862. * @returns An array of abstract meshes
  75863. */
  75864. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  75865. /**
  75866. * Gets the vertex data
  75867. * @param kind The type of vertex data
  75868. * @returns A nullable array of numbers, or a float32 array
  75869. */
  75870. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  75871. /**
  75872. * Gets the indices from the mesh
  75873. * @returns A nullable array of index arrays
  75874. */
  75875. getIndices?(): Nullable<IndicesArray>;
  75876. /**
  75877. * Gets the scene from the mesh
  75878. * @returns the indices array or null
  75879. */
  75880. getScene?(): Scene;
  75881. /**
  75882. * Gets the absolute position from the mesh
  75883. * @returns the absolute position
  75884. */
  75885. getAbsolutePosition(): Vector3;
  75886. /**
  75887. * Gets the absolute pivot point from the mesh
  75888. * @returns the absolute pivot point
  75889. */
  75890. getAbsolutePivotPoint(): Vector3;
  75891. /**
  75892. * Rotates the mesh
  75893. * @param axis The axis of rotation
  75894. * @param amount The amount of rotation
  75895. * @param space The space of the rotation
  75896. * @returns The rotation transform node
  75897. */
  75898. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  75899. /**
  75900. * Translates the mesh
  75901. * @param axis The axis of translation
  75902. * @param distance The distance of translation
  75903. * @param space The space of the translation
  75904. * @returns The transform node
  75905. */
  75906. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  75907. /**
  75908. * Sets the absolute position of the mesh
  75909. * @param absolutePosition The absolute position of the mesh
  75910. * @returns The transform node
  75911. */
  75912. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  75913. /**
  75914. * Gets the class name of the mesh
  75915. * @returns The class name
  75916. */
  75917. getClassName(): string;
  75918. }
  75919. /**
  75920. * Represents a physics imposter
  75921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75922. */
  75923. export class PhysicsImpostor {
  75924. /**
  75925. * The physics-enabled object used as the physics imposter
  75926. */
  75927. object: IPhysicsEnabledObject;
  75928. /**
  75929. * The type of the physics imposter
  75930. */
  75931. type: number;
  75932. private _options;
  75933. private _scene?;
  75934. /**
  75935. * The default object size of the imposter
  75936. */
  75937. static DEFAULT_OBJECT_SIZE: Vector3;
  75938. /**
  75939. * The identity quaternion of the imposter
  75940. */
  75941. static IDENTITY_QUATERNION: Quaternion;
  75942. /** @hidden */
  75943. _pluginData: any;
  75944. private _physicsEngine;
  75945. private _physicsBody;
  75946. private _bodyUpdateRequired;
  75947. private _onBeforePhysicsStepCallbacks;
  75948. private _onAfterPhysicsStepCallbacks;
  75949. /** @hidden */
  75950. _onPhysicsCollideCallbacks: Array<{
  75951. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  75952. otherImpostors: Array<PhysicsImpostor>;
  75953. }>;
  75954. private _deltaPosition;
  75955. private _deltaRotation;
  75956. private _deltaRotationConjugated;
  75957. /** @hidden */
  75958. _isFromLine: boolean;
  75959. private _parent;
  75960. private _isDisposed;
  75961. private static _tmpVecs;
  75962. private static _tmpQuat;
  75963. /**
  75964. * Specifies if the physics imposter is disposed
  75965. */
  75966. readonly isDisposed: boolean;
  75967. /**
  75968. * Gets the mass of the physics imposter
  75969. */
  75970. mass: number;
  75971. /**
  75972. * Gets the coefficient of friction
  75973. */
  75974. /**
  75975. * Sets the coefficient of friction
  75976. */
  75977. friction: number;
  75978. /**
  75979. * Gets the coefficient of restitution
  75980. */
  75981. /**
  75982. * Sets the coefficient of restitution
  75983. */
  75984. restitution: number;
  75985. /**
  75986. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  75987. */
  75988. /**
  75989. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  75990. */
  75991. pressure: number;
  75992. /**
  75993. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  75994. */
  75995. /**
  75996. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  75997. */
  75998. stiffness: number;
  75999. /**
  76000. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76001. */
  76002. /**
  76003. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76004. */
  76005. velocityIterations: number;
  76006. /**
  76007. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76008. */
  76009. /**
  76010. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76011. */
  76012. positionIterations: number;
  76013. /**
  76014. * The unique id of the physics imposter
  76015. * set by the physics engine when adding this impostor to the array
  76016. */
  76017. uniqueId: number;
  76018. /**
  76019. * @hidden
  76020. */
  76021. soft: boolean;
  76022. /**
  76023. * @hidden
  76024. */
  76025. segments: number;
  76026. private _joints;
  76027. /**
  76028. * Initializes the physics imposter
  76029. * @param object The physics-enabled object used as the physics imposter
  76030. * @param type The type of the physics imposter
  76031. * @param _options The options for the physics imposter
  76032. * @param _scene The Babylon scene
  76033. */
  76034. constructor(
  76035. /**
  76036. * The physics-enabled object used as the physics imposter
  76037. */
  76038. object: IPhysicsEnabledObject,
  76039. /**
  76040. * The type of the physics imposter
  76041. */
  76042. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76043. /**
  76044. * This function will completly initialize this impostor.
  76045. * It will create a new body - but only if this mesh has no parent.
  76046. * If it has, this impostor will not be used other than to define the impostor
  76047. * of the child mesh.
  76048. * @hidden
  76049. */
  76050. _init(): void;
  76051. private _getPhysicsParent;
  76052. /**
  76053. * Should a new body be generated.
  76054. * @returns boolean specifying if body initialization is required
  76055. */
  76056. isBodyInitRequired(): boolean;
  76057. /**
  76058. * Sets the updated scaling
  76059. * @param updated Specifies if the scaling is updated
  76060. */
  76061. setScalingUpdated(): void;
  76062. /**
  76063. * Force a regeneration of this or the parent's impostor's body.
  76064. * Use under cautious - This will remove all joints already implemented.
  76065. */
  76066. forceUpdate(): void;
  76067. /**
  76068. * Gets the body that holds this impostor. Either its own, or its parent.
  76069. */
  76070. /**
  76071. * Set the physics body. Used mainly by the physics engine/plugin
  76072. */
  76073. physicsBody: any;
  76074. /**
  76075. * Get the parent of the physics imposter
  76076. * @returns Physics imposter or null
  76077. */
  76078. /**
  76079. * Sets the parent of the physics imposter
  76080. */
  76081. parent: Nullable<PhysicsImpostor>;
  76082. /**
  76083. * Resets the update flags
  76084. */
  76085. resetUpdateFlags(): void;
  76086. /**
  76087. * Gets the object extend size
  76088. * @returns the object extend size
  76089. */
  76090. getObjectExtendSize(): Vector3;
  76091. /**
  76092. * Gets the object center
  76093. * @returns The object center
  76094. */
  76095. getObjectCenter(): Vector3;
  76096. /**
  76097. * Get a specific parametes from the options parameter
  76098. * @param paramName The object parameter name
  76099. * @returns The object parameter
  76100. */
  76101. getParam(paramName: string): any;
  76102. /**
  76103. * Sets a specific parameter in the options given to the physics plugin
  76104. * @param paramName The parameter name
  76105. * @param value The value of the parameter
  76106. */
  76107. setParam(paramName: string, value: number): void;
  76108. /**
  76109. * Specifically change the body's mass option. Won't recreate the physics body object
  76110. * @param mass The mass of the physics imposter
  76111. */
  76112. setMass(mass: number): void;
  76113. /**
  76114. * Gets the linear velocity
  76115. * @returns linear velocity or null
  76116. */
  76117. getLinearVelocity(): Nullable<Vector3>;
  76118. /**
  76119. * Sets the linear velocity
  76120. * @param velocity linear velocity or null
  76121. */
  76122. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76123. /**
  76124. * Gets the angular velocity
  76125. * @returns angular velocity or null
  76126. */
  76127. getAngularVelocity(): Nullable<Vector3>;
  76128. /**
  76129. * Sets the angular velocity
  76130. * @param velocity The velocity or null
  76131. */
  76132. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76133. /**
  76134. * Execute a function with the physics plugin native code
  76135. * Provide a function the will have two variables - the world object and the physics body object
  76136. * @param func The function to execute with the physics plugin native code
  76137. */
  76138. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76139. /**
  76140. * Register a function that will be executed before the physics world is stepping forward
  76141. * @param func The function to execute before the physics world is stepped forward
  76142. */
  76143. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76144. /**
  76145. * Unregister a function that will be executed before the physics world is stepping forward
  76146. * @param func The function to execute before the physics world is stepped forward
  76147. */
  76148. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76149. /**
  76150. * Register a function that will be executed after the physics step
  76151. * @param func The function to execute after physics step
  76152. */
  76153. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76154. /**
  76155. * Unregisters a function that will be executed after the physics step
  76156. * @param func The function to execute after physics step
  76157. */
  76158. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76159. /**
  76160. * register a function that will be executed when this impostor collides against a different body
  76161. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76162. * @param func Callback that is executed on collision
  76163. */
  76164. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76165. /**
  76166. * Unregisters the physics imposter on contact
  76167. * @param collideAgainst The physics object to collide against
  76168. * @param func Callback to execute on collision
  76169. */
  76170. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76171. private _tmpQuat;
  76172. private _tmpQuat2;
  76173. /**
  76174. * Get the parent rotation
  76175. * @returns The parent rotation
  76176. */
  76177. getParentsRotation(): Quaternion;
  76178. /**
  76179. * this function is executed by the physics engine.
  76180. */
  76181. beforeStep: () => void;
  76182. /**
  76183. * this function is executed by the physics engine
  76184. */
  76185. afterStep: () => void;
  76186. /**
  76187. * Legacy collision detection event support
  76188. */
  76189. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76190. /**
  76191. * event and body object due to cannon's event-based architecture.
  76192. */
  76193. onCollide: (e: {
  76194. body: any;
  76195. }) => void;
  76196. /**
  76197. * Apply a force
  76198. * @param force The force to apply
  76199. * @param contactPoint The contact point for the force
  76200. * @returns The physics imposter
  76201. */
  76202. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76203. /**
  76204. * Apply an impulse
  76205. * @param force The impulse force
  76206. * @param contactPoint The contact point for the impulse force
  76207. * @returns The physics imposter
  76208. */
  76209. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76210. /**
  76211. * A help function to create a joint
  76212. * @param otherImpostor A physics imposter used to create a joint
  76213. * @param jointType The type of joint
  76214. * @param jointData The data for the joint
  76215. * @returns The physics imposter
  76216. */
  76217. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76218. /**
  76219. * Add a joint to this impostor with a different impostor
  76220. * @param otherImpostor A physics imposter used to add a joint
  76221. * @param joint The joint to add
  76222. * @returns The physics imposter
  76223. */
  76224. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76225. /**
  76226. * Add an anchor to a cloth impostor
  76227. * @param otherImpostor rigid impostor to anchor to
  76228. * @param width ratio across width from 0 to 1
  76229. * @param height ratio up height from 0 to 1
  76230. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76231. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76232. * @returns impostor the soft imposter
  76233. */
  76234. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76235. /**
  76236. * Add a hook to a rope impostor
  76237. * @param otherImpostor rigid impostor to anchor to
  76238. * @param length ratio across rope from 0 to 1
  76239. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76240. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76241. * @returns impostor the rope imposter
  76242. */
  76243. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76244. /**
  76245. * Will keep this body still, in a sleep mode.
  76246. * @returns the physics imposter
  76247. */
  76248. sleep(): PhysicsImpostor;
  76249. /**
  76250. * Wake the body up.
  76251. * @returns The physics imposter
  76252. */
  76253. wakeUp(): PhysicsImpostor;
  76254. /**
  76255. * Clones the physics imposter
  76256. * @param newObject The physics imposter clones to this physics-enabled object
  76257. * @returns A nullable physics imposter
  76258. */
  76259. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76260. /**
  76261. * Disposes the physics imposter
  76262. */
  76263. dispose(): void;
  76264. /**
  76265. * Sets the delta position
  76266. * @param position The delta position amount
  76267. */
  76268. setDeltaPosition(position: Vector3): void;
  76269. /**
  76270. * Sets the delta rotation
  76271. * @param rotation The delta rotation amount
  76272. */
  76273. setDeltaRotation(rotation: Quaternion): void;
  76274. /**
  76275. * Gets the box size of the physics imposter and stores the result in the input parameter
  76276. * @param result Stores the box size
  76277. * @returns The physics imposter
  76278. */
  76279. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76280. /**
  76281. * Gets the radius of the physics imposter
  76282. * @returns Radius of the physics imposter
  76283. */
  76284. getRadius(): number;
  76285. /**
  76286. * Sync a bone with this impostor
  76287. * @param bone The bone to sync to the impostor.
  76288. * @param boneMesh The mesh that the bone is influencing.
  76289. * @param jointPivot The pivot of the joint / bone in local space.
  76290. * @param distToJoint Optional distance from the impostor to the joint.
  76291. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76292. */
  76293. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76294. /**
  76295. * Sync impostor to a bone
  76296. * @param bone The bone that the impostor will be synced to.
  76297. * @param boneMesh The mesh that the bone is influencing.
  76298. * @param jointPivot The pivot of the joint / bone in local space.
  76299. * @param distToJoint Optional distance from the impostor to the joint.
  76300. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76301. * @param boneAxis Optional vector3 axis the bone is aligned with
  76302. */
  76303. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76304. /**
  76305. * No-Imposter type
  76306. */
  76307. static NoImpostor: number;
  76308. /**
  76309. * Sphere-Imposter type
  76310. */
  76311. static SphereImpostor: number;
  76312. /**
  76313. * Box-Imposter type
  76314. */
  76315. static BoxImpostor: number;
  76316. /**
  76317. * Plane-Imposter type
  76318. */
  76319. static PlaneImpostor: number;
  76320. /**
  76321. * Mesh-imposter type
  76322. */
  76323. static MeshImpostor: number;
  76324. /**
  76325. * Cylinder-Imposter type
  76326. */
  76327. static CylinderImpostor: number;
  76328. /**
  76329. * Particle-Imposter type
  76330. */
  76331. static ParticleImpostor: number;
  76332. /**
  76333. * Heightmap-Imposter type
  76334. */
  76335. static HeightmapImpostor: number;
  76336. /**
  76337. * ConvexHull-Impostor type (Ammo.js plugin only)
  76338. */
  76339. static ConvexHullImpostor: number;
  76340. /**
  76341. * Rope-Imposter type
  76342. */
  76343. static RopeImpostor: number;
  76344. /**
  76345. * Cloth-Imposter type
  76346. */
  76347. static ClothImpostor: number;
  76348. /**
  76349. * Softbody-Imposter type
  76350. */
  76351. static SoftbodyImpostor: number;
  76352. }
  76353. }
  76354. declare module BABYLON {
  76355. /**
  76356. * @hidden
  76357. **/
  76358. export class _CreationDataStorage {
  76359. closePath?: boolean;
  76360. closeArray?: boolean;
  76361. idx: number[];
  76362. dashSize: number;
  76363. gapSize: number;
  76364. path3D: Path3D;
  76365. pathArray: Vector3[][];
  76366. arc: number;
  76367. radius: number;
  76368. cap: number;
  76369. tessellation: number;
  76370. }
  76371. /**
  76372. * @hidden
  76373. **/
  76374. class _InstanceDataStorage {
  76375. visibleInstances: any;
  76376. batchCache: _InstancesBatch;
  76377. instancesBufferSize: number;
  76378. instancesBuffer: Nullable<Buffer>;
  76379. instancesData: Float32Array;
  76380. overridenInstanceCount: number;
  76381. isFrozen: boolean;
  76382. previousBatch: _InstancesBatch;
  76383. hardwareInstancedRendering: boolean;
  76384. sideOrientation: number;
  76385. }
  76386. /**
  76387. * @hidden
  76388. **/
  76389. export class _InstancesBatch {
  76390. mustReturn: boolean;
  76391. visibleInstances: Nullable<InstancedMesh[]>[];
  76392. renderSelf: boolean[];
  76393. hardwareInstancedRendering: boolean[];
  76394. }
  76395. /**
  76396. * Class used to represent renderable models
  76397. */
  76398. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76399. /**
  76400. * Mesh side orientation : usually the external or front surface
  76401. */
  76402. static readonly FRONTSIDE: number;
  76403. /**
  76404. * Mesh side orientation : usually the internal or back surface
  76405. */
  76406. static readonly BACKSIDE: number;
  76407. /**
  76408. * Mesh side orientation : both internal and external or front and back surfaces
  76409. */
  76410. static readonly DOUBLESIDE: number;
  76411. /**
  76412. * Mesh side orientation : by default, `FRONTSIDE`
  76413. */
  76414. static readonly DEFAULTSIDE: number;
  76415. /**
  76416. * Mesh cap setting : no cap
  76417. */
  76418. static readonly NO_CAP: number;
  76419. /**
  76420. * Mesh cap setting : one cap at the beginning of the mesh
  76421. */
  76422. static readonly CAP_START: number;
  76423. /**
  76424. * Mesh cap setting : one cap at the end of the mesh
  76425. */
  76426. static readonly CAP_END: number;
  76427. /**
  76428. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76429. */
  76430. static readonly CAP_ALL: number;
  76431. /**
  76432. * Mesh pattern setting : no flip or rotate
  76433. */
  76434. static readonly NO_FLIP: number;
  76435. /**
  76436. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76437. */
  76438. static readonly FLIP_TILE: number;
  76439. /**
  76440. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76441. */
  76442. static readonly ROTATE_TILE: number;
  76443. /**
  76444. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76445. */
  76446. static readonly FLIP_ROW: number;
  76447. /**
  76448. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76449. */
  76450. static readonly ROTATE_ROW: number;
  76451. /**
  76452. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76453. */
  76454. static readonly FLIP_N_ROTATE_TILE: number;
  76455. /**
  76456. * Mesh pattern setting : rotate pattern and rotate
  76457. */
  76458. static readonly FLIP_N_ROTATE_ROW: number;
  76459. /**
  76460. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76461. */
  76462. static readonly CENTER: number;
  76463. /**
  76464. * Mesh tile positioning : part tiles on left
  76465. */
  76466. static readonly LEFT: number;
  76467. /**
  76468. * Mesh tile positioning : part tiles on right
  76469. */
  76470. static readonly RIGHT: number;
  76471. /**
  76472. * Mesh tile positioning : part tiles on top
  76473. */
  76474. static readonly TOP: number;
  76475. /**
  76476. * Mesh tile positioning : part tiles on bottom
  76477. */
  76478. static readonly BOTTOM: number;
  76479. /**
  76480. * Gets the default side orientation.
  76481. * @param orientation the orientation to value to attempt to get
  76482. * @returns the default orientation
  76483. * @hidden
  76484. */
  76485. static _GetDefaultSideOrientation(orientation?: number): number;
  76486. private _internalMeshDataInfo;
  76487. /**
  76488. * An event triggered before rendering the mesh
  76489. */
  76490. readonly onBeforeRenderObservable: Observable<Mesh>;
  76491. /**
  76492. * An event triggered before binding the mesh
  76493. */
  76494. readonly onBeforeBindObservable: Observable<Mesh>;
  76495. /**
  76496. * An event triggered after rendering the mesh
  76497. */
  76498. readonly onAfterRenderObservable: Observable<Mesh>;
  76499. /**
  76500. * An event triggered before drawing the mesh
  76501. */
  76502. readonly onBeforeDrawObservable: Observable<Mesh>;
  76503. private _onBeforeDrawObserver;
  76504. /**
  76505. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76506. */
  76507. onBeforeDraw: () => void;
  76508. /**
  76509. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76510. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76511. */
  76512. delayLoadState: number;
  76513. /**
  76514. * Gets the list of instances created from this mesh
  76515. * it is not supposed to be modified manually.
  76516. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76517. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76518. */
  76519. instances: InstancedMesh[];
  76520. /**
  76521. * Gets the file containing delay loading data for this mesh
  76522. */
  76523. delayLoadingFile: string;
  76524. /** @hidden */
  76525. _binaryInfo: any;
  76526. /**
  76527. * User defined function used to change how LOD level selection is done
  76528. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76529. */
  76530. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76531. /**
  76532. * Gets or sets the morph target manager
  76533. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76534. */
  76535. morphTargetManager: Nullable<MorphTargetManager>;
  76536. /** @hidden */
  76537. _creationDataStorage: Nullable<_CreationDataStorage>;
  76538. /** @hidden */
  76539. _geometry: Nullable<Geometry>;
  76540. /** @hidden */
  76541. _delayInfo: Array<string>;
  76542. /** @hidden */
  76543. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76544. /** @hidden */
  76545. _instanceDataStorage: _InstanceDataStorage;
  76546. private _effectiveMaterial;
  76547. /** @hidden */
  76548. _shouldGenerateFlatShading: boolean;
  76549. /** @hidden */
  76550. _originalBuilderSideOrientation: number;
  76551. /**
  76552. * Use this property to change the original side orientation defined at construction time
  76553. */
  76554. overrideMaterialSideOrientation: Nullable<number>;
  76555. /**
  76556. * Gets the source mesh (the one used to clone this one from)
  76557. */
  76558. readonly source: Nullable<Mesh>;
  76559. /**
  76560. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76561. */
  76562. isUnIndexed: boolean;
  76563. /**
  76564. * @constructor
  76565. * @param name The value used by scene.getMeshByName() to do a lookup.
  76566. * @param scene The scene to add this mesh to.
  76567. * @param parent The parent of this mesh, if it has one
  76568. * @param source An optional Mesh from which geometry is shared, cloned.
  76569. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76570. * When false, achieved by calling a clone(), also passing False.
  76571. * This will make creation of children, recursive.
  76572. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76573. */
  76574. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76575. /**
  76576. * Gets the class name
  76577. * @returns the string "Mesh".
  76578. */
  76579. getClassName(): string;
  76580. /** @hidden */
  76581. readonly _isMesh: boolean;
  76582. /**
  76583. * Returns a description of this mesh
  76584. * @param fullDetails define if full details about this mesh must be used
  76585. * @returns a descriptive string representing this mesh
  76586. */
  76587. toString(fullDetails?: boolean): string;
  76588. /** @hidden */
  76589. _unBindEffect(): void;
  76590. /**
  76591. * Gets a boolean indicating if this mesh has LOD
  76592. */
  76593. readonly hasLODLevels: boolean;
  76594. /**
  76595. * Gets the list of MeshLODLevel associated with the current mesh
  76596. * @returns an array of MeshLODLevel
  76597. */
  76598. getLODLevels(): MeshLODLevel[];
  76599. private _sortLODLevels;
  76600. /**
  76601. * Add a mesh as LOD level triggered at the given distance.
  76602. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76603. * @param distance The distance from the center of the object to show this level
  76604. * @param mesh The mesh to be added as LOD level (can be null)
  76605. * @return This mesh (for chaining)
  76606. */
  76607. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76608. /**
  76609. * Returns the LOD level mesh at the passed distance or null if not found.
  76610. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76611. * @param distance The distance from the center of the object to show this level
  76612. * @returns a Mesh or `null`
  76613. */
  76614. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76615. /**
  76616. * Remove a mesh from the LOD array
  76617. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76618. * @param mesh defines the mesh to be removed
  76619. * @return This mesh (for chaining)
  76620. */
  76621. removeLODLevel(mesh: Mesh): Mesh;
  76622. /**
  76623. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76624. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76625. * @param camera defines the camera to use to compute distance
  76626. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76627. * @return This mesh (for chaining)
  76628. */
  76629. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76630. /**
  76631. * Gets the mesh internal Geometry object
  76632. */
  76633. readonly geometry: Nullable<Geometry>;
  76634. /**
  76635. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76636. * @returns the total number of vertices
  76637. */
  76638. getTotalVertices(): number;
  76639. /**
  76640. * Returns the content of an associated vertex buffer
  76641. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76642. * - VertexBuffer.PositionKind
  76643. * - VertexBuffer.UVKind
  76644. * - VertexBuffer.UV2Kind
  76645. * - VertexBuffer.UV3Kind
  76646. * - VertexBuffer.UV4Kind
  76647. * - VertexBuffer.UV5Kind
  76648. * - VertexBuffer.UV6Kind
  76649. * - VertexBuffer.ColorKind
  76650. * - VertexBuffer.MatricesIndicesKind
  76651. * - VertexBuffer.MatricesIndicesExtraKind
  76652. * - VertexBuffer.MatricesWeightsKind
  76653. * - VertexBuffer.MatricesWeightsExtraKind
  76654. * @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
  76655. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  76656. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  76657. */
  76658. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  76659. /**
  76660. * Returns the mesh VertexBuffer object from the requested `kind`
  76661. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76662. * - VertexBuffer.PositionKind
  76663. * - VertexBuffer.NormalKind
  76664. * - VertexBuffer.UVKind
  76665. * - VertexBuffer.UV2Kind
  76666. * - VertexBuffer.UV3Kind
  76667. * - VertexBuffer.UV4Kind
  76668. * - VertexBuffer.UV5Kind
  76669. * - VertexBuffer.UV6Kind
  76670. * - VertexBuffer.ColorKind
  76671. * - VertexBuffer.MatricesIndicesKind
  76672. * - VertexBuffer.MatricesIndicesExtraKind
  76673. * - VertexBuffer.MatricesWeightsKind
  76674. * - VertexBuffer.MatricesWeightsExtraKind
  76675. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  76676. */
  76677. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  76678. /**
  76679. * Tests if a specific vertex buffer is associated with this mesh
  76680. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76681. * - VertexBuffer.PositionKind
  76682. * - VertexBuffer.NormalKind
  76683. * - VertexBuffer.UVKind
  76684. * - VertexBuffer.UV2Kind
  76685. * - VertexBuffer.UV3Kind
  76686. * - VertexBuffer.UV4Kind
  76687. * - VertexBuffer.UV5Kind
  76688. * - VertexBuffer.UV6Kind
  76689. * - VertexBuffer.ColorKind
  76690. * - VertexBuffer.MatricesIndicesKind
  76691. * - VertexBuffer.MatricesIndicesExtraKind
  76692. * - VertexBuffer.MatricesWeightsKind
  76693. * - VertexBuffer.MatricesWeightsExtraKind
  76694. * @returns a boolean
  76695. */
  76696. isVerticesDataPresent(kind: string): boolean;
  76697. /**
  76698. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  76699. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76700. * - VertexBuffer.PositionKind
  76701. * - VertexBuffer.UVKind
  76702. * - VertexBuffer.UV2Kind
  76703. * - VertexBuffer.UV3Kind
  76704. * - VertexBuffer.UV4Kind
  76705. * - VertexBuffer.UV5Kind
  76706. * - VertexBuffer.UV6Kind
  76707. * - VertexBuffer.ColorKind
  76708. * - VertexBuffer.MatricesIndicesKind
  76709. * - VertexBuffer.MatricesIndicesExtraKind
  76710. * - VertexBuffer.MatricesWeightsKind
  76711. * - VertexBuffer.MatricesWeightsExtraKind
  76712. * @returns a boolean
  76713. */
  76714. isVertexBufferUpdatable(kind: string): boolean;
  76715. /**
  76716. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  76717. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76718. * - VertexBuffer.PositionKind
  76719. * - VertexBuffer.NormalKind
  76720. * - VertexBuffer.UVKind
  76721. * - VertexBuffer.UV2Kind
  76722. * - VertexBuffer.UV3Kind
  76723. * - VertexBuffer.UV4Kind
  76724. * - VertexBuffer.UV5Kind
  76725. * - VertexBuffer.UV6Kind
  76726. * - VertexBuffer.ColorKind
  76727. * - VertexBuffer.MatricesIndicesKind
  76728. * - VertexBuffer.MatricesIndicesExtraKind
  76729. * - VertexBuffer.MatricesWeightsKind
  76730. * - VertexBuffer.MatricesWeightsExtraKind
  76731. * @returns an array of strings
  76732. */
  76733. getVerticesDataKinds(): string[];
  76734. /**
  76735. * Returns a positive integer : the total number of indices in this mesh geometry.
  76736. * @returns the numner of indices or zero if the mesh has no geometry.
  76737. */
  76738. getTotalIndices(): number;
  76739. /**
  76740. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76741. * @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.
  76742. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  76743. * @returns the indices array or an empty array if the mesh has no geometry
  76744. */
  76745. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  76746. readonly isBlocked: boolean;
  76747. /**
  76748. * Determine if the current mesh is ready to be rendered
  76749. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76750. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  76751. * @returns true if all associated assets are ready (material, textures, shaders)
  76752. */
  76753. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  76754. /**
  76755. * 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.
  76756. */
  76757. readonly areNormalsFrozen: boolean;
  76758. /**
  76759. * 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.
  76760. * @returns the current mesh
  76761. */
  76762. freezeNormals(): Mesh;
  76763. /**
  76764. * 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
  76765. * @returns the current mesh
  76766. */
  76767. unfreezeNormals(): Mesh;
  76768. /**
  76769. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  76770. */
  76771. overridenInstanceCount: number;
  76772. /** @hidden */
  76773. _preActivate(): Mesh;
  76774. /** @hidden */
  76775. _preActivateForIntermediateRendering(renderId: number): Mesh;
  76776. /** @hidden */
  76777. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  76778. /**
  76779. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76780. * This means the mesh underlying bounding box and sphere are recomputed.
  76781. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76782. * @returns the current mesh
  76783. */
  76784. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  76785. /** @hidden */
  76786. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  76787. /**
  76788. * This function will subdivide the mesh into multiple submeshes
  76789. * @param count defines the expected number of submeshes
  76790. */
  76791. subdivide(count: number): void;
  76792. /**
  76793. * Copy a FloatArray into a specific associated vertex buffer
  76794. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76795. * - VertexBuffer.PositionKind
  76796. * - VertexBuffer.UVKind
  76797. * - VertexBuffer.UV2Kind
  76798. * - VertexBuffer.UV3Kind
  76799. * - VertexBuffer.UV4Kind
  76800. * - VertexBuffer.UV5Kind
  76801. * - VertexBuffer.UV6Kind
  76802. * - VertexBuffer.ColorKind
  76803. * - VertexBuffer.MatricesIndicesKind
  76804. * - VertexBuffer.MatricesIndicesExtraKind
  76805. * - VertexBuffer.MatricesWeightsKind
  76806. * - VertexBuffer.MatricesWeightsExtraKind
  76807. * @param data defines the data source
  76808. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76809. * @param stride defines the data stride size (can be null)
  76810. * @returns the current mesh
  76811. */
  76812. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76813. /**
  76814. * Flags an associated vertex buffer as updatable
  76815. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  76816. * - VertexBuffer.PositionKind
  76817. * - VertexBuffer.UVKind
  76818. * - VertexBuffer.UV2Kind
  76819. * - VertexBuffer.UV3Kind
  76820. * - VertexBuffer.UV4Kind
  76821. * - VertexBuffer.UV5Kind
  76822. * - VertexBuffer.UV6Kind
  76823. * - VertexBuffer.ColorKind
  76824. * - VertexBuffer.MatricesIndicesKind
  76825. * - VertexBuffer.MatricesIndicesExtraKind
  76826. * - VertexBuffer.MatricesWeightsKind
  76827. * - VertexBuffer.MatricesWeightsExtraKind
  76828. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76829. */
  76830. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  76831. /**
  76832. * Sets the mesh global Vertex Buffer
  76833. * @param buffer defines the buffer to use
  76834. * @returns the current mesh
  76835. */
  76836. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  76837. /**
  76838. * Update a specific associated vertex buffer
  76839. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76840. * - VertexBuffer.PositionKind
  76841. * - VertexBuffer.UVKind
  76842. * - VertexBuffer.UV2Kind
  76843. * - VertexBuffer.UV3Kind
  76844. * - VertexBuffer.UV4Kind
  76845. * - VertexBuffer.UV5Kind
  76846. * - VertexBuffer.UV6Kind
  76847. * - VertexBuffer.ColorKind
  76848. * - VertexBuffer.MatricesIndicesKind
  76849. * - VertexBuffer.MatricesIndicesExtraKind
  76850. * - VertexBuffer.MatricesWeightsKind
  76851. * - VertexBuffer.MatricesWeightsExtraKind
  76852. * @param data defines the data source
  76853. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  76854. * @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)
  76855. * @returns the current mesh
  76856. */
  76857. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76858. /**
  76859. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  76860. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  76861. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  76862. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  76863. * @returns the current mesh
  76864. */
  76865. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  76866. /**
  76867. * Creates a un-shared specific occurence of the geometry for the mesh.
  76868. * @returns the current mesh
  76869. */
  76870. makeGeometryUnique(): Mesh;
  76871. /**
  76872. * Set the index buffer of this mesh
  76873. * @param indices defines the source data
  76874. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  76875. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  76876. * @returns the current mesh
  76877. */
  76878. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  76879. /**
  76880. * Update the current index buffer
  76881. * @param indices defines the source data
  76882. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  76883. * @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)
  76884. * @returns the current mesh
  76885. */
  76886. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  76887. /**
  76888. * Invert the geometry to move from a right handed system to a left handed one.
  76889. * @returns the current mesh
  76890. */
  76891. toLeftHanded(): Mesh;
  76892. /** @hidden */
  76893. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  76894. /** @hidden */
  76895. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  76896. /**
  76897. * Registers for this mesh a javascript function called just before the rendering process
  76898. * @param func defines the function to call before rendering this mesh
  76899. * @returns the current mesh
  76900. */
  76901. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76902. /**
  76903. * Disposes a previously registered javascript function called before the rendering
  76904. * @param func defines the function to remove
  76905. * @returns the current mesh
  76906. */
  76907. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76908. /**
  76909. * Registers for this mesh a javascript function called just after the rendering is complete
  76910. * @param func defines the function to call after rendering this mesh
  76911. * @returns the current mesh
  76912. */
  76913. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76914. /**
  76915. * Disposes a previously registered javascript function called after the rendering.
  76916. * @param func defines the function to remove
  76917. * @returns the current mesh
  76918. */
  76919. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76920. /** @hidden */
  76921. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  76922. /** @hidden */
  76923. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  76924. /** @hidden */
  76925. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  76926. /** @hidden */
  76927. _freeze(): void;
  76928. /** @hidden */
  76929. _unFreeze(): void;
  76930. /**
  76931. * 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
  76932. * @param subMesh defines the subMesh to render
  76933. * @param enableAlphaMode defines if alpha mode can be changed
  76934. * @returns the current mesh
  76935. */
  76936. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  76937. private _onBeforeDraw;
  76938. /**
  76939. * Renormalize the mesh and patch it up if there are no weights
  76940. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  76941. * However in the case of zero weights then we set just a single influence to 1.
  76942. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  76943. */
  76944. cleanMatrixWeights(): void;
  76945. private normalizeSkinFourWeights;
  76946. private normalizeSkinWeightsAndExtra;
  76947. /**
  76948. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  76949. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  76950. * the user know there was an issue with importing the mesh
  76951. * @returns a validation object with skinned, valid and report string
  76952. */
  76953. validateSkinning(): {
  76954. skinned: boolean;
  76955. valid: boolean;
  76956. report: string;
  76957. };
  76958. /** @hidden */
  76959. _checkDelayState(): Mesh;
  76960. private _queueLoad;
  76961. /**
  76962. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  76963. * A mesh is in the frustum if its bounding box intersects the frustum
  76964. * @param frustumPlanes defines the frustum to test
  76965. * @returns true if the mesh is in the frustum planes
  76966. */
  76967. isInFrustum(frustumPlanes: Plane[]): boolean;
  76968. /**
  76969. * Sets the mesh material by the material or multiMaterial `id` property
  76970. * @param id is a string identifying the material or the multiMaterial
  76971. * @returns the current mesh
  76972. */
  76973. setMaterialByID(id: string): Mesh;
  76974. /**
  76975. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  76976. * @returns an array of IAnimatable
  76977. */
  76978. getAnimatables(): IAnimatable[];
  76979. /**
  76980. * Modifies the mesh geometry according to the passed transformation matrix.
  76981. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  76982. * The mesh normals are modified using the same transformation.
  76983. * Note that, under the hood, this method sets a new VertexBuffer each call.
  76984. * @param transform defines the transform matrix to use
  76985. * @see http://doc.babylonjs.com/resources/baking_transformations
  76986. * @returns the current mesh
  76987. */
  76988. bakeTransformIntoVertices(transform: Matrix): Mesh;
  76989. /**
  76990. * Modifies the mesh geometry according to its own current World Matrix.
  76991. * The mesh World Matrix is then reset.
  76992. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  76993. * Note that, under the hood, this method sets a new VertexBuffer each call.
  76994. * @see http://doc.babylonjs.com/resources/baking_transformations
  76995. * @returns the current mesh
  76996. */
  76997. bakeCurrentTransformIntoVertices(): Mesh;
  76998. /** @hidden */
  76999. readonly _positions: Nullable<Vector3[]>;
  77000. /** @hidden */
  77001. _resetPointsArrayCache(): Mesh;
  77002. /** @hidden */
  77003. _generatePointsArray(): boolean;
  77004. /**
  77005. * Returns a new Mesh object generated from the current mesh properties.
  77006. * This method must not get confused with createInstance()
  77007. * @param name is a string, the name given to the new mesh
  77008. * @param newParent can be any Node object (default `null`)
  77009. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77010. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77011. * @returns a new mesh
  77012. */
  77013. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77014. /**
  77015. * Releases resources associated with this mesh.
  77016. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77017. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77018. */
  77019. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77020. /**
  77021. * Modifies the mesh geometry according to a displacement map.
  77022. * 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.
  77023. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77024. * @param url is a string, the URL from the image file is to be downloaded.
  77025. * @param minHeight is the lower limit of the displacement.
  77026. * @param maxHeight is the upper limit of the displacement.
  77027. * @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.
  77028. * @param uvOffset is an optional vector2 used to offset UV.
  77029. * @param uvScale is an optional vector2 used to scale UV.
  77030. * @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.
  77031. * @returns the Mesh.
  77032. */
  77033. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77034. /**
  77035. * Modifies the mesh geometry according to a displacementMap buffer.
  77036. * 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.
  77037. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77038. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77039. * @param heightMapWidth is the width of the buffer image.
  77040. * @param heightMapHeight is the height of the buffer image.
  77041. * @param minHeight is the lower limit of the displacement.
  77042. * @param maxHeight is the upper limit of the displacement.
  77043. * @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.
  77044. * @param uvOffset is an optional vector2 used to offset UV.
  77045. * @param uvScale is an optional vector2 used to scale UV.
  77046. * @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.
  77047. * @returns the Mesh.
  77048. */
  77049. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77050. /**
  77051. * Modify the mesh to get a flat shading rendering.
  77052. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77053. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77054. * @returns current mesh
  77055. */
  77056. convertToFlatShadedMesh(): Mesh;
  77057. /**
  77058. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77059. * In other words, more vertices, no more indices and a single bigger VBO.
  77060. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77061. * @returns current mesh
  77062. */
  77063. convertToUnIndexedMesh(): Mesh;
  77064. /**
  77065. * Inverses facet orientations.
  77066. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77067. * @param flipNormals will also inverts the normals
  77068. * @returns current mesh
  77069. */
  77070. flipFaces(flipNormals?: boolean): Mesh;
  77071. /**
  77072. * Increase the number of facets and hence vertices in a mesh
  77073. * Vertex normals are interpolated from existing vertex normals
  77074. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77075. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77076. */
  77077. increaseVertices(numberPerEdge: number): void;
  77078. /**
  77079. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77080. * This will undo any application of covertToFlatShadedMesh
  77081. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77082. */
  77083. forceSharedVertices(): void;
  77084. /** @hidden */
  77085. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77086. /** @hidden */
  77087. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77088. /**
  77089. * Creates a new InstancedMesh object from the mesh model.
  77090. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77091. * @param name defines the name of the new instance
  77092. * @returns a new InstancedMesh
  77093. */
  77094. createInstance(name: string): InstancedMesh;
  77095. /**
  77096. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77097. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77098. * @returns the current mesh
  77099. */
  77100. synchronizeInstances(): Mesh;
  77101. /**
  77102. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77103. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77104. * This should be used together with the simplification to avoid disappearing triangles.
  77105. * @param successCallback an optional success callback to be called after the optimization finished.
  77106. * @returns the current mesh
  77107. */
  77108. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77109. /**
  77110. * Serialize current mesh
  77111. * @param serializationObject defines the object which will receive the serialization data
  77112. */
  77113. serialize(serializationObject: any): void;
  77114. /** @hidden */
  77115. _syncGeometryWithMorphTargetManager(): void;
  77116. /** @hidden */
  77117. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77118. /**
  77119. * Returns a new Mesh object parsed from the source provided.
  77120. * @param parsedMesh is the source
  77121. * @param scene defines the hosting scene
  77122. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77123. * @returns a new Mesh
  77124. */
  77125. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77126. /**
  77127. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77128. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77129. * @param name defines the name of the mesh to create
  77130. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77131. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77132. * @param closePath creates a seam between the first and the last points of each path of the path array
  77133. * @param offset is taken in account only if the `pathArray` is containing a single path
  77134. * @param scene defines the hosting scene
  77135. * @param updatable defines if the mesh must be flagged as updatable
  77136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77137. * @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)
  77138. * @returns a new Mesh
  77139. */
  77140. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77141. /**
  77142. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77143. * @param name defines the name of the mesh to create
  77144. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77145. * @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
  77146. * @param scene defines the hosting scene
  77147. * @param updatable defines if the mesh must be flagged as updatable
  77148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77149. * @returns a new Mesh
  77150. */
  77151. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77152. /**
  77153. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77154. * @param name defines the name of the mesh to create
  77155. * @param size sets the size (float) of each box side (default 1)
  77156. * @param scene defines the hosting scene
  77157. * @param updatable defines if the mesh must be flagged as updatable
  77158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77159. * @returns a new Mesh
  77160. */
  77161. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77162. /**
  77163. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77164. * @param name defines the name of the mesh to create
  77165. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77166. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77167. * @param scene defines the hosting scene
  77168. * @param updatable defines if the mesh must be flagged as updatable
  77169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77170. * @returns a new Mesh
  77171. */
  77172. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77173. /**
  77174. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77175. * @param name defines the name of the mesh to create
  77176. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77177. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77178. * @param scene defines the hosting scene
  77179. * @returns a new Mesh
  77180. */
  77181. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77182. /**
  77183. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77184. * @param name defines the name of the mesh to create
  77185. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77186. * @param diameterTop set the top cap diameter (floats, default 1)
  77187. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77188. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77189. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77190. * @param scene defines the hosting scene
  77191. * @param updatable defines if the mesh must be flagged as updatable
  77192. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77193. * @returns a new Mesh
  77194. */
  77195. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77196. /**
  77197. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77198. * @param name defines the name of the mesh to create
  77199. * @param diameter sets the diameter size (float) of the torus (default 1)
  77200. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77201. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77202. * @param scene defines the hosting scene
  77203. * @param updatable defines if the mesh must be flagged as updatable
  77204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77205. * @returns a new Mesh
  77206. */
  77207. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77208. /**
  77209. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77210. * @param name defines the name of the mesh to create
  77211. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77212. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77213. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77214. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77215. * @param p the number of windings on X axis (positive integers, default 2)
  77216. * @param q the number of windings on Y axis (positive integers, default 3)
  77217. * @param scene defines the hosting scene
  77218. * @param updatable defines if the mesh must be flagged as updatable
  77219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77220. * @returns a new Mesh
  77221. */
  77222. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77223. /**
  77224. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77225. * @param name defines the name of the mesh to create
  77226. * @param points is an array successive Vector3
  77227. * @param scene defines the hosting scene
  77228. * @param updatable defines if the mesh must be flagged as updatable
  77229. * @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).
  77230. * @returns a new Mesh
  77231. */
  77232. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77233. /**
  77234. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77235. * @param name defines the name of the mesh to create
  77236. * @param points is an array successive Vector3
  77237. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77238. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77239. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77240. * @param scene defines the hosting scene
  77241. * @param updatable defines if the mesh must be flagged as updatable
  77242. * @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)
  77243. * @returns a new Mesh
  77244. */
  77245. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77246. /**
  77247. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77248. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77249. * 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.
  77250. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77251. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77252. * Remember you can only change the shape positions, not their number when updating a polygon.
  77253. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77254. * @param name defines the name of the mesh to create
  77255. * @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
  77256. * @param scene defines the hosting scene
  77257. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77258. * @param updatable defines if the mesh must be flagged as updatable
  77259. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77260. * @param earcutInjection can be used to inject your own earcut reference
  77261. * @returns a new Mesh
  77262. */
  77263. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77264. /**
  77265. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77266. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77267. * @param name defines the name of the mesh to create
  77268. * @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
  77269. * @param depth defines the height of extrusion
  77270. * @param scene defines the hosting scene
  77271. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77272. * @param updatable defines if the mesh must be flagged as updatable
  77273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77274. * @param earcutInjection can be used to inject your own earcut reference
  77275. * @returns a new Mesh
  77276. */
  77277. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77278. /**
  77279. * Creates an extruded shape mesh.
  77280. * 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
  77281. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77282. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77283. * @param name defines the name of the mesh to create
  77284. * @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
  77285. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77286. * @param scale is the value to scale the shape
  77287. * @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
  77288. * @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
  77289. * @param scene defines the hosting scene
  77290. * @param updatable defines if the mesh must be flagged as updatable
  77291. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77292. * @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)
  77293. * @returns a new Mesh
  77294. */
  77295. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77296. /**
  77297. * Creates an custom extruded shape mesh.
  77298. * The custom extrusion is a parametric shape.
  77299. * It has no predefined shape. Its final shape will depend on the input parameters.
  77300. * Please consider using the same method from the MeshBuilder class instead
  77301. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77302. * @param name defines the name of the mesh to create
  77303. * @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
  77304. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77305. * @param scaleFunction is a custom Javascript function called on each path point
  77306. * @param rotationFunction is a custom Javascript function called on each path point
  77307. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77308. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77309. * @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
  77310. * @param scene defines the hosting scene
  77311. * @param updatable defines if the mesh must be flagged as updatable
  77312. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77313. * @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)
  77314. * @returns a new Mesh
  77315. */
  77316. 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;
  77317. /**
  77318. * Creates lathe mesh.
  77319. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77320. * Please consider using the same method from the MeshBuilder class instead
  77321. * @param name defines the name of the mesh to create
  77322. * @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
  77323. * @param radius is the radius value of the lathe
  77324. * @param tessellation is the side number of the lathe.
  77325. * @param scene defines the hosting scene
  77326. * @param updatable defines if the mesh must be flagged as updatable
  77327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77328. * @returns a new Mesh
  77329. */
  77330. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77331. /**
  77332. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77333. * @param name defines the name of the mesh to create
  77334. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77335. * @param scene defines the hosting scene
  77336. * @param updatable defines if the mesh must be flagged as updatable
  77337. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77338. * @returns a new Mesh
  77339. */
  77340. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77341. /**
  77342. * Creates a ground mesh.
  77343. * Please consider using the same method from the MeshBuilder class instead
  77344. * @param name defines the name of the mesh to create
  77345. * @param width set the width of the ground
  77346. * @param height set the height of the ground
  77347. * @param subdivisions sets the number of subdivisions per side
  77348. * @param scene defines the hosting scene
  77349. * @param updatable defines if the mesh must be flagged as updatable
  77350. * @returns a new Mesh
  77351. */
  77352. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77353. /**
  77354. * Creates a tiled ground mesh.
  77355. * Please consider using the same method from the MeshBuilder class instead
  77356. * @param name defines the name of the mesh to create
  77357. * @param xmin set the ground minimum X coordinate
  77358. * @param zmin set the ground minimum Y coordinate
  77359. * @param xmax set the ground maximum X coordinate
  77360. * @param zmax set the ground maximum Z coordinate
  77361. * @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
  77362. * @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
  77363. * @param scene defines the hosting scene
  77364. * @param updatable defines if the mesh must be flagged as updatable
  77365. * @returns a new Mesh
  77366. */
  77367. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77368. w: number;
  77369. h: number;
  77370. }, precision: {
  77371. w: number;
  77372. h: number;
  77373. }, scene: Scene, updatable?: boolean): Mesh;
  77374. /**
  77375. * Creates a ground mesh from a height map.
  77376. * Please consider using the same method from the MeshBuilder class instead
  77377. * @see http://doc.babylonjs.com/babylon101/height_map
  77378. * @param name defines the name of the mesh to create
  77379. * @param url sets the URL of the height map image resource
  77380. * @param width set the ground width size
  77381. * @param height set the ground height size
  77382. * @param subdivisions sets the number of subdivision per side
  77383. * @param minHeight is the minimum altitude on the ground
  77384. * @param maxHeight is the maximum altitude on the ground
  77385. * @param scene defines the hosting scene
  77386. * @param updatable defines if the mesh must be flagged as updatable
  77387. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77388. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77389. * @returns a new Mesh
  77390. */
  77391. 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;
  77392. /**
  77393. * Creates a tube mesh.
  77394. * The tube is a parametric shape.
  77395. * It has no predefined shape. Its final shape will depend on the input parameters.
  77396. * Please consider using the same method from the MeshBuilder class instead
  77397. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77398. * @param name defines the name of the mesh to create
  77399. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77400. * @param radius sets the tube radius size
  77401. * @param tessellation is the number of sides on the tubular surface
  77402. * @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
  77403. * @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
  77404. * @param scene defines the hosting scene
  77405. * @param updatable defines if the mesh must be flagged as updatable
  77406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77407. * @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)
  77408. * @returns a new Mesh
  77409. */
  77410. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77411. (i: number, distance: number): number;
  77412. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77413. /**
  77414. * Creates a polyhedron mesh.
  77415. * Please consider using the same method from the MeshBuilder class instead.
  77416. * * 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
  77417. * * The parameter `size` (positive float, default 1) sets the polygon size
  77418. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77419. * * 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`
  77420. * * 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
  77421. * * 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)`)
  77422. * * 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
  77423. * * 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
  77424. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77425. * * If you create a double-sided mesh, you can choose what parts of 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
  77426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77427. * @param name defines the name of the mesh to create
  77428. * @param options defines the options used to create the mesh
  77429. * @param scene defines the hosting scene
  77430. * @returns a new Mesh
  77431. */
  77432. static CreatePolyhedron(name: string, options: {
  77433. type?: number;
  77434. size?: number;
  77435. sizeX?: number;
  77436. sizeY?: number;
  77437. sizeZ?: number;
  77438. custom?: any;
  77439. faceUV?: Vector4[];
  77440. faceColors?: Color4[];
  77441. updatable?: boolean;
  77442. sideOrientation?: number;
  77443. }, scene: Scene): Mesh;
  77444. /**
  77445. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77446. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77447. * * 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`)
  77448. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77449. * * 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
  77450. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77451. * * If you create a double-sided mesh, you can choose what parts of 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
  77452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77453. * @param name defines the name of the mesh
  77454. * @param options defines the options used to create the mesh
  77455. * @param scene defines the hosting scene
  77456. * @returns a new Mesh
  77457. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77458. */
  77459. static CreateIcoSphere(name: string, options: {
  77460. radius?: number;
  77461. flat?: boolean;
  77462. subdivisions?: number;
  77463. sideOrientation?: number;
  77464. updatable?: boolean;
  77465. }, scene: Scene): Mesh;
  77466. /**
  77467. * Creates a decal mesh.
  77468. * Please consider using the same method from the MeshBuilder class instead.
  77469. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77470. * @param name defines the name of the mesh
  77471. * @param sourceMesh defines the mesh receiving the decal
  77472. * @param position sets the position of the decal in world coordinates
  77473. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77474. * @param size sets the decal scaling
  77475. * @param angle sets the angle to rotate the decal
  77476. * @returns a new Mesh
  77477. */
  77478. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77479. /**
  77480. * Prepare internal position array for software CPU skinning
  77481. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77482. */
  77483. setPositionsForCPUSkinning(): Float32Array;
  77484. /**
  77485. * Prepare internal normal array for software CPU skinning
  77486. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77487. */
  77488. setNormalsForCPUSkinning(): Float32Array;
  77489. /**
  77490. * Updates the vertex buffer by applying transformation from the bones
  77491. * @param skeleton defines the skeleton to apply to current mesh
  77492. * @returns the current mesh
  77493. */
  77494. applySkeleton(skeleton: Skeleton): Mesh;
  77495. /**
  77496. * 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
  77497. * @param meshes defines the list of meshes to scan
  77498. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77499. */
  77500. static MinMax(meshes: AbstractMesh[]): {
  77501. min: Vector3;
  77502. max: Vector3;
  77503. };
  77504. /**
  77505. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77506. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77507. * @returns a vector3
  77508. */
  77509. static Center(meshesOrMinMaxVector: {
  77510. min: Vector3;
  77511. max: Vector3;
  77512. } | AbstractMesh[]): Vector3;
  77513. /**
  77514. * Merge the array of meshes into a single mesh for performance reasons.
  77515. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77516. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77517. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77518. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77519. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77520. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77521. * @returns a new mesh
  77522. */
  77523. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77524. /** @hidden */
  77525. addInstance(instance: InstancedMesh): void;
  77526. /** @hidden */
  77527. removeInstance(instance: InstancedMesh): void;
  77528. }
  77529. }
  77530. declare module BABYLON {
  77531. /**
  77532. * Interface used to define Action
  77533. */
  77534. export interface IAction {
  77535. /**
  77536. * Trigger for the action
  77537. */
  77538. trigger: number;
  77539. /** Options of the trigger */
  77540. triggerOptions: any;
  77541. /**
  77542. * Gets the trigger parameters
  77543. * @returns the trigger parameters
  77544. */
  77545. getTriggerParameter(): any;
  77546. /**
  77547. * Internal only - executes current action event
  77548. * @hidden
  77549. */
  77550. _executeCurrent(evt?: ActionEvent): void;
  77551. /**
  77552. * Serialize placeholder for child classes
  77553. * @param parent of child
  77554. * @returns the serialized object
  77555. */
  77556. serialize(parent: any): any;
  77557. /**
  77558. * Internal only
  77559. * @hidden
  77560. */
  77561. _prepare(): void;
  77562. /**
  77563. * Internal only - manager for action
  77564. * @hidden
  77565. */
  77566. _actionManager: AbstractActionManager;
  77567. /**
  77568. * Adds action to chain of actions, may be a DoNothingAction
  77569. * @param action defines the next action to execute
  77570. * @returns The action passed in
  77571. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77572. */
  77573. then(action: IAction): IAction;
  77574. }
  77575. /**
  77576. * The action to be carried out following a trigger
  77577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77578. */
  77579. export class Action implements IAction {
  77580. /** the trigger, with or without parameters, for the action */
  77581. triggerOptions: any;
  77582. /**
  77583. * Trigger for the action
  77584. */
  77585. trigger: number;
  77586. /**
  77587. * Internal only - manager for action
  77588. * @hidden
  77589. */
  77590. _actionManager: ActionManager;
  77591. private _nextActiveAction;
  77592. private _child;
  77593. private _condition?;
  77594. private _triggerParameter;
  77595. /**
  77596. * An event triggered prior to action being executed.
  77597. */
  77598. onBeforeExecuteObservable: Observable<Action>;
  77599. /**
  77600. * Creates a new Action
  77601. * @param triggerOptions the trigger, with or without parameters, for the action
  77602. * @param condition an optional determinant of action
  77603. */
  77604. constructor(
  77605. /** the trigger, with or without parameters, for the action */
  77606. triggerOptions: any, condition?: Condition);
  77607. /**
  77608. * Internal only
  77609. * @hidden
  77610. */
  77611. _prepare(): void;
  77612. /**
  77613. * Gets the trigger parameters
  77614. * @returns the trigger parameters
  77615. */
  77616. getTriggerParameter(): any;
  77617. /**
  77618. * Internal only - executes current action event
  77619. * @hidden
  77620. */
  77621. _executeCurrent(evt?: ActionEvent): void;
  77622. /**
  77623. * Execute placeholder for child classes
  77624. * @param evt optional action event
  77625. */
  77626. execute(evt?: ActionEvent): void;
  77627. /**
  77628. * Skips to next active action
  77629. */
  77630. skipToNextActiveAction(): void;
  77631. /**
  77632. * Adds action to chain of actions, may be a DoNothingAction
  77633. * @param action defines the next action to execute
  77634. * @returns The action passed in
  77635. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77636. */
  77637. then(action: Action): Action;
  77638. /**
  77639. * Internal only
  77640. * @hidden
  77641. */
  77642. _getProperty(propertyPath: string): string;
  77643. /**
  77644. * Internal only
  77645. * @hidden
  77646. */
  77647. _getEffectiveTarget(target: any, propertyPath: string): any;
  77648. /**
  77649. * Serialize placeholder for child classes
  77650. * @param parent of child
  77651. * @returns the serialized object
  77652. */
  77653. serialize(parent: any): any;
  77654. /**
  77655. * Internal only called by serialize
  77656. * @hidden
  77657. */
  77658. protected _serialize(serializedAction: any, parent?: any): any;
  77659. /**
  77660. * Internal only
  77661. * @hidden
  77662. */
  77663. static _SerializeValueAsString: (value: any) => string;
  77664. /**
  77665. * Internal only
  77666. * @hidden
  77667. */
  77668. static _GetTargetProperty: (target: Scene | Node) => {
  77669. name: string;
  77670. targetType: string;
  77671. value: string;
  77672. };
  77673. }
  77674. }
  77675. declare module BABYLON {
  77676. /**
  77677. * A Condition applied to an Action
  77678. */
  77679. export class Condition {
  77680. /**
  77681. * Internal only - manager for action
  77682. * @hidden
  77683. */
  77684. _actionManager: ActionManager;
  77685. /**
  77686. * Internal only
  77687. * @hidden
  77688. */
  77689. _evaluationId: number;
  77690. /**
  77691. * Internal only
  77692. * @hidden
  77693. */
  77694. _currentResult: boolean;
  77695. /**
  77696. * Creates a new Condition
  77697. * @param actionManager the manager of the action the condition is applied to
  77698. */
  77699. constructor(actionManager: ActionManager);
  77700. /**
  77701. * Check if the current condition is valid
  77702. * @returns a boolean
  77703. */
  77704. isValid(): boolean;
  77705. /**
  77706. * Internal only
  77707. * @hidden
  77708. */
  77709. _getProperty(propertyPath: string): string;
  77710. /**
  77711. * Internal only
  77712. * @hidden
  77713. */
  77714. _getEffectiveTarget(target: any, propertyPath: string): any;
  77715. /**
  77716. * Serialize placeholder for child classes
  77717. * @returns the serialized object
  77718. */
  77719. serialize(): any;
  77720. /**
  77721. * Internal only
  77722. * @hidden
  77723. */
  77724. protected _serialize(serializedCondition: any): any;
  77725. }
  77726. /**
  77727. * Defines specific conditional operators as extensions of Condition
  77728. */
  77729. export class ValueCondition extends Condition {
  77730. /** path to specify the property of the target the conditional operator uses */
  77731. propertyPath: string;
  77732. /** the value compared by the conditional operator against the current value of the property */
  77733. value: any;
  77734. /** the conditional operator, default ValueCondition.IsEqual */
  77735. operator: number;
  77736. /**
  77737. * Internal only
  77738. * @hidden
  77739. */
  77740. private static _IsEqual;
  77741. /**
  77742. * Internal only
  77743. * @hidden
  77744. */
  77745. private static _IsDifferent;
  77746. /**
  77747. * Internal only
  77748. * @hidden
  77749. */
  77750. private static _IsGreater;
  77751. /**
  77752. * Internal only
  77753. * @hidden
  77754. */
  77755. private static _IsLesser;
  77756. /**
  77757. * returns the number for IsEqual
  77758. */
  77759. static readonly IsEqual: number;
  77760. /**
  77761. * Returns the number for IsDifferent
  77762. */
  77763. static readonly IsDifferent: number;
  77764. /**
  77765. * Returns the number for IsGreater
  77766. */
  77767. static readonly IsGreater: number;
  77768. /**
  77769. * Returns the number for IsLesser
  77770. */
  77771. static readonly IsLesser: number;
  77772. /**
  77773. * Internal only The action manager for the condition
  77774. * @hidden
  77775. */
  77776. _actionManager: ActionManager;
  77777. /**
  77778. * Internal only
  77779. * @hidden
  77780. */
  77781. private _target;
  77782. /**
  77783. * Internal only
  77784. * @hidden
  77785. */
  77786. private _effectiveTarget;
  77787. /**
  77788. * Internal only
  77789. * @hidden
  77790. */
  77791. private _property;
  77792. /**
  77793. * Creates a new ValueCondition
  77794. * @param actionManager manager for the action the condition applies to
  77795. * @param target for the action
  77796. * @param propertyPath path to specify the property of the target the conditional operator uses
  77797. * @param value the value compared by the conditional operator against the current value of the property
  77798. * @param operator the conditional operator, default ValueCondition.IsEqual
  77799. */
  77800. constructor(actionManager: ActionManager, target: any,
  77801. /** path to specify the property of the target the conditional operator uses */
  77802. propertyPath: string,
  77803. /** the value compared by the conditional operator against the current value of the property */
  77804. value: any,
  77805. /** the conditional operator, default ValueCondition.IsEqual */
  77806. operator?: number);
  77807. /**
  77808. * Compares the given value with the property value for the specified conditional operator
  77809. * @returns the result of the comparison
  77810. */
  77811. isValid(): boolean;
  77812. /**
  77813. * Serialize the ValueCondition into a JSON compatible object
  77814. * @returns serialization object
  77815. */
  77816. serialize(): any;
  77817. /**
  77818. * Gets the name of the conditional operator for the ValueCondition
  77819. * @param operator the conditional operator
  77820. * @returns the name
  77821. */
  77822. static GetOperatorName(operator: number): string;
  77823. }
  77824. /**
  77825. * Defines a predicate condition as an extension of Condition
  77826. */
  77827. export class PredicateCondition extends Condition {
  77828. /** defines the predicate function used to validate the condition */
  77829. predicate: () => boolean;
  77830. /**
  77831. * Internal only - manager for action
  77832. * @hidden
  77833. */
  77834. _actionManager: ActionManager;
  77835. /**
  77836. * Creates a new PredicateCondition
  77837. * @param actionManager manager for the action the condition applies to
  77838. * @param predicate defines the predicate function used to validate the condition
  77839. */
  77840. constructor(actionManager: ActionManager,
  77841. /** defines the predicate function used to validate the condition */
  77842. predicate: () => boolean);
  77843. /**
  77844. * @returns the validity of the predicate condition
  77845. */
  77846. isValid(): boolean;
  77847. }
  77848. /**
  77849. * Defines a state condition as an extension of Condition
  77850. */
  77851. export class StateCondition extends Condition {
  77852. /** Value to compare with target state */
  77853. value: string;
  77854. /**
  77855. * Internal only - manager for action
  77856. * @hidden
  77857. */
  77858. _actionManager: ActionManager;
  77859. /**
  77860. * Internal only
  77861. * @hidden
  77862. */
  77863. private _target;
  77864. /**
  77865. * Creates a new StateCondition
  77866. * @param actionManager manager for the action the condition applies to
  77867. * @param target of the condition
  77868. * @param value to compare with target state
  77869. */
  77870. constructor(actionManager: ActionManager, target: any,
  77871. /** Value to compare with target state */
  77872. value: string);
  77873. /**
  77874. * Gets a boolean indicating if the current condition is met
  77875. * @returns the validity of the state
  77876. */
  77877. isValid(): boolean;
  77878. /**
  77879. * Serialize the StateCondition into a JSON compatible object
  77880. * @returns serialization object
  77881. */
  77882. serialize(): any;
  77883. }
  77884. }
  77885. declare module BABYLON {
  77886. /**
  77887. * This defines an action responsible to toggle a boolean once triggered.
  77888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77889. */
  77890. export class SwitchBooleanAction extends Action {
  77891. /**
  77892. * The path to the boolean property in the target object
  77893. */
  77894. propertyPath: string;
  77895. private _target;
  77896. private _effectiveTarget;
  77897. private _property;
  77898. /**
  77899. * Instantiate the action
  77900. * @param triggerOptions defines the trigger options
  77901. * @param target defines the object containing the boolean
  77902. * @param propertyPath defines the path to the boolean property in the target object
  77903. * @param condition defines the trigger related conditions
  77904. */
  77905. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77906. /** @hidden */
  77907. _prepare(): void;
  77908. /**
  77909. * Execute the action toggle the boolean value.
  77910. */
  77911. execute(): void;
  77912. /**
  77913. * Serializes the actions and its related information.
  77914. * @param parent defines the object to serialize in
  77915. * @returns the serialized object
  77916. */
  77917. serialize(parent: any): any;
  77918. }
  77919. /**
  77920. * This defines an action responsible to set a the state field of the target
  77921. * to a desired value once triggered.
  77922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77923. */
  77924. export class SetStateAction extends Action {
  77925. /**
  77926. * The value to store in the state field.
  77927. */
  77928. value: string;
  77929. private _target;
  77930. /**
  77931. * Instantiate the action
  77932. * @param triggerOptions defines the trigger options
  77933. * @param target defines the object containing the state property
  77934. * @param value defines the value to store in the state field
  77935. * @param condition defines the trigger related conditions
  77936. */
  77937. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77938. /**
  77939. * Execute the action and store the value on the target state property.
  77940. */
  77941. execute(): void;
  77942. /**
  77943. * Serializes the actions and its related information.
  77944. * @param parent defines the object to serialize in
  77945. * @returns the serialized object
  77946. */
  77947. serialize(parent: any): any;
  77948. }
  77949. /**
  77950. * This defines an action responsible to set a property of the target
  77951. * to a desired value once triggered.
  77952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77953. */
  77954. export class SetValueAction extends Action {
  77955. /**
  77956. * The path of the property to set in the target.
  77957. */
  77958. propertyPath: string;
  77959. /**
  77960. * The value to set in the property
  77961. */
  77962. value: any;
  77963. private _target;
  77964. private _effectiveTarget;
  77965. private _property;
  77966. /**
  77967. * Instantiate the action
  77968. * @param triggerOptions defines the trigger options
  77969. * @param target defines the object containing the property
  77970. * @param propertyPath defines the path of the property to set in the target
  77971. * @param value defines the value to set in the property
  77972. * @param condition defines the trigger related conditions
  77973. */
  77974. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77975. /** @hidden */
  77976. _prepare(): void;
  77977. /**
  77978. * Execute the action and set the targetted property to the desired value.
  77979. */
  77980. execute(): void;
  77981. /**
  77982. * Serializes the actions and its related information.
  77983. * @param parent defines the object to serialize in
  77984. * @returns the serialized object
  77985. */
  77986. serialize(parent: any): any;
  77987. }
  77988. /**
  77989. * This defines an action responsible to increment the target value
  77990. * to a desired value once triggered.
  77991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77992. */
  77993. export class IncrementValueAction extends Action {
  77994. /**
  77995. * The path of the property to increment in the target.
  77996. */
  77997. propertyPath: string;
  77998. /**
  77999. * The value we should increment the property by.
  78000. */
  78001. value: any;
  78002. private _target;
  78003. private _effectiveTarget;
  78004. private _property;
  78005. /**
  78006. * Instantiate the action
  78007. * @param triggerOptions defines the trigger options
  78008. * @param target defines the object containing the property
  78009. * @param propertyPath defines the path of the property to increment in the target
  78010. * @param value defines the value value we should increment the property by
  78011. * @param condition defines the trigger related conditions
  78012. */
  78013. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78014. /** @hidden */
  78015. _prepare(): void;
  78016. /**
  78017. * Execute the action and increment the target of the value amount.
  78018. */
  78019. execute(): void;
  78020. /**
  78021. * Serializes the actions and its related information.
  78022. * @param parent defines the object to serialize in
  78023. * @returns the serialized object
  78024. */
  78025. serialize(parent: any): any;
  78026. }
  78027. /**
  78028. * This defines an action responsible to start an animation once triggered.
  78029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78030. */
  78031. export class PlayAnimationAction extends Action {
  78032. /**
  78033. * Where the animation should start (animation frame)
  78034. */
  78035. from: number;
  78036. /**
  78037. * Where the animation should stop (animation frame)
  78038. */
  78039. to: number;
  78040. /**
  78041. * Define if the animation should loop or stop after the first play.
  78042. */
  78043. loop?: boolean;
  78044. private _target;
  78045. /**
  78046. * Instantiate the action
  78047. * @param triggerOptions defines the trigger options
  78048. * @param target defines the target animation or animation name
  78049. * @param from defines from where the animation should start (animation frame)
  78050. * @param end defines where the animation should stop (animation frame)
  78051. * @param loop defines if the animation should loop or stop after the first play
  78052. * @param condition defines the trigger related conditions
  78053. */
  78054. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78055. /** @hidden */
  78056. _prepare(): void;
  78057. /**
  78058. * Execute the action and play the animation.
  78059. */
  78060. execute(): void;
  78061. /**
  78062. * Serializes the actions and its related information.
  78063. * @param parent defines the object to serialize in
  78064. * @returns the serialized object
  78065. */
  78066. serialize(parent: any): any;
  78067. }
  78068. /**
  78069. * This defines an action responsible to stop an animation once triggered.
  78070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78071. */
  78072. export class StopAnimationAction extends Action {
  78073. private _target;
  78074. /**
  78075. * Instantiate the action
  78076. * @param triggerOptions defines the trigger options
  78077. * @param target defines the target animation or animation name
  78078. * @param condition defines the trigger related conditions
  78079. */
  78080. constructor(triggerOptions: any, target: any, condition?: Condition);
  78081. /** @hidden */
  78082. _prepare(): void;
  78083. /**
  78084. * Execute the action and stop the animation.
  78085. */
  78086. execute(): void;
  78087. /**
  78088. * Serializes the actions and its related information.
  78089. * @param parent defines the object to serialize in
  78090. * @returns the serialized object
  78091. */
  78092. serialize(parent: any): any;
  78093. }
  78094. /**
  78095. * This defines an action responsible that does nothing once triggered.
  78096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78097. */
  78098. export class DoNothingAction extends Action {
  78099. /**
  78100. * Instantiate the action
  78101. * @param triggerOptions defines the trigger options
  78102. * @param condition defines the trigger related conditions
  78103. */
  78104. constructor(triggerOptions?: any, condition?: Condition);
  78105. /**
  78106. * Execute the action and do nothing.
  78107. */
  78108. execute(): void;
  78109. /**
  78110. * Serializes the actions and its related information.
  78111. * @param parent defines the object to serialize in
  78112. * @returns the serialized object
  78113. */
  78114. serialize(parent: any): any;
  78115. }
  78116. /**
  78117. * This defines an action responsible to trigger several actions once triggered.
  78118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78119. */
  78120. export class CombineAction extends Action {
  78121. /**
  78122. * The list of aggregated animations to run.
  78123. */
  78124. children: Action[];
  78125. /**
  78126. * Instantiate the action
  78127. * @param triggerOptions defines the trigger options
  78128. * @param children defines the list of aggregated animations to run
  78129. * @param condition defines the trigger related conditions
  78130. */
  78131. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78132. /** @hidden */
  78133. _prepare(): void;
  78134. /**
  78135. * Execute the action and executes all the aggregated actions.
  78136. */
  78137. execute(evt: ActionEvent): void;
  78138. /**
  78139. * Serializes the actions and its related information.
  78140. * @param parent defines the object to serialize in
  78141. * @returns the serialized object
  78142. */
  78143. serialize(parent: any): any;
  78144. }
  78145. /**
  78146. * This defines an action responsible to run code (external event) once triggered.
  78147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78148. */
  78149. export class ExecuteCodeAction extends Action {
  78150. /**
  78151. * The callback function to run.
  78152. */
  78153. func: (evt: ActionEvent) => void;
  78154. /**
  78155. * Instantiate the action
  78156. * @param triggerOptions defines the trigger options
  78157. * @param func defines the callback function to run
  78158. * @param condition defines the trigger related conditions
  78159. */
  78160. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78161. /**
  78162. * Execute the action and run the attached code.
  78163. */
  78164. execute(evt: ActionEvent): void;
  78165. }
  78166. /**
  78167. * This defines an action responsible to set the parent property of the target once triggered.
  78168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78169. */
  78170. export class SetParentAction extends Action {
  78171. private _parent;
  78172. private _target;
  78173. /**
  78174. * Instantiate the action
  78175. * @param triggerOptions defines the trigger options
  78176. * @param target defines the target containing the parent property
  78177. * @param parent defines from where the animation should start (animation frame)
  78178. * @param condition defines the trigger related conditions
  78179. */
  78180. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78181. /** @hidden */
  78182. _prepare(): void;
  78183. /**
  78184. * Execute the action and set the parent property.
  78185. */
  78186. execute(): void;
  78187. /**
  78188. * Serializes the actions and its related information.
  78189. * @param parent defines the object to serialize in
  78190. * @returns the serialized object
  78191. */
  78192. serialize(parent: any): any;
  78193. }
  78194. }
  78195. declare module BABYLON {
  78196. /**
  78197. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78198. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78200. */
  78201. export class ActionManager extends AbstractActionManager {
  78202. /**
  78203. * Nothing
  78204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78205. */
  78206. static readonly NothingTrigger: number;
  78207. /**
  78208. * On pick
  78209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78210. */
  78211. static readonly OnPickTrigger: number;
  78212. /**
  78213. * On left pick
  78214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78215. */
  78216. static readonly OnLeftPickTrigger: number;
  78217. /**
  78218. * On right pick
  78219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78220. */
  78221. static readonly OnRightPickTrigger: number;
  78222. /**
  78223. * On center pick
  78224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78225. */
  78226. static readonly OnCenterPickTrigger: number;
  78227. /**
  78228. * On pick down
  78229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78230. */
  78231. static readonly OnPickDownTrigger: number;
  78232. /**
  78233. * On double pick
  78234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78235. */
  78236. static readonly OnDoublePickTrigger: number;
  78237. /**
  78238. * On pick up
  78239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78240. */
  78241. static readonly OnPickUpTrigger: number;
  78242. /**
  78243. * On pick out.
  78244. * This trigger will only be raised if you also declared a OnPickDown
  78245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78246. */
  78247. static readonly OnPickOutTrigger: number;
  78248. /**
  78249. * On long press
  78250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78251. */
  78252. static readonly OnLongPressTrigger: number;
  78253. /**
  78254. * On pointer over
  78255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78256. */
  78257. static readonly OnPointerOverTrigger: number;
  78258. /**
  78259. * On pointer out
  78260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78261. */
  78262. static readonly OnPointerOutTrigger: number;
  78263. /**
  78264. * On every frame
  78265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78266. */
  78267. static readonly OnEveryFrameTrigger: number;
  78268. /**
  78269. * On intersection enter
  78270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78271. */
  78272. static readonly OnIntersectionEnterTrigger: number;
  78273. /**
  78274. * On intersection exit
  78275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78276. */
  78277. static readonly OnIntersectionExitTrigger: number;
  78278. /**
  78279. * On key down
  78280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78281. */
  78282. static readonly OnKeyDownTrigger: number;
  78283. /**
  78284. * On key up
  78285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78286. */
  78287. static readonly OnKeyUpTrigger: number;
  78288. private _scene;
  78289. /**
  78290. * Creates a new action manager
  78291. * @param scene defines the hosting scene
  78292. */
  78293. constructor(scene: Scene);
  78294. /**
  78295. * Releases all associated resources
  78296. */
  78297. dispose(): void;
  78298. /**
  78299. * Gets hosting scene
  78300. * @returns the hosting scene
  78301. */
  78302. getScene(): Scene;
  78303. /**
  78304. * Does this action manager handles actions of any of the given triggers
  78305. * @param triggers defines the triggers to be tested
  78306. * @return a boolean indicating whether one (or more) of the triggers is handled
  78307. */
  78308. hasSpecificTriggers(triggers: number[]): boolean;
  78309. /**
  78310. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78311. * speed.
  78312. * @param triggerA defines the trigger to be tested
  78313. * @param triggerB defines the trigger to be tested
  78314. * @return a boolean indicating whether one (or more) of the triggers is handled
  78315. */
  78316. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78317. /**
  78318. * Does this action manager handles actions of a given trigger
  78319. * @param trigger defines the trigger to be tested
  78320. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78321. * @return whether the trigger is handled
  78322. */
  78323. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78324. /**
  78325. * Does this action manager has pointer triggers
  78326. */
  78327. readonly hasPointerTriggers: boolean;
  78328. /**
  78329. * Does this action manager has pick triggers
  78330. */
  78331. readonly hasPickTriggers: boolean;
  78332. /**
  78333. * Registers an action to this action manager
  78334. * @param action defines the action to be registered
  78335. * @return the action amended (prepared) after registration
  78336. */
  78337. registerAction(action: IAction): Nullable<IAction>;
  78338. /**
  78339. * Unregisters an action to this action manager
  78340. * @param action defines the action to be unregistered
  78341. * @return a boolean indicating whether the action has been unregistered
  78342. */
  78343. unregisterAction(action: IAction): Boolean;
  78344. /**
  78345. * Process a specific trigger
  78346. * @param trigger defines the trigger to process
  78347. * @param evt defines the event details to be processed
  78348. */
  78349. processTrigger(trigger: number, evt?: IActionEvent): void;
  78350. /** @hidden */
  78351. _getEffectiveTarget(target: any, propertyPath: string): any;
  78352. /** @hidden */
  78353. _getProperty(propertyPath: string): string;
  78354. /**
  78355. * Serialize this manager to a JSON object
  78356. * @param name defines the property name to store this manager
  78357. * @returns a JSON representation of this manager
  78358. */
  78359. serialize(name: string): any;
  78360. /**
  78361. * Creates a new ActionManager from a JSON data
  78362. * @param parsedActions defines the JSON data to read from
  78363. * @param object defines the hosting mesh
  78364. * @param scene defines the hosting scene
  78365. */
  78366. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78367. /**
  78368. * Get a trigger name by index
  78369. * @param trigger defines the trigger index
  78370. * @returns a trigger name
  78371. */
  78372. static GetTriggerName(trigger: number): string;
  78373. }
  78374. }
  78375. declare module BABYLON {
  78376. /**
  78377. * Class representing a ray with position and direction
  78378. */
  78379. export class Ray {
  78380. /** origin point */
  78381. origin: Vector3;
  78382. /** direction */
  78383. direction: Vector3;
  78384. /** length of the ray */
  78385. length: number;
  78386. private static readonly TmpVector3;
  78387. private _tmpRay;
  78388. /**
  78389. * Creates a new ray
  78390. * @param origin origin point
  78391. * @param direction direction
  78392. * @param length length of the ray
  78393. */
  78394. constructor(
  78395. /** origin point */
  78396. origin: Vector3,
  78397. /** direction */
  78398. direction: Vector3,
  78399. /** length of the ray */
  78400. length?: number);
  78401. /**
  78402. * Checks if the ray intersects a box
  78403. * @param minimum bound of the box
  78404. * @param maximum bound of the box
  78405. * @param intersectionTreshold extra extend to be added to the box in all direction
  78406. * @returns if the box was hit
  78407. */
  78408. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78409. /**
  78410. * Checks if the ray intersects a box
  78411. * @param box the bounding box to check
  78412. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78413. * @returns if the box was hit
  78414. */
  78415. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78416. /**
  78417. * If the ray hits a sphere
  78418. * @param sphere the bounding sphere to check
  78419. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78420. * @returns true if it hits the sphere
  78421. */
  78422. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78423. /**
  78424. * If the ray hits a triange
  78425. * @param vertex0 triangle vertex
  78426. * @param vertex1 triangle vertex
  78427. * @param vertex2 triangle vertex
  78428. * @returns intersection information if hit
  78429. */
  78430. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78431. /**
  78432. * Checks if ray intersects a plane
  78433. * @param plane the plane to check
  78434. * @returns the distance away it was hit
  78435. */
  78436. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78437. /**
  78438. * Checks if ray intersects a mesh
  78439. * @param mesh the mesh to check
  78440. * @param fastCheck if only the bounding box should checked
  78441. * @returns picking info of the intersecton
  78442. */
  78443. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78444. /**
  78445. * Checks if ray intersects a mesh
  78446. * @param meshes the meshes to check
  78447. * @param fastCheck if only the bounding box should checked
  78448. * @param results array to store result in
  78449. * @returns Array of picking infos
  78450. */
  78451. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78452. private _comparePickingInfo;
  78453. private static smallnum;
  78454. private static rayl;
  78455. /**
  78456. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78457. * @param sega the first point of the segment to test the intersection against
  78458. * @param segb the second point of the segment to test the intersection against
  78459. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78460. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78461. */
  78462. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78463. /**
  78464. * Update the ray from viewport position
  78465. * @param x position
  78466. * @param y y position
  78467. * @param viewportWidth viewport width
  78468. * @param viewportHeight viewport height
  78469. * @param world world matrix
  78470. * @param view view matrix
  78471. * @param projection projection matrix
  78472. * @returns this ray updated
  78473. */
  78474. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78475. /**
  78476. * Creates a ray with origin and direction of 0,0,0
  78477. * @returns the new ray
  78478. */
  78479. static Zero(): Ray;
  78480. /**
  78481. * Creates a new ray from screen space and viewport
  78482. * @param x position
  78483. * @param y y position
  78484. * @param viewportWidth viewport width
  78485. * @param viewportHeight viewport height
  78486. * @param world world matrix
  78487. * @param view view matrix
  78488. * @param projection projection matrix
  78489. * @returns new ray
  78490. */
  78491. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78492. /**
  78493. * 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
  78494. * transformed to the given world matrix.
  78495. * @param origin The origin point
  78496. * @param end The end point
  78497. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78498. * @returns the new ray
  78499. */
  78500. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78501. /**
  78502. * Transforms a ray by a matrix
  78503. * @param ray ray to transform
  78504. * @param matrix matrix to apply
  78505. * @returns the resulting new ray
  78506. */
  78507. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78508. /**
  78509. * Transforms a ray by a matrix
  78510. * @param ray ray to transform
  78511. * @param matrix matrix to apply
  78512. * @param result ray to store result in
  78513. */
  78514. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78515. /**
  78516. * Unproject a ray from screen space to object space
  78517. * @param sourceX defines the screen space x coordinate to use
  78518. * @param sourceY defines the screen space y coordinate to use
  78519. * @param viewportWidth defines the current width of the viewport
  78520. * @param viewportHeight defines the current height of the viewport
  78521. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78522. * @param view defines the view matrix to use
  78523. * @param projection defines the projection matrix to use
  78524. */
  78525. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78526. }
  78527. /**
  78528. * Type used to define predicate used to select faces when a mesh intersection is detected
  78529. */
  78530. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78531. interface Scene {
  78532. /** @hidden */
  78533. _tempPickingRay: Nullable<Ray>;
  78534. /** @hidden */
  78535. _cachedRayForTransform: Ray;
  78536. /** @hidden */
  78537. _pickWithRayInverseMatrix: Matrix;
  78538. /** @hidden */
  78539. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78540. /** @hidden */
  78541. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78542. }
  78543. }
  78544. declare module BABYLON {
  78545. interface Scene {
  78546. /** @hidden */
  78547. _pointerOverSprite: Nullable<Sprite>;
  78548. /** @hidden */
  78549. _pickedDownSprite: Nullable<Sprite>;
  78550. /** @hidden */
  78551. _tempSpritePickingRay: Nullable<Ray>;
  78552. /**
  78553. * All of the sprite managers added to this scene
  78554. * @see http://doc.babylonjs.com/babylon101/sprites
  78555. */
  78556. spriteManagers: Array<ISpriteManager>;
  78557. /**
  78558. * An event triggered when sprites rendering is about to start
  78559. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78560. */
  78561. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78562. /**
  78563. * An event triggered when sprites rendering is done
  78564. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78565. */
  78566. onAfterSpritesRenderingObservable: Observable<Scene>;
  78567. /** @hidden */
  78568. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78569. /** Launch a ray to try to pick a sprite in the scene
  78570. * @param x position on screen
  78571. * @param y position on screen
  78572. * @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
  78573. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78574. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78575. * @returns a PickingInfo
  78576. */
  78577. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78578. /** Use the given ray to pick a sprite in the scene
  78579. * @param ray The ray (in world space) to use to pick meshes
  78580. * @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
  78581. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78582. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78583. * @returns a PickingInfo
  78584. */
  78585. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78586. /**
  78587. * Force the sprite under the pointer
  78588. * @param sprite defines the sprite to use
  78589. */
  78590. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78591. /**
  78592. * Gets the sprite under the pointer
  78593. * @returns a Sprite or null if no sprite is under the pointer
  78594. */
  78595. getPointerOverSprite(): Nullable<Sprite>;
  78596. }
  78597. /**
  78598. * Defines the sprite scene component responsible to manage sprites
  78599. * in a given scene.
  78600. */
  78601. export class SpriteSceneComponent implements ISceneComponent {
  78602. /**
  78603. * The component name helpfull to identify the component in the list of scene components.
  78604. */
  78605. readonly name: string;
  78606. /**
  78607. * The scene the component belongs to.
  78608. */
  78609. scene: Scene;
  78610. /** @hidden */
  78611. private _spritePredicate;
  78612. /**
  78613. * Creates a new instance of the component for the given scene
  78614. * @param scene Defines the scene to register the component in
  78615. */
  78616. constructor(scene: Scene);
  78617. /**
  78618. * Registers the component in a given scene
  78619. */
  78620. register(): void;
  78621. /**
  78622. * Rebuilds the elements related to this component in case of
  78623. * context lost for instance.
  78624. */
  78625. rebuild(): void;
  78626. /**
  78627. * Disposes the component and the associated ressources.
  78628. */
  78629. dispose(): void;
  78630. private _pickSpriteButKeepRay;
  78631. private _pointerMove;
  78632. private _pointerDown;
  78633. private _pointerUp;
  78634. }
  78635. }
  78636. declare module BABYLON {
  78637. /** @hidden */
  78638. export var fogFragmentDeclaration: {
  78639. name: string;
  78640. shader: string;
  78641. };
  78642. }
  78643. declare module BABYLON {
  78644. /** @hidden */
  78645. export var fogFragment: {
  78646. name: string;
  78647. shader: string;
  78648. };
  78649. }
  78650. declare module BABYLON {
  78651. /** @hidden */
  78652. export var spritesPixelShader: {
  78653. name: string;
  78654. shader: string;
  78655. };
  78656. }
  78657. declare module BABYLON {
  78658. /** @hidden */
  78659. export var fogVertexDeclaration: {
  78660. name: string;
  78661. shader: string;
  78662. };
  78663. }
  78664. declare module BABYLON {
  78665. /** @hidden */
  78666. export var spritesVertexShader: {
  78667. name: string;
  78668. shader: string;
  78669. };
  78670. }
  78671. declare module BABYLON {
  78672. /**
  78673. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78674. */
  78675. export interface ISpriteManager extends IDisposable {
  78676. /**
  78677. * Restricts the camera to viewing objects with the same layerMask.
  78678. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78679. */
  78680. layerMask: number;
  78681. /**
  78682. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78683. */
  78684. isPickable: boolean;
  78685. /**
  78686. * Specifies the rendering group id for this mesh (0 by default)
  78687. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78688. */
  78689. renderingGroupId: number;
  78690. /**
  78691. * Defines the list of sprites managed by the manager.
  78692. */
  78693. sprites: Array<Sprite>;
  78694. /**
  78695. * Tests the intersection of a sprite with a specific ray.
  78696. * @param ray The ray we are sending to test the collision
  78697. * @param camera The camera space we are sending rays in
  78698. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78699. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78700. * @returns picking info or null.
  78701. */
  78702. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78703. /**
  78704. * Renders the list of sprites on screen.
  78705. */
  78706. render(): void;
  78707. }
  78708. /**
  78709. * Class used to manage multiple sprites on the same spritesheet
  78710. * @see http://doc.babylonjs.com/babylon101/sprites
  78711. */
  78712. export class SpriteManager implements ISpriteManager {
  78713. /** defines the manager's name */
  78714. name: string;
  78715. /** Gets the list of sprites */
  78716. sprites: Sprite[];
  78717. /** Gets or sets the rendering group id (0 by default) */
  78718. renderingGroupId: number;
  78719. /** Gets or sets camera layer mask */
  78720. layerMask: number;
  78721. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78722. fogEnabled: boolean;
  78723. /** Gets or sets a boolean indicating if the sprites are pickable */
  78724. isPickable: boolean;
  78725. /** Defines the default width of a cell in the spritesheet */
  78726. cellWidth: number;
  78727. /** Defines the default height of a cell in the spritesheet */
  78728. cellHeight: number;
  78729. /**
  78730. * An event triggered when the manager is disposed.
  78731. */
  78732. onDisposeObservable: Observable<SpriteManager>;
  78733. private _onDisposeObserver;
  78734. /**
  78735. * Callback called when the manager is disposed
  78736. */
  78737. onDispose: () => void;
  78738. private _capacity;
  78739. private _spriteTexture;
  78740. private _epsilon;
  78741. private _scene;
  78742. private _vertexData;
  78743. private _buffer;
  78744. private _vertexBuffers;
  78745. private _indexBuffer;
  78746. private _effectBase;
  78747. private _effectFog;
  78748. /**
  78749. * Gets or sets the spritesheet texture
  78750. */
  78751. texture: Texture;
  78752. /**
  78753. * Creates a new sprite manager
  78754. * @param name defines the manager's name
  78755. * @param imgUrl defines the sprite sheet url
  78756. * @param capacity defines the maximum allowed number of sprites
  78757. * @param cellSize defines the size of a sprite cell
  78758. * @param scene defines the hosting scene
  78759. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78760. * @param samplingMode defines the smapling mode to use with spritesheet
  78761. */
  78762. constructor(
  78763. /** defines the manager's name */
  78764. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  78765. private _appendSpriteVertex;
  78766. /**
  78767. * Intersects the sprites with a ray
  78768. * @param ray defines the ray to intersect with
  78769. * @param camera defines the current active camera
  78770. * @param predicate defines a predicate used to select candidate sprites
  78771. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78772. * @returns null if no hit or a PickingInfo
  78773. */
  78774. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78775. /**
  78776. * Render all child sprites
  78777. */
  78778. render(): void;
  78779. /**
  78780. * Release associated resources
  78781. */
  78782. dispose(): void;
  78783. }
  78784. }
  78785. declare module BABYLON {
  78786. /**
  78787. * Class used to represent a sprite
  78788. * @see http://doc.babylonjs.com/babylon101/sprites
  78789. */
  78790. export class Sprite {
  78791. /** defines the name */
  78792. name: string;
  78793. /** Gets or sets the current world position */
  78794. position: Vector3;
  78795. /** Gets or sets the main color */
  78796. color: Color4;
  78797. /** Gets or sets the width */
  78798. width: number;
  78799. /** Gets or sets the height */
  78800. height: number;
  78801. /** Gets or sets rotation angle */
  78802. angle: number;
  78803. /** Gets or sets the cell index in the sprite sheet */
  78804. cellIndex: number;
  78805. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78806. invertU: number;
  78807. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78808. invertV: number;
  78809. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78810. disposeWhenFinishedAnimating: boolean;
  78811. /** Gets the list of attached animations */
  78812. animations: Animation[];
  78813. /** Gets or sets a boolean indicating if the sprite can be picked */
  78814. isPickable: boolean;
  78815. /**
  78816. * Gets or sets the associated action manager
  78817. */
  78818. actionManager: Nullable<ActionManager>;
  78819. private _animationStarted;
  78820. private _loopAnimation;
  78821. private _fromIndex;
  78822. private _toIndex;
  78823. private _delay;
  78824. private _direction;
  78825. private _manager;
  78826. private _time;
  78827. private _onAnimationEnd;
  78828. /**
  78829. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78830. */
  78831. isVisible: boolean;
  78832. /**
  78833. * Gets or sets the sprite size
  78834. */
  78835. size: number;
  78836. /**
  78837. * Creates a new Sprite
  78838. * @param name defines the name
  78839. * @param manager defines the manager
  78840. */
  78841. constructor(
  78842. /** defines the name */
  78843. name: string, manager: ISpriteManager);
  78844. /**
  78845. * Starts an animation
  78846. * @param from defines the initial key
  78847. * @param to defines the end key
  78848. * @param loop defines if the animation must loop
  78849. * @param delay defines the start delay (in ms)
  78850. * @param onAnimationEnd defines a callback to call when animation ends
  78851. */
  78852. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78853. /** Stops current animation (if any) */
  78854. stopAnimation(): void;
  78855. /** @hidden */
  78856. _animate(deltaTime: number): void;
  78857. /** Release associated resources */
  78858. dispose(): void;
  78859. }
  78860. }
  78861. declare module BABYLON {
  78862. /**
  78863. * Information about the result of picking within a scene
  78864. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78865. */
  78866. export class PickingInfo {
  78867. /** @hidden */
  78868. _pickingUnavailable: boolean;
  78869. /**
  78870. * If the pick collided with an object
  78871. */
  78872. hit: boolean;
  78873. /**
  78874. * Distance away where the pick collided
  78875. */
  78876. distance: number;
  78877. /**
  78878. * The location of pick collision
  78879. */
  78880. pickedPoint: Nullable<Vector3>;
  78881. /**
  78882. * The mesh corresponding the the pick collision
  78883. */
  78884. pickedMesh: Nullable<AbstractMesh>;
  78885. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78886. bu: number;
  78887. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78888. bv: number;
  78889. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78890. faceId: number;
  78891. /** Id of the the submesh that was picked */
  78892. subMeshId: number;
  78893. /** If a sprite was picked, this will be the sprite the pick collided with */
  78894. pickedSprite: Nullable<Sprite>;
  78895. /**
  78896. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78897. */
  78898. originMesh: Nullable<AbstractMesh>;
  78899. /**
  78900. * The ray that was used to perform the picking.
  78901. */
  78902. ray: Nullable<Ray>;
  78903. /**
  78904. * Gets the normal correspodning to the face the pick collided with
  78905. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78906. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78907. * @returns The normal correspodning to the face the pick collided with
  78908. */
  78909. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78910. /**
  78911. * Gets the texture coordinates of where the pick occured
  78912. * @returns the vector containing the coordnates of the texture
  78913. */
  78914. getTextureCoordinates(): Nullable<Vector2>;
  78915. }
  78916. }
  78917. declare module BABYLON {
  78918. /**
  78919. * Gather the list of pointer event types as constants.
  78920. */
  78921. export class PointerEventTypes {
  78922. /**
  78923. * 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.
  78924. */
  78925. static readonly POINTERDOWN: number;
  78926. /**
  78927. * The pointerup event is fired when a pointer is no longer active.
  78928. */
  78929. static readonly POINTERUP: number;
  78930. /**
  78931. * The pointermove event is fired when a pointer changes coordinates.
  78932. */
  78933. static readonly POINTERMOVE: number;
  78934. /**
  78935. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78936. */
  78937. static readonly POINTERWHEEL: number;
  78938. /**
  78939. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78940. */
  78941. static readonly POINTERPICK: number;
  78942. /**
  78943. * The pointertap event is fired when a the object has been touched and released without drag.
  78944. */
  78945. static readonly POINTERTAP: number;
  78946. /**
  78947. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78948. */
  78949. static readonly POINTERDOUBLETAP: number;
  78950. }
  78951. /**
  78952. * Base class of pointer info types.
  78953. */
  78954. export class PointerInfoBase {
  78955. /**
  78956. * Defines the type of event (PointerEventTypes)
  78957. */
  78958. type: number;
  78959. /**
  78960. * Defines the related dom event
  78961. */
  78962. event: PointerEvent | MouseWheelEvent;
  78963. /**
  78964. * Instantiates the base class of pointers info.
  78965. * @param type Defines the type of event (PointerEventTypes)
  78966. * @param event Defines the related dom event
  78967. */
  78968. constructor(
  78969. /**
  78970. * Defines the type of event (PointerEventTypes)
  78971. */
  78972. type: number,
  78973. /**
  78974. * Defines the related dom event
  78975. */
  78976. event: PointerEvent | MouseWheelEvent);
  78977. }
  78978. /**
  78979. * This class is used to store pointer related info for the onPrePointerObservable event.
  78980. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78981. */
  78982. export class PointerInfoPre extends PointerInfoBase {
  78983. /**
  78984. * Ray from a pointer if availible (eg. 6dof controller)
  78985. */
  78986. ray: Nullable<Ray>;
  78987. /**
  78988. * Defines the local position of the pointer on the canvas.
  78989. */
  78990. localPosition: Vector2;
  78991. /**
  78992. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78993. */
  78994. skipOnPointerObservable: boolean;
  78995. /**
  78996. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78997. * @param type Defines the type of event (PointerEventTypes)
  78998. * @param event Defines the related dom event
  78999. * @param localX Defines the local x coordinates of the pointer when the event occured
  79000. * @param localY Defines the local y coordinates of the pointer when the event occured
  79001. */
  79002. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79003. }
  79004. /**
  79005. * This type contains all the data related to a pointer event in Babylon.js.
  79006. * 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.
  79007. */
  79008. export class PointerInfo extends PointerInfoBase {
  79009. /**
  79010. * Defines the picking info associated to the info (if any)\
  79011. */
  79012. pickInfo: Nullable<PickingInfo>;
  79013. /**
  79014. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79015. * @param type Defines the type of event (PointerEventTypes)
  79016. * @param event Defines the related dom event
  79017. * @param pickInfo Defines the picking info associated to the info (if any)\
  79018. */
  79019. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79020. /**
  79021. * Defines the picking info associated to the info (if any)\
  79022. */
  79023. pickInfo: Nullable<PickingInfo>);
  79024. }
  79025. /**
  79026. * Data relating to a touch event on the screen.
  79027. */
  79028. export interface PointerTouch {
  79029. /**
  79030. * X coordinate of touch.
  79031. */
  79032. x: number;
  79033. /**
  79034. * Y coordinate of touch.
  79035. */
  79036. y: number;
  79037. /**
  79038. * Id of touch. Unique for each finger.
  79039. */
  79040. pointerId: number;
  79041. /**
  79042. * Event type passed from DOM.
  79043. */
  79044. type: any;
  79045. }
  79046. }
  79047. declare module BABYLON {
  79048. /**
  79049. * Manage the mouse inputs to control the movement of a free camera.
  79050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79051. */
  79052. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79053. /**
  79054. * Define if touch is enabled in the mouse input
  79055. */
  79056. touchEnabled: boolean;
  79057. /**
  79058. * Defines the camera the input is attached to.
  79059. */
  79060. camera: FreeCamera;
  79061. /**
  79062. * Defines the buttons associated with the input to handle camera move.
  79063. */
  79064. buttons: number[];
  79065. /**
  79066. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79067. */
  79068. angularSensibility: number;
  79069. private _pointerInput;
  79070. private _onMouseMove;
  79071. private _observer;
  79072. private previousPosition;
  79073. /**
  79074. * Observable for when a pointer move event occurs containing the move offset
  79075. */
  79076. onPointerMovedObservable: Observable<{
  79077. offsetX: number;
  79078. offsetY: number;
  79079. }>;
  79080. /**
  79081. * @hidden
  79082. * If the camera should be rotated automatically based on pointer movement
  79083. */
  79084. _allowCameraRotation: boolean;
  79085. /**
  79086. * Manage the mouse inputs to control the movement of a free camera.
  79087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79088. * @param touchEnabled Defines if touch is enabled or not
  79089. */
  79090. constructor(
  79091. /**
  79092. * Define if touch is enabled in the mouse input
  79093. */
  79094. touchEnabled?: boolean);
  79095. /**
  79096. * Attach the input controls to a specific dom element to get the input from.
  79097. * @param element Defines the element the controls should be listened from
  79098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79099. */
  79100. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79101. /**
  79102. * Called on JS contextmenu event.
  79103. * Override this method to provide functionality.
  79104. */
  79105. protected onContextMenu(evt: PointerEvent): void;
  79106. /**
  79107. * Detach the current controls from the specified dom element.
  79108. * @param element Defines the element to stop listening the inputs from
  79109. */
  79110. detachControl(element: Nullable<HTMLElement>): void;
  79111. /**
  79112. * Gets the class name of the current intput.
  79113. * @returns the class name
  79114. */
  79115. getClassName(): string;
  79116. /**
  79117. * Get the friendly name associated with the input class.
  79118. * @returns the input friendly name
  79119. */
  79120. getSimpleName(): string;
  79121. }
  79122. }
  79123. declare module BABYLON {
  79124. /**
  79125. * Manage the touch inputs to control the movement of a free camera.
  79126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79127. */
  79128. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79129. /**
  79130. * Defines the camera the input is attached to.
  79131. */
  79132. camera: FreeCamera;
  79133. /**
  79134. * Defines the touch sensibility for rotation.
  79135. * The higher the faster.
  79136. */
  79137. touchAngularSensibility: number;
  79138. /**
  79139. * Defines the touch sensibility for move.
  79140. * The higher the faster.
  79141. */
  79142. touchMoveSensibility: number;
  79143. private _offsetX;
  79144. private _offsetY;
  79145. private _pointerPressed;
  79146. private _pointerInput;
  79147. private _observer;
  79148. private _onLostFocus;
  79149. /**
  79150. * Attach the input controls to a specific dom element to get the input from.
  79151. * @param element Defines the element the controls should be listened from
  79152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79153. */
  79154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79155. /**
  79156. * Detach the current controls from the specified dom element.
  79157. * @param element Defines the element to stop listening the inputs from
  79158. */
  79159. detachControl(element: Nullable<HTMLElement>): void;
  79160. /**
  79161. * Update the current camera state depending on the inputs that have been used this frame.
  79162. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79163. */
  79164. checkInputs(): void;
  79165. /**
  79166. * Gets the class name of the current intput.
  79167. * @returns the class name
  79168. */
  79169. getClassName(): string;
  79170. /**
  79171. * Get the friendly name associated with the input class.
  79172. * @returns the input friendly name
  79173. */
  79174. getSimpleName(): string;
  79175. }
  79176. }
  79177. declare module BABYLON {
  79178. /**
  79179. * Default Inputs manager for the FreeCamera.
  79180. * It groups all the default supported inputs for ease of use.
  79181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79182. */
  79183. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79184. /**
  79185. * @hidden
  79186. */
  79187. _mouseInput: Nullable<FreeCameraMouseInput>;
  79188. /**
  79189. * Instantiates a new FreeCameraInputsManager.
  79190. * @param camera Defines the camera the inputs belong to
  79191. */
  79192. constructor(camera: FreeCamera);
  79193. /**
  79194. * Add keyboard input support to the input manager.
  79195. * @returns the current input manager
  79196. */
  79197. addKeyboard(): FreeCameraInputsManager;
  79198. /**
  79199. * Add mouse input support to the input manager.
  79200. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79201. * @returns the current input manager
  79202. */
  79203. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79204. /**
  79205. * Removes the mouse input support from the manager
  79206. * @returns the current input manager
  79207. */
  79208. removeMouse(): FreeCameraInputsManager;
  79209. /**
  79210. * Add touch input support to the input manager.
  79211. * @returns the current input manager
  79212. */
  79213. addTouch(): FreeCameraInputsManager;
  79214. /**
  79215. * Remove all attached input methods from a camera
  79216. */
  79217. clear(): void;
  79218. }
  79219. }
  79220. declare module BABYLON {
  79221. /**
  79222. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79223. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79224. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79225. */
  79226. export class FreeCamera extends TargetCamera {
  79227. /**
  79228. * Define the collision ellipsoid of the camera.
  79229. * This is helpful to simulate a camera body like the player body around the camera
  79230. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79231. */
  79232. ellipsoid: Vector3;
  79233. /**
  79234. * Define an offset for the position of the ellipsoid around the camera.
  79235. * This can be helpful to determine the center of the body near the gravity center of the body
  79236. * instead of its head.
  79237. */
  79238. ellipsoidOffset: Vector3;
  79239. /**
  79240. * Enable or disable collisions of the camera with the rest of the scene objects.
  79241. */
  79242. checkCollisions: boolean;
  79243. /**
  79244. * Enable or disable gravity on the camera.
  79245. */
  79246. applyGravity: boolean;
  79247. /**
  79248. * Define the input manager associated to the camera.
  79249. */
  79250. inputs: FreeCameraInputsManager;
  79251. /**
  79252. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79253. * Higher values reduce sensitivity.
  79254. */
  79255. /**
  79256. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79257. * Higher values reduce sensitivity.
  79258. */
  79259. angularSensibility: number;
  79260. /**
  79261. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79262. */
  79263. keysUp: number[];
  79264. /**
  79265. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79266. */
  79267. keysDown: number[];
  79268. /**
  79269. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79270. */
  79271. keysLeft: number[];
  79272. /**
  79273. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79274. */
  79275. keysRight: number[];
  79276. /**
  79277. * Event raised when the camera collide with a mesh in the scene.
  79278. */
  79279. onCollide: (collidedMesh: AbstractMesh) => void;
  79280. private _collider;
  79281. private _needMoveForGravity;
  79282. private _oldPosition;
  79283. private _diffPosition;
  79284. private _newPosition;
  79285. /** @hidden */
  79286. _localDirection: Vector3;
  79287. /** @hidden */
  79288. _transformedDirection: Vector3;
  79289. /**
  79290. * Instantiates a Free Camera.
  79291. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79292. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79293. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79294. * @param name Define the name of the camera in the scene
  79295. * @param position Define the start position of the camera in the scene
  79296. * @param scene Define the scene the camera belongs to
  79297. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79298. */
  79299. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79300. /**
  79301. * Attached controls to the current camera.
  79302. * @param element Defines the element the controls should be listened from
  79303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79304. */
  79305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79306. /**
  79307. * Detach the current controls from the camera.
  79308. * The camera will stop reacting to inputs.
  79309. * @param element Defines the element to stop listening the inputs from
  79310. */
  79311. detachControl(element: HTMLElement): void;
  79312. private _collisionMask;
  79313. /**
  79314. * Define a collision mask to limit the list of object the camera can collide with
  79315. */
  79316. collisionMask: number;
  79317. /** @hidden */
  79318. _collideWithWorld(displacement: Vector3): void;
  79319. private _onCollisionPositionChange;
  79320. /** @hidden */
  79321. _checkInputs(): void;
  79322. /** @hidden */
  79323. _decideIfNeedsToMove(): boolean;
  79324. /** @hidden */
  79325. _updatePosition(): void;
  79326. /**
  79327. * Destroy the camera and release the current resources hold by it.
  79328. */
  79329. dispose(): void;
  79330. /**
  79331. * Gets the current object class name.
  79332. * @return the class name
  79333. */
  79334. getClassName(): string;
  79335. }
  79336. }
  79337. declare module BABYLON {
  79338. /**
  79339. * Represents a gamepad control stick position
  79340. */
  79341. export class StickValues {
  79342. /**
  79343. * The x component of the control stick
  79344. */
  79345. x: number;
  79346. /**
  79347. * The y component of the control stick
  79348. */
  79349. y: number;
  79350. /**
  79351. * Initializes the gamepad x and y control stick values
  79352. * @param x The x component of the gamepad control stick value
  79353. * @param y The y component of the gamepad control stick value
  79354. */
  79355. constructor(
  79356. /**
  79357. * The x component of the control stick
  79358. */
  79359. x: number,
  79360. /**
  79361. * The y component of the control stick
  79362. */
  79363. y: number);
  79364. }
  79365. /**
  79366. * An interface which manages callbacks for gamepad button changes
  79367. */
  79368. export interface GamepadButtonChanges {
  79369. /**
  79370. * Called when a gamepad has been changed
  79371. */
  79372. changed: boolean;
  79373. /**
  79374. * Called when a gamepad press event has been triggered
  79375. */
  79376. pressChanged: boolean;
  79377. /**
  79378. * Called when a touch event has been triggered
  79379. */
  79380. touchChanged: boolean;
  79381. /**
  79382. * Called when a value has changed
  79383. */
  79384. valueChanged: boolean;
  79385. }
  79386. /**
  79387. * Represents a gamepad
  79388. */
  79389. export class Gamepad {
  79390. /**
  79391. * The id of the gamepad
  79392. */
  79393. id: string;
  79394. /**
  79395. * The index of the gamepad
  79396. */
  79397. index: number;
  79398. /**
  79399. * The browser gamepad
  79400. */
  79401. browserGamepad: any;
  79402. /**
  79403. * Specifies what type of gamepad this represents
  79404. */
  79405. type: number;
  79406. private _leftStick;
  79407. private _rightStick;
  79408. /** @hidden */
  79409. _isConnected: boolean;
  79410. private _leftStickAxisX;
  79411. private _leftStickAxisY;
  79412. private _rightStickAxisX;
  79413. private _rightStickAxisY;
  79414. /**
  79415. * Triggered when the left control stick has been changed
  79416. */
  79417. private _onleftstickchanged;
  79418. /**
  79419. * Triggered when the right control stick has been changed
  79420. */
  79421. private _onrightstickchanged;
  79422. /**
  79423. * Represents a gamepad controller
  79424. */
  79425. static GAMEPAD: number;
  79426. /**
  79427. * Represents a generic controller
  79428. */
  79429. static GENERIC: number;
  79430. /**
  79431. * Represents an XBox controller
  79432. */
  79433. static XBOX: number;
  79434. /**
  79435. * Represents a pose-enabled controller
  79436. */
  79437. static POSE_ENABLED: number;
  79438. /**
  79439. * Specifies whether the left control stick should be Y-inverted
  79440. */
  79441. protected _invertLeftStickY: boolean;
  79442. /**
  79443. * Specifies if the gamepad has been connected
  79444. */
  79445. readonly isConnected: boolean;
  79446. /**
  79447. * Initializes the gamepad
  79448. * @param id The id of the gamepad
  79449. * @param index The index of the gamepad
  79450. * @param browserGamepad The browser gamepad
  79451. * @param leftStickX The x component of the left joystick
  79452. * @param leftStickY The y component of the left joystick
  79453. * @param rightStickX The x component of the right joystick
  79454. * @param rightStickY The y component of the right joystick
  79455. */
  79456. constructor(
  79457. /**
  79458. * The id of the gamepad
  79459. */
  79460. id: string,
  79461. /**
  79462. * The index of the gamepad
  79463. */
  79464. index: number,
  79465. /**
  79466. * The browser gamepad
  79467. */
  79468. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79469. /**
  79470. * Callback triggered when the left joystick has changed
  79471. * @param callback
  79472. */
  79473. onleftstickchanged(callback: (values: StickValues) => void): void;
  79474. /**
  79475. * Callback triggered when the right joystick has changed
  79476. * @param callback
  79477. */
  79478. onrightstickchanged(callback: (values: StickValues) => void): void;
  79479. /**
  79480. * Gets the left joystick
  79481. */
  79482. /**
  79483. * Sets the left joystick values
  79484. */
  79485. leftStick: StickValues;
  79486. /**
  79487. * Gets the right joystick
  79488. */
  79489. /**
  79490. * Sets the right joystick value
  79491. */
  79492. rightStick: StickValues;
  79493. /**
  79494. * Updates the gamepad joystick positions
  79495. */
  79496. update(): void;
  79497. /**
  79498. * Disposes the gamepad
  79499. */
  79500. dispose(): void;
  79501. }
  79502. /**
  79503. * Represents a generic gamepad
  79504. */
  79505. export class GenericPad extends Gamepad {
  79506. private _buttons;
  79507. private _onbuttondown;
  79508. private _onbuttonup;
  79509. /**
  79510. * Observable triggered when a button has been pressed
  79511. */
  79512. onButtonDownObservable: Observable<number>;
  79513. /**
  79514. * Observable triggered when a button has been released
  79515. */
  79516. onButtonUpObservable: Observable<number>;
  79517. /**
  79518. * Callback triggered when a button has been pressed
  79519. * @param callback Called when a button has been pressed
  79520. */
  79521. onbuttondown(callback: (buttonPressed: number) => void): void;
  79522. /**
  79523. * Callback triggered when a button has been released
  79524. * @param callback Called when a button has been released
  79525. */
  79526. onbuttonup(callback: (buttonReleased: number) => void): void;
  79527. /**
  79528. * Initializes the generic gamepad
  79529. * @param id The id of the generic gamepad
  79530. * @param index The index of the generic gamepad
  79531. * @param browserGamepad The browser gamepad
  79532. */
  79533. constructor(id: string, index: number, browserGamepad: any);
  79534. private _setButtonValue;
  79535. /**
  79536. * Updates the generic gamepad
  79537. */
  79538. update(): void;
  79539. /**
  79540. * Disposes the generic gamepad
  79541. */
  79542. dispose(): void;
  79543. }
  79544. }
  79545. declare module BABYLON {
  79546. /**
  79547. * Defines the types of pose enabled controllers that are supported
  79548. */
  79549. export enum PoseEnabledControllerType {
  79550. /**
  79551. * HTC Vive
  79552. */
  79553. VIVE = 0,
  79554. /**
  79555. * Oculus Rift
  79556. */
  79557. OCULUS = 1,
  79558. /**
  79559. * Windows mixed reality
  79560. */
  79561. WINDOWS = 2,
  79562. /**
  79563. * Samsung gear VR
  79564. */
  79565. GEAR_VR = 3,
  79566. /**
  79567. * Google Daydream
  79568. */
  79569. DAYDREAM = 4,
  79570. /**
  79571. * Generic
  79572. */
  79573. GENERIC = 5
  79574. }
  79575. /**
  79576. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79577. */
  79578. export interface MutableGamepadButton {
  79579. /**
  79580. * Value of the button/trigger
  79581. */
  79582. value: number;
  79583. /**
  79584. * If the button/trigger is currently touched
  79585. */
  79586. touched: boolean;
  79587. /**
  79588. * If the button/trigger is currently pressed
  79589. */
  79590. pressed: boolean;
  79591. }
  79592. /**
  79593. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79594. * @hidden
  79595. */
  79596. export interface ExtendedGamepadButton extends GamepadButton {
  79597. /**
  79598. * If the button/trigger is currently pressed
  79599. */
  79600. readonly pressed: boolean;
  79601. /**
  79602. * If the button/trigger is currently touched
  79603. */
  79604. readonly touched: boolean;
  79605. /**
  79606. * Value of the button/trigger
  79607. */
  79608. readonly value: number;
  79609. }
  79610. /** @hidden */
  79611. export interface _GamePadFactory {
  79612. /**
  79613. * Returns wether or not the current gamepad can be created for this type of controller.
  79614. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79615. * @returns true if it can be created, otherwise false
  79616. */
  79617. canCreate(gamepadInfo: any): boolean;
  79618. /**
  79619. * Creates a new instance of the Gamepad.
  79620. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79621. * @returns the new gamepad instance
  79622. */
  79623. create(gamepadInfo: any): Gamepad;
  79624. }
  79625. /**
  79626. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79627. */
  79628. export class PoseEnabledControllerHelper {
  79629. /** @hidden */
  79630. static _ControllerFactories: _GamePadFactory[];
  79631. /** @hidden */
  79632. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79633. /**
  79634. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79635. * @param vrGamepad the gamepad to initialized
  79636. * @returns a vr controller of the type the gamepad identified as
  79637. */
  79638. static InitiateController(vrGamepad: any): Gamepad;
  79639. }
  79640. /**
  79641. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79642. */
  79643. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79644. private _deviceRoomPosition;
  79645. private _deviceRoomRotationQuaternion;
  79646. /**
  79647. * The device position in babylon space
  79648. */
  79649. devicePosition: Vector3;
  79650. /**
  79651. * The device rotation in babylon space
  79652. */
  79653. deviceRotationQuaternion: Quaternion;
  79654. /**
  79655. * The scale factor of the device in babylon space
  79656. */
  79657. deviceScaleFactor: number;
  79658. /**
  79659. * (Likely devicePosition should be used instead) The device position in its room space
  79660. */
  79661. position: Vector3;
  79662. /**
  79663. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79664. */
  79665. rotationQuaternion: Quaternion;
  79666. /**
  79667. * The type of controller (Eg. Windows mixed reality)
  79668. */
  79669. controllerType: PoseEnabledControllerType;
  79670. protected _calculatedPosition: Vector3;
  79671. private _calculatedRotation;
  79672. /**
  79673. * The raw pose from the device
  79674. */
  79675. rawPose: DevicePose;
  79676. private _trackPosition;
  79677. private _maxRotationDistFromHeadset;
  79678. private _draggedRoomRotation;
  79679. /**
  79680. * @hidden
  79681. */
  79682. _disableTrackPosition(fixedPosition: Vector3): void;
  79683. /**
  79684. * Internal, the mesh attached to the controller
  79685. * @hidden
  79686. */
  79687. _mesh: Nullable<AbstractMesh>;
  79688. private _poseControlledCamera;
  79689. private _leftHandSystemQuaternion;
  79690. /**
  79691. * Internal, matrix used to convert room space to babylon space
  79692. * @hidden
  79693. */
  79694. _deviceToWorld: Matrix;
  79695. /**
  79696. * Node to be used when casting a ray from the controller
  79697. * @hidden
  79698. */
  79699. _pointingPoseNode: Nullable<TransformNode>;
  79700. /**
  79701. * Name of the child mesh that can be used to cast a ray from the controller
  79702. */
  79703. static readonly POINTING_POSE: string;
  79704. /**
  79705. * Creates a new PoseEnabledController from a gamepad
  79706. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79707. */
  79708. constructor(browserGamepad: any);
  79709. private _workingMatrix;
  79710. /**
  79711. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79712. */
  79713. update(): void;
  79714. /**
  79715. * Updates only the pose device and mesh without doing any button event checking
  79716. */
  79717. protected _updatePoseAndMesh(): void;
  79718. /**
  79719. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79720. * @param poseData raw pose fromthe device
  79721. */
  79722. updateFromDevice(poseData: DevicePose): void;
  79723. /**
  79724. * @hidden
  79725. */
  79726. _meshAttachedObservable: Observable<AbstractMesh>;
  79727. /**
  79728. * Attaches a mesh to the controller
  79729. * @param mesh the mesh to be attached
  79730. */
  79731. attachToMesh(mesh: AbstractMesh): void;
  79732. /**
  79733. * Attaches the controllers mesh to a camera
  79734. * @param camera the camera the mesh should be attached to
  79735. */
  79736. attachToPoseControlledCamera(camera: TargetCamera): void;
  79737. /**
  79738. * Disposes of the controller
  79739. */
  79740. dispose(): void;
  79741. /**
  79742. * The mesh that is attached to the controller
  79743. */
  79744. readonly mesh: Nullable<AbstractMesh>;
  79745. /**
  79746. * Gets the ray of the controller in the direction the controller is pointing
  79747. * @param length the length the resulting ray should be
  79748. * @returns a ray in the direction the controller is pointing
  79749. */
  79750. getForwardRay(length?: number): Ray;
  79751. }
  79752. }
  79753. declare module BABYLON {
  79754. /**
  79755. * Defines the WebVRController object that represents controllers tracked in 3D space
  79756. */
  79757. export abstract class WebVRController extends PoseEnabledController {
  79758. /**
  79759. * Internal, the default controller model for the controller
  79760. */
  79761. protected _defaultModel: AbstractMesh;
  79762. /**
  79763. * Fired when the trigger state has changed
  79764. */
  79765. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79766. /**
  79767. * Fired when the main button state has changed
  79768. */
  79769. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79770. /**
  79771. * Fired when the secondary button state has changed
  79772. */
  79773. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79774. /**
  79775. * Fired when the pad state has changed
  79776. */
  79777. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79778. /**
  79779. * Fired when controllers stick values have changed
  79780. */
  79781. onPadValuesChangedObservable: Observable<StickValues>;
  79782. /**
  79783. * Array of button availible on the controller
  79784. */
  79785. protected _buttons: Array<MutableGamepadButton>;
  79786. private _onButtonStateChange;
  79787. /**
  79788. * Fired when a controller button's state has changed
  79789. * @param callback the callback containing the button that was modified
  79790. */
  79791. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79792. /**
  79793. * X and Y axis corresponding to the controllers joystick
  79794. */
  79795. pad: StickValues;
  79796. /**
  79797. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79798. */
  79799. hand: string;
  79800. /**
  79801. * The default controller model for the controller
  79802. */
  79803. readonly defaultModel: AbstractMesh;
  79804. /**
  79805. * Creates a new WebVRController from a gamepad
  79806. * @param vrGamepad the gamepad that the WebVRController should be created from
  79807. */
  79808. constructor(vrGamepad: any);
  79809. /**
  79810. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79811. */
  79812. update(): void;
  79813. /**
  79814. * Function to be called when a button is modified
  79815. */
  79816. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79817. /**
  79818. * Loads a mesh and attaches it to the controller
  79819. * @param scene the scene the mesh should be added to
  79820. * @param meshLoaded callback for when the mesh has been loaded
  79821. */
  79822. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79823. private _setButtonValue;
  79824. private _changes;
  79825. private _checkChanges;
  79826. /**
  79827. * Disposes of th webVRCOntroller
  79828. */
  79829. dispose(): void;
  79830. }
  79831. }
  79832. declare module BABYLON {
  79833. /**
  79834. * The HemisphericLight simulates the ambient environment light,
  79835. * so the passed direction is the light reflection direction, not the incoming direction.
  79836. */
  79837. export class HemisphericLight extends Light {
  79838. /**
  79839. * The groundColor is the light in the opposite direction to the one specified during creation.
  79840. * 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.
  79841. */
  79842. groundColor: Color3;
  79843. /**
  79844. * The light reflection direction, not the incoming direction.
  79845. */
  79846. direction: Vector3;
  79847. /**
  79848. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79849. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79850. * The HemisphericLight can't cast shadows.
  79851. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79852. * @param name The friendly name of the light
  79853. * @param direction The direction of the light reflection
  79854. * @param scene The scene the light belongs to
  79855. */
  79856. constructor(name: string, direction: Vector3, scene: Scene);
  79857. protected _buildUniformLayout(): void;
  79858. /**
  79859. * Returns the string "HemisphericLight".
  79860. * @return The class name
  79861. */
  79862. getClassName(): string;
  79863. /**
  79864. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79865. * Returns the updated direction.
  79866. * @param target The target the direction should point to
  79867. * @return The computed direction
  79868. */
  79869. setDirectionToTarget(target: Vector3): Vector3;
  79870. /**
  79871. * Returns the shadow generator associated to the light.
  79872. * @returns Always null for hemispheric lights because it does not support shadows.
  79873. */
  79874. getShadowGenerator(): Nullable<IShadowGenerator>;
  79875. /**
  79876. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79877. * @param effect The effect to update
  79878. * @param lightIndex The index of the light in the effect to update
  79879. * @returns The hemispheric light
  79880. */
  79881. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79882. /**
  79883. * Computes the world matrix of the node
  79884. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79885. * @param useWasUpdatedFlag defines a reserved property
  79886. * @returns the world matrix
  79887. */
  79888. computeWorldMatrix(): Matrix;
  79889. /**
  79890. * Returns the integer 3.
  79891. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79892. */
  79893. getTypeID(): number;
  79894. /**
  79895. * Prepares the list of defines specific to the light type.
  79896. * @param defines the list of defines
  79897. * @param lightIndex defines the index of the light for the effect
  79898. */
  79899. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79900. }
  79901. }
  79902. declare module BABYLON {
  79903. /** @hidden */
  79904. export var vrMultiviewToSingleviewPixelShader: {
  79905. name: string;
  79906. shader: string;
  79907. };
  79908. }
  79909. declare module BABYLON {
  79910. /**
  79911. * Renders to multiple views with a single draw call
  79912. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79913. */
  79914. export class MultiviewRenderTarget extends RenderTargetTexture {
  79915. /**
  79916. * Creates a multiview render target
  79917. * @param scene scene used with the render target
  79918. * @param size the size of the render target (used for each view)
  79919. */
  79920. constructor(scene: Scene, size?: number | {
  79921. width: number;
  79922. height: number;
  79923. } | {
  79924. ratio: number;
  79925. });
  79926. /**
  79927. * @hidden
  79928. * @param faceIndex the face index, if its a cube texture
  79929. */
  79930. _bindFrameBuffer(faceIndex?: number): void;
  79931. /**
  79932. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  79933. * @returns the view count
  79934. */
  79935. getViewCount(): number;
  79936. }
  79937. }
  79938. declare module BABYLON {
  79939. interface Engine {
  79940. /**
  79941. * Creates a new multiview render target
  79942. * @param width defines the width of the texture
  79943. * @param height defines the height of the texture
  79944. * @returns the created multiview texture
  79945. */
  79946. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  79947. /**
  79948. * Binds a multiview framebuffer to be drawn to
  79949. * @param multiviewTexture texture to bind
  79950. */
  79951. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  79952. }
  79953. interface Camera {
  79954. /**
  79955. * @hidden
  79956. * 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)
  79957. */
  79958. _useMultiviewToSingleView: boolean;
  79959. /**
  79960. * @hidden
  79961. * 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)
  79962. */
  79963. _multiviewTexture: Nullable<RenderTargetTexture>;
  79964. /**
  79965. * @hidden
  79966. * ensures the multiview texture of the camera exists and has the specified width/height
  79967. * @param width height to set on the multiview texture
  79968. * @param height width to set on the multiview texture
  79969. */
  79970. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  79971. }
  79972. interface Scene {
  79973. /** @hidden */
  79974. _transformMatrixR: Matrix;
  79975. /** @hidden */
  79976. _multiviewSceneUbo: Nullable<UniformBuffer>;
  79977. /** @hidden */
  79978. _createMultiviewUbo(): void;
  79979. /** @hidden */
  79980. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  79981. /** @hidden */
  79982. _renderMultiviewToSingleView(camera: Camera): void;
  79983. }
  79984. }
  79985. declare module BABYLON {
  79986. /**
  79987. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  79988. * This will not be used for webXR as it supports displaying texture arrays directly
  79989. */
  79990. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  79991. /**
  79992. * Initializes a VRMultiviewToSingleview
  79993. * @param name name of the post process
  79994. * @param camera camera to be applied to
  79995. * @param scaleFactor scaling factor to the size of the output texture
  79996. */
  79997. constructor(name: string, camera: Camera, scaleFactor: number);
  79998. }
  79999. }
  80000. declare module BABYLON {
  80001. interface Engine {
  80002. /** @hidden */
  80003. _vrDisplay: any;
  80004. /** @hidden */
  80005. _vrSupported: boolean;
  80006. /** @hidden */
  80007. _oldSize: Size;
  80008. /** @hidden */
  80009. _oldHardwareScaleFactor: number;
  80010. /** @hidden */
  80011. _vrExclusivePointerMode: boolean;
  80012. /** @hidden */
  80013. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80014. /** @hidden */
  80015. _onVRDisplayPointerRestricted: () => void;
  80016. /** @hidden */
  80017. _onVRDisplayPointerUnrestricted: () => void;
  80018. /** @hidden */
  80019. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80020. /** @hidden */
  80021. _onVrDisplayDisconnect: Nullable<() => void>;
  80022. /** @hidden */
  80023. _onVrDisplayPresentChange: Nullable<() => void>;
  80024. /**
  80025. * Observable signaled when VR display mode changes
  80026. */
  80027. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80028. /**
  80029. * Observable signaled when VR request present is complete
  80030. */
  80031. onVRRequestPresentComplete: Observable<boolean>;
  80032. /**
  80033. * Observable signaled when VR request present starts
  80034. */
  80035. onVRRequestPresentStart: Observable<Engine>;
  80036. /**
  80037. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80038. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80039. */
  80040. isInVRExclusivePointerMode: boolean;
  80041. /**
  80042. * Gets a boolean indicating if a webVR device was detected
  80043. * @returns true if a webVR device was detected
  80044. */
  80045. isVRDevicePresent(): boolean;
  80046. /**
  80047. * Gets the current webVR device
  80048. * @returns the current webVR device (or null)
  80049. */
  80050. getVRDevice(): any;
  80051. /**
  80052. * Initializes a webVR display and starts listening to display change events
  80053. * The onVRDisplayChangedObservable will be notified upon these changes
  80054. * @returns A promise containing a VRDisplay and if vr is supported
  80055. */
  80056. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80057. /** @hidden */
  80058. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80059. /**
  80060. * Call this function to switch to webVR mode
  80061. * Will do nothing if webVR is not supported or if there is no webVR device
  80062. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80063. */
  80064. enableVR(): void;
  80065. /** @hidden */
  80066. _onVRFullScreenTriggered(): void;
  80067. }
  80068. }
  80069. declare module BABYLON {
  80070. /**
  80071. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80072. * IMPORTANT!! The data is right-hand data.
  80073. * @export
  80074. * @interface DevicePose
  80075. */
  80076. export interface DevicePose {
  80077. /**
  80078. * The position of the device, values in array are [x,y,z].
  80079. */
  80080. readonly position: Nullable<Float32Array>;
  80081. /**
  80082. * The linearVelocity of the device, values in array are [x,y,z].
  80083. */
  80084. readonly linearVelocity: Nullable<Float32Array>;
  80085. /**
  80086. * The linearAcceleration of the device, values in array are [x,y,z].
  80087. */
  80088. readonly linearAcceleration: Nullable<Float32Array>;
  80089. /**
  80090. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80091. */
  80092. readonly orientation: Nullable<Float32Array>;
  80093. /**
  80094. * The angularVelocity of the device, values in array are [x,y,z].
  80095. */
  80096. readonly angularVelocity: Nullable<Float32Array>;
  80097. /**
  80098. * The angularAcceleration of the device, values in array are [x,y,z].
  80099. */
  80100. readonly angularAcceleration: Nullable<Float32Array>;
  80101. }
  80102. /**
  80103. * Interface representing a pose controlled object in Babylon.
  80104. * A pose controlled object has both regular pose values as well as pose values
  80105. * from an external device such as a VR head mounted display
  80106. */
  80107. export interface PoseControlled {
  80108. /**
  80109. * The position of the object in babylon space.
  80110. */
  80111. position: Vector3;
  80112. /**
  80113. * The rotation quaternion of the object in babylon space.
  80114. */
  80115. rotationQuaternion: Quaternion;
  80116. /**
  80117. * The position of the device in babylon space.
  80118. */
  80119. devicePosition?: Vector3;
  80120. /**
  80121. * The rotation quaternion of the device in babylon space.
  80122. */
  80123. deviceRotationQuaternion: Quaternion;
  80124. /**
  80125. * The raw pose coming from the device.
  80126. */
  80127. rawPose: Nullable<DevicePose>;
  80128. /**
  80129. * The scale of the device to be used when translating from device space to babylon space.
  80130. */
  80131. deviceScaleFactor: number;
  80132. /**
  80133. * Updates the poseControlled values based on the input device pose.
  80134. * @param poseData the pose data to update the object with
  80135. */
  80136. updateFromDevice(poseData: DevicePose): void;
  80137. }
  80138. /**
  80139. * Set of options to customize the webVRCamera
  80140. */
  80141. export interface WebVROptions {
  80142. /**
  80143. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80144. */
  80145. trackPosition?: boolean;
  80146. /**
  80147. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80148. */
  80149. positionScale?: number;
  80150. /**
  80151. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80152. */
  80153. displayName?: string;
  80154. /**
  80155. * Should the native controller meshes be initialized. (default: true)
  80156. */
  80157. controllerMeshes?: boolean;
  80158. /**
  80159. * Creating a default HemiLight only on controllers. (default: true)
  80160. */
  80161. defaultLightingOnControllers?: boolean;
  80162. /**
  80163. * If you don't want to use the default VR button of the helper. (default: false)
  80164. */
  80165. useCustomVRButton?: boolean;
  80166. /**
  80167. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80168. */
  80169. customVRButton?: HTMLButtonElement;
  80170. /**
  80171. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80172. */
  80173. rayLength?: number;
  80174. /**
  80175. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80176. */
  80177. defaultHeight?: number;
  80178. /**
  80179. * If multiview should be used if availible (default: false)
  80180. */
  80181. useMultiview?: boolean;
  80182. }
  80183. /**
  80184. * This represents a WebVR camera.
  80185. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80186. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80187. */
  80188. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80189. private webVROptions;
  80190. /**
  80191. * @hidden
  80192. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80193. */
  80194. _vrDevice: any;
  80195. /**
  80196. * The rawPose of the vrDevice.
  80197. */
  80198. rawPose: Nullable<DevicePose>;
  80199. private _onVREnabled;
  80200. private _specsVersion;
  80201. private _attached;
  80202. private _frameData;
  80203. protected _descendants: Array<Node>;
  80204. private _deviceRoomPosition;
  80205. /** @hidden */
  80206. _deviceRoomRotationQuaternion: Quaternion;
  80207. private _standingMatrix;
  80208. /**
  80209. * Represents device position in babylon space.
  80210. */
  80211. devicePosition: Vector3;
  80212. /**
  80213. * Represents device rotation in babylon space.
  80214. */
  80215. deviceRotationQuaternion: Quaternion;
  80216. /**
  80217. * The scale of the device to be used when translating from device space to babylon space.
  80218. */
  80219. deviceScaleFactor: number;
  80220. private _deviceToWorld;
  80221. private _worldToDevice;
  80222. /**
  80223. * References to the webVR controllers for the vrDevice.
  80224. */
  80225. controllers: Array<WebVRController>;
  80226. /**
  80227. * Emits an event when a controller is attached.
  80228. */
  80229. onControllersAttachedObservable: Observable<WebVRController[]>;
  80230. /**
  80231. * Emits an event when a controller's mesh has been loaded;
  80232. */
  80233. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80234. /**
  80235. * Emits an event when the HMD's pose has been updated.
  80236. */
  80237. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80238. private _poseSet;
  80239. /**
  80240. * If the rig cameras be used as parent instead of this camera.
  80241. */
  80242. rigParenting: boolean;
  80243. private _lightOnControllers;
  80244. private _defaultHeight?;
  80245. /**
  80246. * Instantiates a WebVRFreeCamera.
  80247. * @param name The name of the WebVRFreeCamera
  80248. * @param position The starting anchor position for the camera
  80249. * @param scene The scene the camera belongs to
  80250. * @param webVROptions a set of customizable options for the webVRCamera
  80251. */
  80252. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80253. /**
  80254. * Gets the device distance from the ground in meters.
  80255. * @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.
  80256. */
  80257. deviceDistanceToRoomGround(): number;
  80258. /**
  80259. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80260. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80261. */
  80262. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80263. /**
  80264. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80265. * @returns A promise with a boolean set to if the standing matrix is supported.
  80266. */
  80267. useStandingMatrixAsync(): Promise<boolean>;
  80268. /**
  80269. * Disposes the camera
  80270. */
  80271. dispose(): void;
  80272. /**
  80273. * Gets a vrController by name.
  80274. * @param name The name of the controller to retreive
  80275. * @returns the controller matching the name specified or null if not found
  80276. */
  80277. getControllerByName(name: string): Nullable<WebVRController>;
  80278. private _leftController;
  80279. /**
  80280. * The controller corresponding to the users left hand.
  80281. */
  80282. readonly leftController: Nullable<WebVRController>;
  80283. private _rightController;
  80284. /**
  80285. * The controller corresponding to the users right hand.
  80286. */
  80287. readonly rightController: Nullable<WebVRController>;
  80288. /**
  80289. * Casts a ray forward from the vrCamera's gaze.
  80290. * @param length Length of the ray (default: 100)
  80291. * @returns the ray corresponding to the gaze
  80292. */
  80293. getForwardRay(length?: number): Ray;
  80294. /**
  80295. * @hidden
  80296. * Updates the camera based on device's frame data
  80297. */
  80298. _checkInputs(): void;
  80299. /**
  80300. * Updates the poseControlled values based on the input device pose.
  80301. * @param poseData Pose coming from the device
  80302. */
  80303. updateFromDevice(poseData: DevicePose): void;
  80304. private _htmlElementAttached;
  80305. private _detachIfAttached;
  80306. /**
  80307. * WebVR's attach control will start broadcasting frames to the device.
  80308. * Note that in certain browsers (chrome for example) this function must be called
  80309. * within a user-interaction callback. Example:
  80310. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80311. *
  80312. * @param element html element to attach the vrDevice to
  80313. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80314. */
  80315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80316. /**
  80317. * Detaches the camera from the html element and disables VR
  80318. *
  80319. * @param element html element to detach from
  80320. */
  80321. detachControl(element: HTMLElement): void;
  80322. /**
  80323. * @returns the name of this class
  80324. */
  80325. getClassName(): string;
  80326. /**
  80327. * Calls resetPose on the vrDisplay
  80328. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80329. */
  80330. resetToCurrentRotation(): void;
  80331. /**
  80332. * @hidden
  80333. * Updates the rig cameras (left and right eye)
  80334. */
  80335. _updateRigCameras(): void;
  80336. private _workingVector;
  80337. private _oneVector;
  80338. private _workingMatrix;
  80339. private updateCacheCalled;
  80340. private _correctPositionIfNotTrackPosition;
  80341. /**
  80342. * @hidden
  80343. * Updates the cached values of the camera
  80344. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80345. */
  80346. _updateCache(ignoreParentClass?: boolean): void;
  80347. /**
  80348. * @hidden
  80349. * Get current device position in babylon world
  80350. */
  80351. _computeDevicePosition(): void;
  80352. /**
  80353. * Updates the current device position and rotation in the babylon world
  80354. */
  80355. update(): void;
  80356. /**
  80357. * @hidden
  80358. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80359. * @returns an identity matrix
  80360. */
  80361. _getViewMatrix(): Matrix;
  80362. private _tmpMatrix;
  80363. /**
  80364. * This function is called by the two RIG cameras.
  80365. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80366. * @hidden
  80367. */
  80368. _getWebVRViewMatrix(): Matrix;
  80369. /** @hidden */
  80370. _getWebVRProjectionMatrix(): Matrix;
  80371. private _onGamepadConnectedObserver;
  80372. private _onGamepadDisconnectedObserver;
  80373. private _updateCacheWhenTrackingDisabledObserver;
  80374. /**
  80375. * Initializes the controllers and their meshes
  80376. */
  80377. initControllers(): void;
  80378. }
  80379. }
  80380. declare module BABYLON {
  80381. /**
  80382. * Size options for a post process
  80383. */
  80384. export type PostProcessOptions = {
  80385. width: number;
  80386. height: number;
  80387. };
  80388. /**
  80389. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80390. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80391. */
  80392. export class PostProcess {
  80393. /** Name of the PostProcess. */
  80394. name: string;
  80395. /**
  80396. * Gets or sets the unique id of the post process
  80397. */
  80398. uniqueId: number;
  80399. /**
  80400. * Width of the texture to apply the post process on
  80401. */
  80402. width: number;
  80403. /**
  80404. * Height of the texture to apply the post process on
  80405. */
  80406. height: number;
  80407. /**
  80408. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80409. * @hidden
  80410. */
  80411. _outputTexture: Nullable<InternalTexture>;
  80412. /**
  80413. * Sampling mode used by the shader
  80414. * See https://doc.babylonjs.com/classes/3.1/texture
  80415. */
  80416. renderTargetSamplingMode: number;
  80417. /**
  80418. * Clear color to use when screen clearing
  80419. */
  80420. clearColor: Color4;
  80421. /**
  80422. * If the buffer needs to be cleared before applying the post process. (default: true)
  80423. * Should be set to false if shader will overwrite all previous pixels.
  80424. */
  80425. autoClear: boolean;
  80426. /**
  80427. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80428. */
  80429. alphaMode: number;
  80430. /**
  80431. * Sets the setAlphaBlendConstants of the babylon engine
  80432. */
  80433. alphaConstants: Color4;
  80434. /**
  80435. * Animations to be used for the post processing
  80436. */
  80437. animations: Animation[];
  80438. /**
  80439. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80440. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80441. */
  80442. enablePixelPerfectMode: boolean;
  80443. /**
  80444. * Force the postprocess to be applied without taking in account viewport
  80445. */
  80446. forceFullscreenViewport: boolean;
  80447. /**
  80448. * List of inspectable custom properties (used by the Inspector)
  80449. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80450. */
  80451. inspectableCustomProperties: IInspectable[];
  80452. /**
  80453. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80454. *
  80455. * | Value | Type | Description |
  80456. * | ----- | ----------------------------------- | ----------- |
  80457. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80458. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80459. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80460. *
  80461. */
  80462. scaleMode: number;
  80463. /**
  80464. * Force textures to be a power of two (default: false)
  80465. */
  80466. alwaysForcePOT: boolean;
  80467. private _samples;
  80468. /**
  80469. * Number of sample textures (default: 1)
  80470. */
  80471. samples: number;
  80472. /**
  80473. * Modify the scale of the post process to be the same as the viewport (default: false)
  80474. */
  80475. adaptScaleToCurrentViewport: boolean;
  80476. private _camera;
  80477. private _scene;
  80478. private _engine;
  80479. private _options;
  80480. private _reusable;
  80481. private _textureType;
  80482. /**
  80483. * Smart array of input and output textures for the post process.
  80484. * @hidden
  80485. */
  80486. _textures: SmartArray<InternalTexture>;
  80487. /**
  80488. * The index in _textures that corresponds to the output texture.
  80489. * @hidden
  80490. */
  80491. _currentRenderTextureInd: number;
  80492. private _effect;
  80493. private _samplers;
  80494. private _fragmentUrl;
  80495. private _vertexUrl;
  80496. private _parameters;
  80497. private _scaleRatio;
  80498. protected _indexParameters: any;
  80499. private _shareOutputWithPostProcess;
  80500. private _texelSize;
  80501. private _forcedOutputTexture;
  80502. /**
  80503. * Returns the fragment url or shader name used in the post process.
  80504. * @returns the fragment url or name in the shader store.
  80505. */
  80506. getEffectName(): string;
  80507. /**
  80508. * An event triggered when the postprocess is activated.
  80509. */
  80510. onActivateObservable: Observable<Camera>;
  80511. private _onActivateObserver;
  80512. /**
  80513. * A function that is added to the onActivateObservable
  80514. */
  80515. onActivate: Nullable<(camera: Camera) => void>;
  80516. /**
  80517. * An event triggered when the postprocess changes its size.
  80518. */
  80519. onSizeChangedObservable: Observable<PostProcess>;
  80520. private _onSizeChangedObserver;
  80521. /**
  80522. * A function that is added to the onSizeChangedObservable
  80523. */
  80524. onSizeChanged: (postProcess: PostProcess) => void;
  80525. /**
  80526. * An event triggered when the postprocess applies its effect.
  80527. */
  80528. onApplyObservable: Observable<Effect>;
  80529. private _onApplyObserver;
  80530. /**
  80531. * A function that is added to the onApplyObservable
  80532. */
  80533. onApply: (effect: Effect) => void;
  80534. /**
  80535. * An event triggered before rendering the postprocess
  80536. */
  80537. onBeforeRenderObservable: Observable<Effect>;
  80538. private _onBeforeRenderObserver;
  80539. /**
  80540. * A function that is added to the onBeforeRenderObservable
  80541. */
  80542. onBeforeRender: (effect: Effect) => void;
  80543. /**
  80544. * An event triggered after rendering the postprocess
  80545. */
  80546. onAfterRenderObservable: Observable<Effect>;
  80547. private _onAfterRenderObserver;
  80548. /**
  80549. * A function that is added to the onAfterRenderObservable
  80550. */
  80551. onAfterRender: (efect: Effect) => void;
  80552. /**
  80553. * 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
  80554. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80555. */
  80556. inputTexture: InternalTexture;
  80557. /**
  80558. * Gets the camera which post process is applied to.
  80559. * @returns The camera the post process is applied to.
  80560. */
  80561. getCamera(): Camera;
  80562. /**
  80563. * Gets the texel size of the postprocess.
  80564. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80565. */
  80566. readonly texelSize: Vector2;
  80567. /**
  80568. * Creates a new instance PostProcess
  80569. * @param name The name of the PostProcess.
  80570. * @param fragmentUrl The url of the fragment shader to be used.
  80571. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80572. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80573. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80574. * @param camera The camera to apply the render pass to.
  80575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80576. * @param engine The engine which the post process will be applied. (default: current engine)
  80577. * @param reusable If the post process can be reused on the same frame. (default: false)
  80578. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80579. * @param textureType Type of textures used when performing the post process. (default: 0)
  80580. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80581. * @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
  80582. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80583. */
  80584. constructor(
  80585. /** Name of the PostProcess. */
  80586. 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);
  80587. /**
  80588. * Gets a string idenfifying the name of the class
  80589. * @returns "PostProcess" string
  80590. */
  80591. getClassName(): string;
  80592. /**
  80593. * Gets the engine which this post process belongs to.
  80594. * @returns The engine the post process was enabled with.
  80595. */
  80596. getEngine(): Engine;
  80597. /**
  80598. * The effect that is created when initializing the post process.
  80599. * @returns The created effect corresponding the the postprocess.
  80600. */
  80601. getEffect(): Effect;
  80602. /**
  80603. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80604. * @param postProcess The post process to share the output with.
  80605. * @returns This post process.
  80606. */
  80607. shareOutputWith(postProcess: PostProcess): PostProcess;
  80608. /**
  80609. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80610. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80611. */
  80612. useOwnOutput(): void;
  80613. /**
  80614. * Updates the effect with the current post process compile time values and recompiles the shader.
  80615. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80616. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80617. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80618. * @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
  80619. * @param onCompiled Called when the shader has been compiled.
  80620. * @param onError Called if there is an error when compiling a shader.
  80621. */
  80622. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80623. /**
  80624. * The post process is reusable if it can be used multiple times within one frame.
  80625. * @returns If the post process is reusable
  80626. */
  80627. isReusable(): boolean;
  80628. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80629. markTextureDirty(): void;
  80630. /**
  80631. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80632. * 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.
  80633. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80634. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80635. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80636. * @returns The target texture that was bound to be written to.
  80637. */
  80638. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80639. /**
  80640. * If the post process is supported.
  80641. */
  80642. readonly isSupported: boolean;
  80643. /**
  80644. * The aspect ratio of the output texture.
  80645. */
  80646. readonly aspectRatio: number;
  80647. /**
  80648. * Get a value indicating if the post-process is ready to be used
  80649. * @returns true if the post-process is ready (shader is compiled)
  80650. */
  80651. isReady(): boolean;
  80652. /**
  80653. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80654. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80655. */
  80656. apply(): Nullable<Effect>;
  80657. private _disposeTextures;
  80658. /**
  80659. * Disposes the post process.
  80660. * @param camera The camera to dispose the post process on.
  80661. */
  80662. dispose(camera?: Camera): void;
  80663. }
  80664. }
  80665. declare module BABYLON {
  80666. /** @hidden */
  80667. export var kernelBlurVaryingDeclaration: {
  80668. name: string;
  80669. shader: string;
  80670. };
  80671. }
  80672. declare module BABYLON {
  80673. /** @hidden */
  80674. export var kernelBlurFragment: {
  80675. name: string;
  80676. shader: string;
  80677. };
  80678. }
  80679. declare module BABYLON {
  80680. /** @hidden */
  80681. export var kernelBlurFragment2: {
  80682. name: string;
  80683. shader: string;
  80684. };
  80685. }
  80686. declare module BABYLON {
  80687. /** @hidden */
  80688. export var kernelBlurPixelShader: {
  80689. name: string;
  80690. shader: string;
  80691. };
  80692. }
  80693. declare module BABYLON {
  80694. /** @hidden */
  80695. export var kernelBlurVertex: {
  80696. name: string;
  80697. shader: string;
  80698. };
  80699. }
  80700. declare module BABYLON {
  80701. /** @hidden */
  80702. export var kernelBlurVertexShader: {
  80703. name: string;
  80704. shader: string;
  80705. };
  80706. }
  80707. declare module BABYLON {
  80708. /**
  80709. * The Blur Post Process which blurs an image based on a kernel and direction.
  80710. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80711. */
  80712. export class BlurPostProcess extends PostProcess {
  80713. /** The direction in which to blur the image. */
  80714. direction: Vector2;
  80715. private blockCompilation;
  80716. protected _kernel: number;
  80717. protected _idealKernel: number;
  80718. protected _packedFloat: boolean;
  80719. private _staticDefines;
  80720. /**
  80721. * Sets the length in pixels of the blur sample region
  80722. */
  80723. /**
  80724. * Gets the length in pixels of the blur sample region
  80725. */
  80726. kernel: number;
  80727. /**
  80728. * Sets wether or not the blur needs to unpack/repack floats
  80729. */
  80730. /**
  80731. * Gets wether or not the blur is unpacking/repacking floats
  80732. */
  80733. packedFloat: boolean;
  80734. /**
  80735. * Creates a new instance BlurPostProcess
  80736. * @param name The name of the effect.
  80737. * @param direction The direction in which to blur the image.
  80738. * @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.
  80739. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80740. * @param camera The camera to apply the render pass to.
  80741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80742. * @param engine The engine which the post process will be applied. (default: current engine)
  80743. * @param reusable If the post process can be reused on the same frame. (default: false)
  80744. * @param textureType Type of textures used when performing the post process. (default: 0)
  80745. * @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)
  80746. */
  80747. constructor(name: string,
  80748. /** The direction in which to blur the image. */
  80749. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80750. /**
  80751. * Updates the effect with the current post process compile time values and recompiles the shader.
  80752. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80753. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80754. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80755. * @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
  80756. * @param onCompiled Called when the shader has been compiled.
  80757. * @param onError Called if there is an error when compiling a shader.
  80758. */
  80759. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80760. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80761. /**
  80762. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80763. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80764. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80765. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80766. * The gaps between physical kernels are compensated for in the weighting of the samples
  80767. * @param idealKernel Ideal blur kernel.
  80768. * @return Nearest best kernel.
  80769. */
  80770. protected _nearestBestKernel(idealKernel: number): number;
  80771. /**
  80772. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80773. * @param x The point on the Gaussian distribution to sample.
  80774. * @return the value of the Gaussian function at x.
  80775. */
  80776. protected _gaussianWeight(x: number): number;
  80777. /**
  80778. * Generates a string that can be used as a floating point number in GLSL.
  80779. * @param x Value to print.
  80780. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80781. * @return GLSL float string.
  80782. */
  80783. protected _glslFloat(x: number, decimalFigures?: number): string;
  80784. }
  80785. }
  80786. declare module BABYLON {
  80787. /**
  80788. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80789. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80790. * You can then easily use it as a reflectionTexture on a flat surface.
  80791. * In case the surface is not a plane, please consider relying on reflection probes.
  80792. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80793. */
  80794. export class MirrorTexture extends RenderTargetTexture {
  80795. private scene;
  80796. /**
  80797. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80798. * 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.
  80799. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80800. */
  80801. mirrorPlane: Plane;
  80802. /**
  80803. * Define the blur ratio used to blur the reflection if needed.
  80804. */
  80805. blurRatio: number;
  80806. /**
  80807. * Define the adaptive blur kernel used to blur the reflection if needed.
  80808. * This will autocompute the closest best match for the `blurKernel`
  80809. */
  80810. adaptiveBlurKernel: number;
  80811. /**
  80812. * Define the blur kernel used to blur the reflection if needed.
  80813. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80814. */
  80815. blurKernel: number;
  80816. /**
  80817. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80818. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80819. */
  80820. blurKernelX: number;
  80821. /**
  80822. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80823. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80824. */
  80825. blurKernelY: number;
  80826. private _autoComputeBlurKernel;
  80827. protected _onRatioRescale(): void;
  80828. private _updateGammaSpace;
  80829. private _imageProcessingConfigChangeObserver;
  80830. private _transformMatrix;
  80831. private _mirrorMatrix;
  80832. private _savedViewMatrix;
  80833. private _blurX;
  80834. private _blurY;
  80835. private _adaptiveBlurKernel;
  80836. private _blurKernelX;
  80837. private _blurKernelY;
  80838. private _blurRatio;
  80839. /**
  80840. * Instantiates a Mirror Texture.
  80841. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80842. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80843. * You can then easily use it as a reflectionTexture on a flat surface.
  80844. * In case the surface is not a plane, please consider relying on reflection probes.
  80845. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80846. * @param name
  80847. * @param size
  80848. * @param scene
  80849. * @param generateMipMaps
  80850. * @param type
  80851. * @param samplingMode
  80852. * @param generateDepthBuffer
  80853. */
  80854. constructor(name: string, size: number | {
  80855. width: number;
  80856. height: number;
  80857. } | {
  80858. ratio: number;
  80859. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80860. private _preparePostProcesses;
  80861. /**
  80862. * Clone the mirror texture.
  80863. * @returns the cloned texture
  80864. */
  80865. clone(): MirrorTexture;
  80866. /**
  80867. * Serialize the texture to a JSON representation you could use in Parse later on
  80868. * @returns the serialized JSON representation
  80869. */
  80870. serialize(): any;
  80871. /**
  80872. * Dispose the texture and release its associated resources.
  80873. */
  80874. dispose(): void;
  80875. }
  80876. }
  80877. declare module BABYLON {
  80878. /**
  80879. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80880. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80881. */
  80882. export class Texture extends BaseTexture {
  80883. /** @hidden */
  80884. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80885. /** @hidden */
  80886. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80887. /** @hidden */
  80888. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80889. /** nearest is mag = nearest and min = nearest and mip = linear */
  80890. static readonly NEAREST_SAMPLINGMODE: number;
  80891. /** nearest is mag = nearest and min = nearest and mip = linear */
  80892. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80893. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80894. static readonly BILINEAR_SAMPLINGMODE: number;
  80895. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80896. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80897. /** Trilinear is mag = linear and min = linear and mip = linear */
  80898. static readonly TRILINEAR_SAMPLINGMODE: number;
  80899. /** Trilinear is mag = linear and min = linear and mip = linear */
  80900. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80901. /** mag = nearest and min = nearest and mip = nearest */
  80902. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80903. /** mag = nearest and min = linear and mip = nearest */
  80904. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80905. /** mag = nearest and min = linear and mip = linear */
  80906. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80907. /** mag = nearest and min = linear and mip = none */
  80908. static readonly NEAREST_LINEAR: number;
  80909. /** mag = nearest and min = nearest and mip = none */
  80910. static readonly NEAREST_NEAREST: number;
  80911. /** mag = linear and min = nearest and mip = nearest */
  80912. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80913. /** mag = linear and min = nearest and mip = linear */
  80914. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80915. /** mag = linear and min = linear and mip = none */
  80916. static readonly LINEAR_LINEAR: number;
  80917. /** mag = linear and min = nearest and mip = none */
  80918. static readonly LINEAR_NEAREST: number;
  80919. /** Explicit coordinates mode */
  80920. static readonly EXPLICIT_MODE: number;
  80921. /** Spherical coordinates mode */
  80922. static readonly SPHERICAL_MODE: number;
  80923. /** Planar coordinates mode */
  80924. static readonly PLANAR_MODE: number;
  80925. /** Cubic coordinates mode */
  80926. static readonly CUBIC_MODE: number;
  80927. /** Projection coordinates mode */
  80928. static readonly PROJECTION_MODE: number;
  80929. /** Inverse Cubic coordinates mode */
  80930. static readonly SKYBOX_MODE: number;
  80931. /** Inverse Cubic coordinates mode */
  80932. static readonly INVCUBIC_MODE: number;
  80933. /** Equirectangular coordinates mode */
  80934. static readonly EQUIRECTANGULAR_MODE: number;
  80935. /** Equirectangular Fixed coordinates mode */
  80936. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80937. /** Equirectangular Fixed Mirrored coordinates mode */
  80938. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80939. /** Texture is not repeating outside of 0..1 UVs */
  80940. static readonly CLAMP_ADDRESSMODE: number;
  80941. /** Texture is repeating outside of 0..1 UVs */
  80942. static readonly WRAP_ADDRESSMODE: number;
  80943. /** Texture is repeating and mirrored */
  80944. static readonly MIRROR_ADDRESSMODE: number;
  80945. /**
  80946. * 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
  80947. */
  80948. static UseSerializedUrlIfAny: boolean;
  80949. /**
  80950. * Define the url of the texture.
  80951. */
  80952. url: Nullable<string>;
  80953. /**
  80954. * Define an offset on the texture to offset the u coordinates of the UVs
  80955. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80956. */
  80957. uOffset: number;
  80958. /**
  80959. * Define an offset on the texture to offset the v coordinates of the UVs
  80960. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80961. */
  80962. vOffset: number;
  80963. /**
  80964. * Define an offset on the texture to scale the u coordinates of the UVs
  80965. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80966. */
  80967. uScale: number;
  80968. /**
  80969. * Define an offset on the texture to scale the v coordinates of the UVs
  80970. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80971. */
  80972. vScale: number;
  80973. /**
  80974. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80975. * @see http://doc.babylonjs.com/how_to/more_materials
  80976. */
  80977. uAng: number;
  80978. /**
  80979. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80980. * @see http://doc.babylonjs.com/how_to/more_materials
  80981. */
  80982. vAng: number;
  80983. /**
  80984. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80985. * @see http://doc.babylonjs.com/how_to/more_materials
  80986. */
  80987. wAng: number;
  80988. /**
  80989. * Defines the center of rotation (U)
  80990. */
  80991. uRotationCenter: number;
  80992. /**
  80993. * Defines the center of rotation (V)
  80994. */
  80995. vRotationCenter: number;
  80996. /**
  80997. * Defines the center of rotation (W)
  80998. */
  80999. wRotationCenter: number;
  81000. /**
  81001. * Are mip maps generated for this texture or not.
  81002. */
  81003. readonly noMipmap: boolean;
  81004. /**
  81005. * List of inspectable custom properties (used by the Inspector)
  81006. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81007. */
  81008. inspectableCustomProperties: Nullable<IInspectable[]>;
  81009. private _noMipmap;
  81010. /** @hidden */
  81011. _invertY: boolean;
  81012. private _rowGenerationMatrix;
  81013. private _cachedTextureMatrix;
  81014. private _projectionModeMatrix;
  81015. private _t0;
  81016. private _t1;
  81017. private _t2;
  81018. private _cachedUOffset;
  81019. private _cachedVOffset;
  81020. private _cachedUScale;
  81021. private _cachedVScale;
  81022. private _cachedUAng;
  81023. private _cachedVAng;
  81024. private _cachedWAng;
  81025. private _cachedProjectionMatrixId;
  81026. private _cachedCoordinatesMode;
  81027. /** @hidden */
  81028. protected _initialSamplingMode: number;
  81029. /** @hidden */
  81030. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81031. private _deleteBuffer;
  81032. protected _format: Nullable<number>;
  81033. private _delayedOnLoad;
  81034. private _delayedOnError;
  81035. /**
  81036. * Observable triggered once the texture has been loaded.
  81037. */
  81038. onLoadObservable: Observable<Texture>;
  81039. protected _isBlocking: boolean;
  81040. /**
  81041. * Is the texture preventing material to render while loading.
  81042. * If false, a default texture will be used instead of the loading one during the preparation step.
  81043. */
  81044. isBlocking: boolean;
  81045. /**
  81046. * Get the current sampling mode associated with the texture.
  81047. */
  81048. readonly samplingMode: number;
  81049. /**
  81050. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81051. */
  81052. readonly invertY: boolean;
  81053. /**
  81054. * Instantiates a new texture.
  81055. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81056. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81057. * @param url define the url of the picture to load as a texture
  81058. * @param scene define the scene the texture will belong to
  81059. * @param noMipmap define if the texture will require mip maps or not
  81060. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81061. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81062. * @param onLoad define a callback triggered when the texture has been loaded
  81063. * @param onError define a callback triggered when an error occurred during the loading session
  81064. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81065. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81066. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81067. */
  81068. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81069. /**
  81070. * Update the url (and optional buffer) of this texture if url was null during construction.
  81071. * @param url the url of the texture
  81072. * @param buffer the buffer of the texture (defaults to null)
  81073. * @param onLoad callback called when the texture is loaded (defaults to null)
  81074. */
  81075. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81076. /**
  81077. * Finish the loading sequence of a texture flagged as delayed load.
  81078. * @hidden
  81079. */
  81080. delayLoad(): void;
  81081. private _prepareRowForTextureGeneration;
  81082. /**
  81083. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81084. * @returns the transform matrix of the texture.
  81085. */
  81086. getTextureMatrix(): Matrix;
  81087. /**
  81088. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81089. * @returns The reflection texture transform
  81090. */
  81091. getReflectionTextureMatrix(): Matrix;
  81092. /**
  81093. * Clones the texture.
  81094. * @returns the cloned texture
  81095. */
  81096. clone(): Texture;
  81097. /**
  81098. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81099. * @returns The JSON representation of the texture
  81100. */
  81101. serialize(): any;
  81102. /**
  81103. * Get the current class name of the texture useful for serialization or dynamic coding.
  81104. * @returns "Texture"
  81105. */
  81106. getClassName(): string;
  81107. /**
  81108. * Dispose the texture and release its associated resources.
  81109. */
  81110. dispose(): void;
  81111. /**
  81112. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81113. * @param parsedTexture Define the JSON representation of the texture
  81114. * @param scene Define the scene the parsed texture should be instantiated in
  81115. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81116. * @returns The parsed texture if successful
  81117. */
  81118. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81119. /**
  81120. * Creates a texture from its base 64 representation.
  81121. * @param data Define the base64 payload without the data: prefix
  81122. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81123. * @param scene Define the scene the texture should belong to
  81124. * @param noMipmap Forces the texture to not create mip map information if true
  81125. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81126. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81127. * @param onLoad define a callback triggered when the texture has been loaded
  81128. * @param onError define a callback triggered when an error occurred during the loading session
  81129. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81130. * @returns the created texture
  81131. */
  81132. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81133. /**
  81134. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81135. * @param data Define the base64 payload without the data: prefix
  81136. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81137. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81138. * @param scene Define the scene the texture should belong to
  81139. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81140. * @param noMipmap Forces the texture to not create mip map information if true
  81141. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81142. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81143. * @param onLoad define a callback triggered when the texture has been loaded
  81144. * @param onError define a callback triggered when an error occurred during the loading session
  81145. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81146. * @returns the created texture
  81147. */
  81148. 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;
  81149. }
  81150. }
  81151. declare module BABYLON {
  81152. /**
  81153. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81154. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81155. */
  81156. export class PostProcessManager {
  81157. private _scene;
  81158. private _indexBuffer;
  81159. private _vertexBuffers;
  81160. /**
  81161. * Creates a new instance PostProcess
  81162. * @param scene The scene that the post process is associated with.
  81163. */
  81164. constructor(scene: Scene);
  81165. private _prepareBuffers;
  81166. private _buildIndexBuffer;
  81167. /**
  81168. * Rebuilds the vertex buffers of the manager.
  81169. * @hidden
  81170. */
  81171. _rebuild(): void;
  81172. /**
  81173. * Prepares a frame to be run through a post process.
  81174. * @param sourceTexture The input texture to the post procesess. (default: null)
  81175. * @param postProcesses An array of post processes to be run. (default: null)
  81176. * @returns True if the post processes were able to be run.
  81177. * @hidden
  81178. */
  81179. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81180. /**
  81181. * Manually render a set of post processes to a texture.
  81182. * @param postProcesses An array of post processes to be run.
  81183. * @param targetTexture The target texture to render to.
  81184. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81185. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81186. * @param lodLevel defines which lod of the texture to render to
  81187. */
  81188. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81189. /**
  81190. * Finalize the result of the output of the postprocesses.
  81191. * @param doNotPresent If true the result will not be displayed to the screen.
  81192. * @param targetTexture The target texture to render to.
  81193. * @param faceIndex The index of the face to bind the target texture to.
  81194. * @param postProcesses The array of post processes to render.
  81195. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81196. * @hidden
  81197. */
  81198. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81199. /**
  81200. * Disposes of the post process manager.
  81201. */
  81202. dispose(): void;
  81203. }
  81204. }
  81205. declare module BABYLON {
  81206. interface AbstractScene {
  81207. /**
  81208. * The list of procedural textures added to the scene
  81209. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81210. */
  81211. proceduralTextures: Array<ProceduralTexture>;
  81212. }
  81213. /**
  81214. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81215. * in a given scene.
  81216. */
  81217. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81218. /**
  81219. * The component name helpfull to identify the component in the list of scene components.
  81220. */
  81221. readonly name: string;
  81222. /**
  81223. * The scene the component belongs to.
  81224. */
  81225. scene: Scene;
  81226. /**
  81227. * Creates a new instance of the component for the given scene
  81228. * @param scene Defines the scene to register the component in
  81229. */
  81230. constructor(scene: Scene);
  81231. /**
  81232. * Registers the component in a given scene
  81233. */
  81234. register(): void;
  81235. /**
  81236. * Rebuilds the elements related to this component in case of
  81237. * context lost for instance.
  81238. */
  81239. rebuild(): void;
  81240. /**
  81241. * Disposes the component and the associated ressources.
  81242. */
  81243. dispose(): void;
  81244. private _beforeClear;
  81245. }
  81246. }
  81247. declare module BABYLON {
  81248. interface Engine {
  81249. /**
  81250. * Creates a new render target cube texture
  81251. * @param size defines the size of the texture
  81252. * @param options defines the options used to create the texture
  81253. * @returns a new render target cube texture stored in an InternalTexture
  81254. */
  81255. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81256. }
  81257. }
  81258. declare module BABYLON {
  81259. /** @hidden */
  81260. export var proceduralVertexShader: {
  81261. name: string;
  81262. shader: string;
  81263. };
  81264. }
  81265. declare module BABYLON {
  81266. /**
  81267. * 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.
  81268. * This is the base class of any Procedural texture and contains most of the shareable code.
  81269. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81270. */
  81271. export class ProceduralTexture extends Texture {
  81272. isCube: boolean;
  81273. /**
  81274. * Define if the texture is enabled or not (disabled texture will not render)
  81275. */
  81276. isEnabled: boolean;
  81277. /**
  81278. * Define if the texture must be cleared before rendering (default is true)
  81279. */
  81280. autoClear: boolean;
  81281. /**
  81282. * Callback called when the texture is generated
  81283. */
  81284. onGenerated: () => void;
  81285. /**
  81286. * Event raised when the texture is generated
  81287. */
  81288. onGeneratedObservable: Observable<ProceduralTexture>;
  81289. /** @hidden */
  81290. _generateMipMaps: boolean;
  81291. /** @hidden **/
  81292. _effect: Effect;
  81293. /** @hidden */
  81294. _textures: {
  81295. [key: string]: Texture;
  81296. };
  81297. private _size;
  81298. private _currentRefreshId;
  81299. private _refreshRate;
  81300. private _vertexBuffers;
  81301. private _indexBuffer;
  81302. private _uniforms;
  81303. private _samplers;
  81304. private _fragment;
  81305. private _floats;
  81306. private _ints;
  81307. private _floatsArrays;
  81308. private _colors3;
  81309. private _colors4;
  81310. private _vectors2;
  81311. private _vectors3;
  81312. private _matrices;
  81313. private _fallbackTexture;
  81314. private _fallbackTextureUsed;
  81315. private _engine;
  81316. private _cachedDefines;
  81317. private _contentUpdateId;
  81318. private _contentData;
  81319. /**
  81320. * Instantiates a new procedural texture.
  81321. * 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.
  81322. * This is the base class of any Procedural texture and contains most of the shareable code.
  81323. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81324. * @param name Define the name of the texture
  81325. * @param size Define the size of the texture to create
  81326. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81327. * @param scene Define the scene the texture belongs to
  81328. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81329. * @param generateMipMaps Define if the texture should creates mip maps or not
  81330. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81331. */
  81332. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81333. /**
  81334. * The effect that is created when initializing the post process.
  81335. * @returns The created effect corresponding the the postprocess.
  81336. */
  81337. getEffect(): Effect;
  81338. /**
  81339. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81340. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81341. */
  81342. getContent(): Nullable<ArrayBufferView>;
  81343. private _createIndexBuffer;
  81344. /** @hidden */
  81345. _rebuild(): void;
  81346. /**
  81347. * Resets the texture in order to recreate its associated resources.
  81348. * This can be called in case of context loss
  81349. */
  81350. reset(): void;
  81351. protected _getDefines(): string;
  81352. /**
  81353. * Is the texture ready to be used ? (rendered at least once)
  81354. * @returns true if ready, otherwise, false.
  81355. */
  81356. isReady(): boolean;
  81357. /**
  81358. * Resets the refresh counter of the texture and start bak from scratch.
  81359. * Could be useful to regenerate the texture if it is setup to render only once.
  81360. */
  81361. resetRefreshCounter(): void;
  81362. /**
  81363. * Set the fragment shader to use in order to render the texture.
  81364. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81365. */
  81366. setFragment(fragment: any): void;
  81367. /**
  81368. * Define the refresh rate of the texture or the rendering frequency.
  81369. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81370. */
  81371. refreshRate: number;
  81372. /** @hidden */
  81373. _shouldRender(): boolean;
  81374. /**
  81375. * Get the size the texture is rendering at.
  81376. * @returns the size (texture is always squared)
  81377. */
  81378. getRenderSize(): number;
  81379. /**
  81380. * Resize the texture to new value.
  81381. * @param size Define the new size the texture should have
  81382. * @param generateMipMaps Define whether the new texture should create mip maps
  81383. */
  81384. resize(size: number, generateMipMaps: boolean): void;
  81385. private _checkUniform;
  81386. /**
  81387. * Set a texture in the shader program used to render.
  81388. * @param name Define the name of the uniform samplers as defined in the shader
  81389. * @param texture Define the texture to bind to this sampler
  81390. * @return the texture itself allowing "fluent" like uniform updates
  81391. */
  81392. setTexture(name: string, texture: Texture): ProceduralTexture;
  81393. /**
  81394. * Set a float in the shader.
  81395. * @param name Define the name of the uniform as defined in the shader
  81396. * @param value Define the value to give to the uniform
  81397. * @return the texture itself allowing "fluent" like uniform updates
  81398. */
  81399. setFloat(name: string, value: number): ProceduralTexture;
  81400. /**
  81401. * Set a int in the shader.
  81402. * @param name Define the name of the uniform as defined in the shader
  81403. * @param value Define the value to give to the uniform
  81404. * @return the texture itself allowing "fluent" like uniform updates
  81405. */
  81406. setInt(name: string, value: number): ProceduralTexture;
  81407. /**
  81408. * Set an array of floats in the shader.
  81409. * @param name Define the name of the uniform as defined in the shader
  81410. * @param value Define the value to give to the uniform
  81411. * @return the texture itself allowing "fluent" like uniform updates
  81412. */
  81413. setFloats(name: string, value: number[]): ProceduralTexture;
  81414. /**
  81415. * Set a vec3 in the shader from a Color3.
  81416. * @param name Define the name of the uniform as defined in the shader
  81417. * @param value Define the value to give to the uniform
  81418. * @return the texture itself allowing "fluent" like uniform updates
  81419. */
  81420. setColor3(name: string, value: Color3): ProceduralTexture;
  81421. /**
  81422. * Set a vec4 in the shader from a Color4.
  81423. * @param name Define the name of the uniform as defined in the shader
  81424. * @param value Define the value to give to the uniform
  81425. * @return the texture itself allowing "fluent" like uniform updates
  81426. */
  81427. setColor4(name: string, value: Color4): ProceduralTexture;
  81428. /**
  81429. * Set a vec2 in the shader from a Vector2.
  81430. * @param name Define the name of the uniform as defined in the shader
  81431. * @param value Define the value to give to the uniform
  81432. * @return the texture itself allowing "fluent" like uniform updates
  81433. */
  81434. setVector2(name: string, value: Vector2): ProceduralTexture;
  81435. /**
  81436. * Set a vec3 in the shader from a Vector3.
  81437. * @param name Define the name of the uniform as defined in the shader
  81438. * @param value Define the value to give to the uniform
  81439. * @return the texture itself allowing "fluent" like uniform updates
  81440. */
  81441. setVector3(name: string, value: Vector3): ProceduralTexture;
  81442. /**
  81443. * Set a mat4 in the shader from a MAtrix.
  81444. * @param name Define the name of the uniform as defined in the shader
  81445. * @param value Define the value to give to the uniform
  81446. * @return the texture itself allowing "fluent" like uniform updates
  81447. */
  81448. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81449. /**
  81450. * Render the texture to its associated render target.
  81451. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81452. */
  81453. render(useCameraPostProcess?: boolean): void;
  81454. /**
  81455. * Clone the texture.
  81456. * @returns the cloned texture
  81457. */
  81458. clone(): ProceduralTexture;
  81459. /**
  81460. * Dispose the texture and release its asoociated resources.
  81461. */
  81462. dispose(): void;
  81463. }
  81464. }
  81465. declare module BABYLON {
  81466. /**
  81467. * This represents the base class for particle system in Babylon.
  81468. * 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.
  81469. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81470. * @example https://doc.babylonjs.com/babylon101/particles
  81471. */
  81472. export class BaseParticleSystem {
  81473. /**
  81474. * Source color is added to the destination color without alpha affecting the result
  81475. */
  81476. static BLENDMODE_ONEONE: number;
  81477. /**
  81478. * Blend current color and particle color using particle’s alpha
  81479. */
  81480. static BLENDMODE_STANDARD: number;
  81481. /**
  81482. * Add current color and particle color multiplied by particle’s alpha
  81483. */
  81484. static BLENDMODE_ADD: number;
  81485. /**
  81486. * Multiply current color with particle color
  81487. */
  81488. static BLENDMODE_MULTIPLY: number;
  81489. /**
  81490. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81491. */
  81492. static BLENDMODE_MULTIPLYADD: number;
  81493. /**
  81494. * List of animations used by the particle system.
  81495. */
  81496. animations: Animation[];
  81497. /**
  81498. * The id of the Particle system.
  81499. */
  81500. id: string;
  81501. /**
  81502. * The friendly name of the Particle system.
  81503. */
  81504. name: string;
  81505. /**
  81506. * The rendering group used by the Particle system to chose when to render.
  81507. */
  81508. renderingGroupId: number;
  81509. /**
  81510. * The emitter represents the Mesh or position we are attaching the particle system to.
  81511. */
  81512. emitter: Nullable<AbstractMesh | Vector3>;
  81513. /**
  81514. * The maximum number of particles to emit per frame
  81515. */
  81516. emitRate: number;
  81517. /**
  81518. * If you want to launch only a few particles at once, that can be done, as well.
  81519. */
  81520. manualEmitCount: number;
  81521. /**
  81522. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81523. */
  81524. updateSpeed: number;
  81525. /**
  81526. * The amount of time the particle system is running (depends of the overall update speed).
  81527. */
  81528. targetStopDuration: number;
  81529. /**
  81530. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81531. */
  81532. disposeOnStop: boolean;
  81533. /**
  81534. * Minimum power of emitting particles.
  81535. */
  81536. minEmitPower: number;
  81537. /**
  81538. * Maximum power of emitting particles.
  81539. */
  81540. maxEmitPower: number;
  81541. /**
  81542. * Minimum life time of emitting particles.
  81543. */
  81544. minLifeTime: number;
  81545. /**
  81546. * Maximum life time of emitting particles.
  81547. */
  81548. maxLifeTime: number;
  81549. /**
  81550. * Minimum Size of emitting particles.
  81551. */
  81552. minSize: number;
  81553. /**
  81554. * Maximum Size of emitting particles.
  81555. */
  81556. maxSize: number;
  81557. /**
  81558. * Minimum scale of emitting particles on X axis.
  81559. */
  81560. minScaleX: number;
  81561. /**
  81562. * Maximum scale of emitting particles on X axis.
  81563. */
  81564. maxScaleX: number;
  81565. /**
  81566. * Minimum scale of emitting particles on Y axis.
  81567. */
  81568. minScaleY: number;
  81569. /**
  81570. * Maximum scale of emitting particles on Y axis.
  81571. */
  81572. maxScaleY: number;
  81573. /**
  81574. * Gets or sets the minimal initial rotation in radians.
  81575. */
  81576. minInitialRotation: number;
  81577. /**
  81578. * Gets or sets the maximal initial rotation in radians.
  81579. */
  81580. maxInitialRotation: number;
  81581. /**
  81582. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81583. */
  81584. minAngularSpeed: number;
  81585. /**
  81586. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81587. */
  81588. maxAngularSpeed: number;
  81589. /**
  81590. * The texture used to render each particle. (this can be a spritesheet)
  81591. */
  81592. particleTexture: Nullable<Texture>;
  81593. /**
  81594. * The layer mask we are rendering the particles through.
  81595. */
  81596. layerMask: number;
  81597. /**
  81598. * This can help using your own shader to render the particle system.
  81599. * The according effect will be created
  81600. */
  81601. customShader: any;
  81602. /**
  81603. * By default particle system starts as soon as they are created. This prevents the
  81604. * automatic start to happen and let you decide when to start emitting particles.
  81605. */
  81606. preventAutoStart: boolean;
  81607. private _noiseTexture;
  81608. /**
  81609. * Gets or sets a texture used to add random noise to particle positions
  81610. */
  81611. noiseTexture: Nullable<ProceduralTexture>;
  81612. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81613. noiseStrength: Vector3;
  81614. /**
  81615. * Callback triggered when the particle animation is ending.
  81616. */
  81617. onAnimationEnd: Nullable<() => void>;
  81618. /**
  81619. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81620. */
  81621. blendMode: number;
  81622. /**
  81623. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81624. * to override the particles.
  81625. */
  81626. forceDepthWrite: boolean;
  81627. /** 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 */
  81628. preWarmCycles: number;
  81629. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81630. preWarmStepOffset: number;
  81631. /**
  81632. * 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)
  81633. */
  81634. spriteCellChangeSpeed: number;
  81635. /**
  81636. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81637. */
  81638. startSpriteCellID: number;
  81639. /**
  81640. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81641. */
  81642. endSpriteCellID: number;
  81643. /**
  81644. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81645. */
  81646. spriteCellWidth: number;
  81647. /**
  81648. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81649. */
  81650. spriteCellHeight: number;
  81651. /**
  81652. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81653. */
  81654. spriteRandomStartCell: boolean;
  81655. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81656. translationPivot: Vector2;
  81657. /** @hidden */
  81658. protected _isAnimationSheetEnabled: boolean;
  81659. /**
  81660. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81661. */
  81662. beginAnimationOnStart: boolean;
  81663. /**
  81664. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81665. */
  81666. beginAnimationFrom: number;
  81667. /**
  81668. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81669. */
  81670. beginAnimationTo: number;
  81671. /**
  81672. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81673. */
  81674. beginAnimationLoop: boolean;
  81675. /**
  81676. * Gets or sets a world offset applied to all particles
  81677. */
  81678. worldOffset: Vector3;
  81679. /**
  81680. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81681. */
  81682. isAnimationSheetEnabled: boolean;
  81683. /**
  81684. * Get hosting scene
  81685. * @returns the scene
  81686. */
  81687. getScene(): Scene;
  81688. /**
  81689. * You can use gravity if you want to give an orientation to your particles.
  81690. */
  81691. gravity: Vector3;
  81692. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81693. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81694. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81695. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81696. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81697. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81698. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81699. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81700. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81701. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81702. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81703. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81704. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81705. /**
  81706. * Defines the delay in milliseconds before starting the system (0 by default)
  81707. */
  81708. startDelay: number;
  81709. /**
  81710. * Gets the current list of drag gradients.
  81711. * You must use addDragGradient and removeDragGradient to udpate this list
  81712. * @returns the list of drag gradients
  81713. */
  81714. getDragGradients(): Nullable<Array<FactorGradient>>;
  81715. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81716. limitVelocityDamping: number;
  81717. /**
  81718. * Gets the current list of limit velocity gradients.
  81719. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81720. * @returns the list of limit velocity gradients
  81721. */
  81722. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81723. /**
  81724. * Gets the current list of color gradients.
  81725. * You must use addColorGradient and removeColorGradient to udpate this list
  81726. * @returns the list of color gradients
  81727. */
  81728. getColorGradients(): Nullable<Array<ColorGradient>>;
  81729. /**
  81730. * Gets the current list of size gradients.
  81731. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81732. * @returns the list of size gradients
  81733. */
  81734. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81735. /**
  81736. * Gets the current list of color remap gradients.
  81737. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81738. * @returns the list of color remap gradients
  81739. */
  81740. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81741. /**
  81742. * Gets the current list of alpha remap gradients.
  81743. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81744. * @returns the list of alpha remap gradients
  81745. */
  81746. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81747. /**
  81748. * Gets the current list of life time gradients.
  81749. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81750. * @returns the list of life time gradients
  81751. */
  81752. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81753. /**
  81754. * Gets the current list of angular speed gradients.
  81755. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81756. * @returns the list of angular speed gradients
  81757. */
  81758. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81759. /**
  81760. * Gets the current list of velocity gradients.
  81761. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81762. * @returns the list of velocity gradients
  81763. */
  81764. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81765. /**
  81766. * Gets the current list of start size gradients.
  81767. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81768. * @returns the list of start size gradients
  81769. */
  81770. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81771. /**
  81772. * Gets the current list of emit rate gradients.
  81773. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81774. * @returns the list of emit rate gradients
  81775. */
  81776. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81777. /**
  81778. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81779. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81780. */
  81781. direction1: Vector3;
  81782. /**
  81783. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81784. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81785. */
  81786. direction2: Vector3;
  81787. /**
  81788. * 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.
  81789. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81790. */
  81791. minEmitBox: Vector3;
  81792. /**
  81793. * 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.
  81794. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81795. */
  81796. maxEmitBox: Vector3;
  81797. /**
  81798. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81799. */
  81800. color1: Color4;
  81801. /**
  81802. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81803. */
  81804. color2: Color4;
  81805. /**
  81806. * Color the particle will have at the end of its lifetime
  81807. */
  81808. colorDead: Color4;
  81809. /**
  81810. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81811. */
  81812. textureMask: Color4;
  81813. /**
  81814. * The particle emitter type defines the emitter used by the particle system.
  81815. * It can be for example box, sphere, or cone...
  81816. */
  81817. particleEmitterType: IParticleEmitterType;
  81818. /** @hidden */
  81819. _isSubEmitter: boolean;
  81820. /**
  81821. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81822. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81823. */
  81824. billboardMode: number;
  81825. protected _isBillboardBased: boolean;
  81826. /**
  81827. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81828. */
  81829. isBillboardBased: boolean;
  81830. /**
  81831. * The scene the particle system belongs to.
  81832. */
  81833. protected _scene: Scene;
  81834. /**
  81835. * Local cache of defines for image processing.
  81836. */
  81837. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81838. /**
  81839. * Default configuration related to image processing available in the standard Material.
  81840. */
  81841. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81842. /**
  81843. * Gets the image processing configuration used either in this material.
  81844. */
  81845. /**
  81846. * Sets the Default image processing configuration used either in the this material.
  81847. *
  81848. * If sets to null, the scene one is in use.
  81849. */
  81850. imageProcessingConfiguration: ImageProcessingConfiguration;
  81851. /**
  81852. * Attaches a new image processing configuration to the Standard Material.
  81853. * @param configuration
  81854. */
  81855. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81856. /** @hidden */
  81857. protected _reset(): void;
  81858. /** @hidden */
  81859. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81860. /**
  81861. * Instantiates a particle system.
  81862. * 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.
  81863. * @param name The name of the particle system
  81864. */
  81865. constructor(name: string);
  81866. /**
  81867. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81868. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81869. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81870. * @returns the emitter
  81871. */
  81872. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81873. /**
  81874. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81875. * @param radius The radius of the hemisphere to emit from
  81876. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81877. * @returns the emitter
  81878. */
  81879. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81880. /**
  81881. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81882. * @param radius The radius of the sphere to emit from
  81883. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81884. * @returns the emitter
  81885. */
  81886. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81887. /**
  81888. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81889. * @param radius The radius of the sphere to emit from
  81890. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81891. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81892. * @returns the emitter
  81893. */
  81894. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81895. /**
  81896. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81897. * @param radius The radius of the emission cylinder
  81898. * @param height The height of the emission cylinder
  81899. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81900. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81901. * @returns the emitter
  81902. */
  81903. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81904. /**
  81905. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81906. * @param radius The radius of the cylinder to emit from
  81907. * @param height The height of the emission cylinder
  81908. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81909. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81910. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81911. * @returns the emitter
  81912. */
  81913. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81914. /**
  81915. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81916. * @param radius The radius of the cone to emit from
  81917. * @param angle The base angle of the cone
  81918. * @returns the emitter
  81919. */
  81920. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81921. /**
  81922. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81923. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81924. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81925. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81926. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81927. * @returns the emitter
  81928. */
  81929. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  81930. }
  81931. }
  81932. declare module BABYLON {
  81933. /**
  81934. * Type of sub emitter
  81935. */
  81936. export enum SubEmitterType {
  81937. /**
  81938. * Attached to the particle over it's lifetime
  81939. */
  81940. ATTACHED = 0,
  81941. /**
  81942. * Created when the particle dies
  81943. */
  81944. END = 1
  81945. }
  81946. /**
  81947. * Sub emitter class used to emit particles from an existing particle
  81948. */
  81949. export class SubEmitter {
  81950. /**
  81951. * the particle system to be used by the sub emitter
  81952. */
  81953. particleSystem: ParticleSystem;
  81954. /**
  81955. * Type of the submitter (Default: END)
  81956. */
  81957. type: SubEmitterType;
  81958. /**
  81959. * 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)
  81960. * Note: This only is supported when using an emitter of type Mesh
  81961. */
  81962. inheritDirection: boolean;
  81963. /**
  81964. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  81965. */
  81966. inheritedVelocityAmount: number;
  81967. /**
  81968. * Creates a sub emitter
  81969. * @param particleSystem the particle system to be used by the sub emitter
  81970. */
  81971. constructor(
  81972. /**
  81973. * the particle system to be used by the sub emitter
  81974. */
  81975. particleSystem: ParticleSystem);
  81976. /**
  81977. * Clones the sub emitter
  81978. * @returns the cloned sub emitter
  81979. */
  81980. clone(): SubEmitter;
  81981. /**
  81982. * Serialize current object to a JSON object
  81983. * @returns the serialized object
  81984. */
  81985. serialize(): any;
  81986. /** @hidden */
  81987. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  81988. /**
  81989. * Creates a new SubEmitter from a serialized JSON version
  81990. * @param serializationObject defines the JSON object to read from
  81991. * @param scene defines the hosting scene
  81992. * @param rootUrl defines the rootUrl for data loading
  81993. * @returns a new SubEmitter
  81994. */
  81995. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  81996. /** Release associated resources */
  81997. dispose(): void;
  81998. }
  81999. }
  82000. declare module BABYLON {
  82001. /** @hidden */
  82002. export var imageProcessingDeclaration: {
  82003. name: string;
  82004. shader: string;
  82005. };
  82006. }
  82007. declare module BABYLON {
  82008. /** @hidden */
  82009. export var imageProcessingFunctions: {
  82010. name: string;
  82011. shader: string;
  82012. };
  82013. }
  82014. declare module BABYLON {
  82015. /** @hidden */
  82016. export var particlesPixelShader: {
  82017. name: string;
  82018. shader: string;
  82019. };
  82020. }
  82021. declare module BABYLON {
  82022. /** @hidden */
  82023. export var particlesVertexShader: {
  82024. name: string;
  82025. shader: string;
  82026. };
  82027. }
  82028. declare module BABYLON {
  82029. /**
  82030. * This represents a particle system in Babylon.
  82031. * 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.
  82032. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82033. * @example https://doc.babylonjs.com/babylon101/particles
  82034. */
  82035. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82036. /**
  82037. * Billboard mode will only apply to Y axis
  82038. */
  82039. static readonly BILLBOARDMODE_Y: number;
  82040. /**
  82041. * Billboard mode will apply to all axes
  82042. */
  82043. static readonly BILLBOARDMODE_ALL: number;
  82044. /**
  82045. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82046. */
  82047. static readonly BILLBOARDMODE_STRETCHED: number;
  82048. /**
  82049. * This function can be defined to provide custom update for active particles.
  82050. * This function will be called instead of regular update (age, position, color, etc.).
  82051. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82052. */
  82053. updateFunction: (particles: Particle[]) => void;
  82054. private _emitterWorldMatrix;
  82055. /**
  82056. * This function can be defined to specify initial direction for every new particle.
  82057. * It by default use the emitterType defined function
  82058. */
  82059. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82060. /**
  82061. * This function can be defined to specify initial position for every new particle.
  82062. * It by default use the emitterType defined function
  82063. */
  82064. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82065. /**
  82066. * @hidden
  82067. */
  82068. _inheritedVelocityOffset: Vector3;
  82069. /**
  82070. * An event triggered when the system is disposed
  82071. */
  82072. onDisposeObservable: Observable<ParticleSystem>;
  82073. private _onDisposeObserver;
  82074. /**
  82075. * Sets a callback that will be triggered when the system is disposed
  82076. */
  82077. onDispose: () => void;
  82078. private _particles;
  82079. private _epsilon;
  82080. private _capacity;
  82081. private _stockParticles;
  82082. private _newPartsExcess;
  82083. private _vertexData;
  82084. private _vertexBuffer;
  82085. private _vertexBuffers;
  82086. private _spriteBuffer;
  82087. private _indexBuffer;
  82088. private _effect;
  82089. private _customEffect;
  82090. private _cachedDefines;
  82091. private _scaledColorStep;
  82092. private _colorDiff;
  82093. private _scaledDirection;
  82094. private _scaledGravity;
  82095. private _currentRenderId;
  82096. private _alive;
  82097. private _useInstancing;
  82098. private _started;
  82099. private _stopped;
  82100. private _actualFrame;
  82101. private _scaledUpdateSpeed;
  82102. private _vertexBufferSize;
  82103. /** @hidden */
  82104. _currentEmitRateGradient: Nullable<FactorGradient>;
  82105. /** @hidden */
  82106. _currentEmitRate1: number;
  82107. /** @hidden */
  82108. _currentEmitRate2: number;
  82109. /** @hidden */
  82110. _currentStartSizeGradient: Nullable<FactorGradient>;
  82111. /** @hidden */
  82112. _currentStartSize1: number;
  82113. /** @hidden */
  82114. _currentStartSize2: number;
  82115. private readonly _rawTextureWidth;
  82116. private _rampGradientsTexture;
  82117. private _useRampGradients;
  82118. /** Gets or sets a boolean indicating that ramp gradients must be used
  82119. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82120. */
  82121. useRampGradients: boolean;
  82122. /**
  82123. * 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.
  82124. * 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: [])
  82125. */
  82126. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82127. private _subEmitters;
  82128. /**
  82129. * @hidden
  82130. * If the particle systems emitter should be disposed when the particle system is disposed
  82131. */
  82132. _disposeEmitterOnDispose: boolean;
  82133. /**
  82134. * The current active Sub-systems, this property is used by the root particle system only.
  82135. */
  82136. activeSubSystems: Array<ParticleSystem>;
  82137. private _rootParticleSystem;
  82138. /**
  82139. * Gets the current list of active particles
  82140. */
  82141. readonly particles: Particle[];
  82142. /**
  82143. * Returns the string "ParticleSystem"
  82144. * @returns a string containing the class name
  82145. */
  82146. getClassName(): string;
  82147. /**
  82148. * Instantiates a particle system.
  82149. * 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.
  82150. * @param name The name of the particle system
  82151. * @param capacity The max number of particles alive at the same time
  82152. * @param scene The scene the particle system belongs to
  82153. * @param customEffect a custom effect used to change the way particles are rendered by default
  82154. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82155. * @param epsilon Offset used to render the particles
  82156. */
  82157. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82158. private _addFactorGradient;
  82159. private _removeFactorGradient;
  82160. /**
  82161. * Adds a new life time gradient
  82162. * @param gradient defines the gradient to use (between 0 and 1)
  82163. * @param factor defines the life time factor to affect to the specified gradient
  82164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82165. * @returns the current particle system
  82166. */
  82167. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82168. /**
  82169. * Remove a specific life time gradient
  82170. * @param gradient defines the gradient to remove
  82171. * @returns the current particle system
  82172. */
  82173. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82174. /**
  82175. * Adds a new size gradient
  82176. * @param gradient defines the gradient to use (between 0 and 1)
  82177. * @param factor defines the size factor to affect to the specified gradient
  82178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82179. * @returns the current particle system
  82180. */
  82181. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82182. /**
  82183. * Remove a specific size gradient
  82184. * @param gradient defines the gradient to remove
  82185. * @returns the current particle system
  82186. */
  82187. removeSizeGradient(gradient: number): IParticleSystem;
  82188. /**
  82189. * Adds a new color remap gradient
  82190. * @param gradient defines the gradient to use (between 0 and 1)
  82191. * @param min defines the color remap minimal range
  82192. * @param max defines the color remap maximal range
  82193. * @returns the current particle system
  82194. */
  82195. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82196. /**
  82197. * Remove a specific color remap gradient
  82198. * @param gradient defines the gradient to remove
  82199. * @returns the current particle system
  82200. */
  82201. removeColorRemapGradient(gradient: number): IParticleSystem;
  82202. /**
  82203. * Adds a new alpha remap gradient
  82204. * @param gradient defines the gradient to use (between 0 and 1)
  82205. * @param min defines the alpha remap minimal range
  82206. * @param max defines the alpha remap maximal range
  82207. * @returns the current particle system
  82208. */
  82209. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82210. /**
  82211. * Remove a specific alpha remap gradient
  82212. * @param gradient defines the gradient to remove
  82213. * @returns the current particle system
  82214. */
  82215. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82216. /**
  82217. * Adds a new angular speed gradient
  82218. * @param gradient defines the gradient to use (between 0 and 1)
  82219. * @param factor defines the angular speed to affect to the specified gradient
  82220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82221. * @returns the current particle system
  82222. */
  82223. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82224. /**
  82225. * Remove a specific angular speed gradient
  82226. * @param gradient defines the gradient to remove
  82227. * @returns the current particle system
  82228. */
  82229. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82230. /**
  82231. * Adds a new velocity gradient
  82232. * @param gradient defines the gradient to use (between 0 and 1)
  82233. * @param factor defines the velocity to affect to the specified gradient
  82234. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82235. * @returns the current particle system
  82236. */
  82237. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82238. /**
  82239. * Remove a specific velocity gradient
  82240. * @param gradient defines the gradient to remove
  82241. * @returns the current particle system
  82242. */
  82243. removeVelocityGradient(gradient: number): IParticleSystem;
  82244. /**
  82245. * Adds a new limit velocity gradient
  82246. * @param gradient defines the gradient to use (between 0 and 1)
  82247. * @param factor defines the limit velocity value to affect to the specified gradient
  82248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82249. * @returns the current particle system
  82250. */
  82251. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82252. /**
  82253. * Remove a specific limit velocity gradient
  82254. * @param gradient defines the gradient to remove
  82255. * @returns the current particle system
  82256. */
  82257. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82258. /**
  82259. * Adds a new drag gradient
  82260. * @param gradient defines the gradient to use (between 0 and 1)
  82261. * @param factor defines the drag value to affect to the specified gradient
  82262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82263. * @returns the current particle system
  82264. */
  82265. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82266. /**
  82267. * Remove a specific drag gradient
  82268. * @param gradient defines the gradient to remove
  82269. * @returns the current particle system
  82270. */
  82271. removeDragGradient(gradient: number): IParticleSystem;
  82272. /**
  82273. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82274. * @param gradient defines the gradient to use (between 0 and 1)
  82275. * @param factor defines the emit rate value to affect to the specified gradient
  82276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82277. * @returns the current particle system
  82278. */
  82279. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82280. /**
  82281. * Remove a specific emit rate gradient
  82282. * @param gradient defines the gradient to remove
  82283. * @returns the current particle system
  82284. */
  82285. removeEmitRateGradient(gradient: number): IParticleSystem;
  82286. /**
  82287. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82288. * @param gradient defines the gradient to use (between 0 and 1)
  82289. * @param factor defines the start size value to affect to the specified gradient
  82290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82291. * @returns the current particle system
  82292. */
  82293. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82294. /**
  82295. * Remove a specific start size gradient
  82296. * @param gradient defines the gradient to remove
  82297. * @returns the current particle system
  82298. */
  82299. removeStartSizeGradient(gradient: number): IParticleSystem;
  82300. private _createRampGradientTexture;
  82301. /**
  82302. * Gets the current list of ramp gradients.
  82303. * You must use addRampGradient and removeRampGradient to udpate this list
  82304. * @returns the list of ramp gradients
  82305. */
  82306. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82307. /**
  82308. * Adds a new ramp gradient used to remap particle colors
  82309. * @param gradient defines the gradient to use (between 0 and 1)
  82310. * @param color defines the color to affect to the specified gradient
  82311. * @returns the current particle system
  82312. */
  82313. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82314. /**
  82315. * Remove a specific ramp gradient
  82316. * @param gradient defines the gradient to remove
  82317. * @returns the current particle system
  82318. */
  82319. removeRampGradient(gradient: number): ParticleSystem;
  82320. /**
  82321. * Adds a new color gradient
  82322. * @param gradient defines the gradient to use (between 0 and 1)
  82323. * @param color1 defines the color to affect to the specified gradient
  82324. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82325. * @returns this particle system
  82326. */
  82327. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82328. /**
  82329. * Remove a specific color gradient
  82330. * @param gradient defines the gradient to remove
  82331. * @returns this particle system
  82332. */
  82333. removeColorGradient(gradient: number): IParticleSystem;
  82334. private _fetchR;
  82335. protected _reset(): void;
  82336. private _resetEffect;
  82337. private _createVertexBuffers;
  82338. private _createIndexBuffer;
  82339. /**
  82340. * Gets the maximum number of particles active at the same time.
  82341. * @returns The max number of active particles.
  82342. */
  82343. getCapacity(): number;
  82344. /**
  82345. * Gets whether there are still active particles in the system.
  82346. * @returns True if it is alive, otherwise false.
  82347. */
  82348. isAlive(): boolean;
  82349. /**
  82350. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82351. * @returns True if it has been started, otherwise false.
  82352. */
  82353. isStarted(): boolean;
  82354. private _prepareSubEmitterInternalArray;
  82355. /**
  82356. * Starts the particle system and begins to emit
  82357. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82358. */
  82359. start(delay?: number): void;
  82360. /**
  82361. * Stops the particle system.
  82362. * @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.
  82363. */
  82364. stop(stopSubEmitters?: boolean): void;
  82365. /**
  82366. * Remove all active particles
  82367. */
  82368. reset(): void;
  82369. /**
  82370. * @hidden (for internal use only)
  82371. */
  82372. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82373. /**
  82374. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82375. * Its lifetime will start back at 0.
  82376. */
  82377. recycleParticle: (particle: Particle) => void;
  82378. private _stopSubEmitters;
  82379. private _createParticle;
  82380. private _removeFromRoot;
  82381. private _emitFromParticle;
  82382. private _update;
  82383. /** @hidden */
  82384. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82385. /** @hidden */
  82386. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82387. /** @hidden */
  82388. private _getEffect;
  82389. /**
  82390. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82391. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82392. */
  82393. animate(preWarmOnly?: boolean): void;
  82394. private _appendParticleVertices;
  82395. /**
  82396. * Rebuilds the particle system.
  82397. */
  82398. rebuild(): void;
  82399. /**
  82400. * Is this system ready to be used/rendered
  82401. * @return true if the system is ready
  82402. */
  82403. isReady(): boolean;
  82404. private _render;
  82405. /**
  82406. * Renders the particle system in its current state.
  82407. * @returns the current number of particles
  82408. */
  82409. render(): number;
  82410. /**
  82411. * Disposes the particle system and free the associated resources
  82412. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82413. */
  82414. dispose(disposeTexture?: boolean): void;
  82415. /**
  82416. * Clones the particle system.
  82417. * @param name The name of the cloned object
  82418. * @param newEmitter The new emitter to use
  82419. * @returns the cloned particle system
  82420. */
  82421. clone(name: string, newEmitter: any): ParticleSystem;
  82422. /**
  82423. * Serializes the particle system to a JSON object.
  82424. * @returns the JSON object
  82425. */
  82426. serialize(): any;
  82427. /** @hidden */
  82428. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82429. /** @hidden */
  82430. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82431. /**
  82432. * Parses a JSON object to create a particle system.
  82433. * @param parsedParticleSystem The JSON object to parse
  82434. * @param scene The scene to create the particle system in
  82435. * @param rootUrl The root url to use to load external dependencies like texture
  82436. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82437. * @returns the Parsed particle system
  82438. */
  82439. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82440. }
  82441. }
  82442. declare module BABYLON {
  82443. /**
  82444. * A particle represents one of the element emitted by a particle system.
  82445. * This is mainly define by its coordinates, direction, velocity and age.
  82446. */
  82447. export class Particle {
  82448. /**
  82449. * The particle system the particle belongs to.
  82450. */
  82451. particleSystem: ParticleSystem;
  82452. private static _Count;
  82453. /**
  82454. * Unique ID of the particle
  82455. */
  82456. id: number;
  82457. /**
  82458. * The world position of the particle in the scene.
  82459. */
  82460. position: Vector3;
  82461. /**
  82462. * The world direction of the particle in the scene.
  82463. */
  82464. direction: Vector3;
  82465. /**
  82466. * The color of the particle.
  82467. */
  82468. color: Color4;
  82469. /**
  82470. * The color change of the particle per step.
  82471. */
  82472. colorStep: Color4;
  82473. /**
  82474. * Defines how long will the life of the particle be.
  82475. */
  82476. lifeTime: number;
  82477. /**
  82478. * The current age of the particle.
  82479. */
  82480. age: number;
  82481. /**
  82482. * The current size of the particle.
  82483. */
  82484. size: number;
  82485. /**
  82486. * The current scale of the particle.
  82487. */
  82488. scale: Vector2;
  82489. /**
  82490. * The current angle of the particle.
  82491. */
  82492. angle: number;
  82493. /**
  82494. * Defines how fast is the angle changing.
  82495. */
  82496. angularSpeed: number;
  82497. /**
  82498. * Defines the cell index used by the particle to be rendered from a sprite.
  82499. */
  82500. cellIndex: number;
  82501. /**
  82502. * The information required to support color remapping
  82503. */
  82504. remapData: Vector4;
  82505. /** @hidden */
  82506. _randomCellOffset?: number;
  82507. /** @hidden */
  82508. _initialDirection: Nullable<Vector3>;
  82509. /** @hidden */
  82510. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82511. /** @hidden */
  82512. _initialStartSpriteCellID: number;
  82513. /** @hidden */
  82514. _initialEndSpriteCellID: number;
  82515. /** @hidden */
  82516. _currentColorGradient: Nullable<ColorGradient>;
  82517. /** @hidden */
  82518. _currentColor1: Color4;
  82519. /** @hidden */
  82520. _currentColor2: Color4;
  82521. /** @hidden */
  82522. _currentSizeGradient: Nullable<FactorGradient>;
  82523. /** @hidden */
  82524. _currentSize1: number;
  82525. /** @hidden */
  82526. _currentSize2: number;
  82527. /** @hidden */
  82528. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82529. /** @hidden */
  82530. _currentAngularSpeed1: number;
  82531. /** @hidden */
  82532. _currentAngularSpeed2: number;
  82533. /** @hidden */
  82534. _currentVelocityGradient: Nullable<FactorGradient>;
  82535. /** @hidden */
  82536. _currentVelocity1: number;
  82537. /** @hidden */
  82538. _currentVelocity2: number;
  82539. /** @hidden */
  82540. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82541. /** @hidden */
  82542. _currentLimitVelocity1: number;
  82543. /** @hidden */
  82544. _currentLimitVelocity2: number;
  82545. /** @hidden */
  82546. _currentDragGradient: Nullable<FactorGradient>;
  82547. /** @hidden */
  82548. _currentDrag1: number;
  82549. /** @hidden */
  82550. _currentDrag2: number;
  82551. /** @hidden */
  82552. _randomNoiseCoordinates1: Vector3;
  82553. /** @hidden */
  82554. _randomNoiseCoordinates2: Vector3;
  82555. /**
  82556. * Creates a new instance Particle
  82557. * @param particleSystem the particle system the particle belongs to
  82558. */
  82559. constructor(
  82560. /**
  82561. * The particle system the particle belongs to.
  82562. */
  82563. particleSystem: ParticleSystem);
  82564. private updateCellInfoFromSystem;
  82565. /**
  82566. * Defines how the sprite cell index is updated for the particle
  82567. */
  82568. updateCellIndex(): void;
  82569. /** @hidden */
  82570. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82571. /** @hidden */
  82572. _inheritParticleInfoToSubEmitters(): void;
  82573. /** @hidden */
  82574. _reset(): void;
  82575. /**
  82576. * Copy the properties of particle to another one.
  82577. * @param other the particle to copy the information to.
  82578. */
  82579. copyTo(other: Particle): void;
  82580. }
  82581. }
  82582. declare module BABYLON {
  82583. /**
  82584. * Particle emitter represents a volume emitting particles.
  82585. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82586. */
  82587. export interface IParticleEmitterType {
  82588. /**
  82589. * Called by the particle System when the direction is computed for the created particle.
  82590. * @param worldMatrix is the world matrix of the particle system
  82591. * @param directionToUpdate is the direction vector to update with the result
  82592. * @param particle is the particle we are computed the direction for
  82593. */
  82594. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82595. /**
  82596. * Called by the particle System when the position is computed for the created particle.
  82597. * @param worldMatrix is the world matrix of the particle system
  82598. * @param positionToUpdate is the position vector to update with the result
  82599. * @param particle is the particle we are computed the position for
  82600. */
  82601. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82602. /**
  82603. * Clones the current emitter and returns a copy of it
  82604. * @returns the new emitter
  82605. */
  82606. clone(): IParticleEmitterType;
  82607. /**
  82608. * Called by the GPUParticleSystem to setup the update shader
  82609. * @param effect defines the update shader
  82610. */
  82611. applyToShader(effect: Effect): void;
  82612. /**
  82613. * Returns a string to use to update the GPU particles update shader
  82614. * @returns the effect defines string
  82615. */
  82616. getEffectDefines(): string;
  82617. /**
  82618. * Returns a string representing the class name
  82619. * @returns a string containing the class name
  82620. */
  82621. getClassName(): string;
  82622. /**
  82623. * Serializes the particle system to a JSON object.
  82624. * @returns the JSON object
  82625. */
  82626. serialize(): any;
  82627. /**
  82628. * Parse properties from a JSON object
  82629. * @param serializationObject defines the JSON object
  82630. */
  82631. parse(serializationObject: any): void;
  82632. }
  82633. }
  82634. declare module BABYLON {
  82635. /**
  82636. * Particle emitter emitting particles from the inside of a box.
  82637. * It emits the particles randomly between 2 given directions.
  82638. */
  82639. export class BoxParticleEmitter implements IParticleEmitterType {
  82640. /**
  82641. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82642. */
  82643. direction1: Vector3;
  82644. /**
  82645. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82646. */
  82647. direction2: Vector3;
  82648. /**
  82649. * 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.
  82650. */
  82651. minEmitBox: Vector3;
  82652. /**
  82653. * 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.
  82654. */
  82655. maxEmitBox: Vector3;
  82656. /**
  82657. * Creates a new instance BoxParticleEmitter
  82658. */
  82659. constructor();
  82660. /**
  82661. * Called by the particle System when the direction is computed for the created particle.
  82662. * @param worldMatrix is the world matrix of the particle system
  82663. * @param directionToUpdate is the direction vector to update with the result
  82664. * @param particle is the particle we are computed the direction for
  82665. */
  82666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82667. /**
  82668. * Called by the particle System when the position is computed for the created particle.
  82669. * @param worldMatrix is the world matrix of the particle system
  82670. * @param positionToUpdate is the position vector to update with the result
  82671. * @param particle is the particle we are computed the position for
  82672. */
  82673. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82674. /**
  82675. * Clones the current emitter and returns a copy of it
  82676. * @returns the new emitter
  82677. */
  82678. clone(): BoxParticleEmitter;
  82679. /**
  82680. * Called by the GPUParticleSystem to setup the update shader
  82681. * @param effect defines the update shader
  82682. */
  82683. applyToShader(effect: Effect): void;
  82684. /**
  82685. * Returns a string to use to update the GPU particles update shader
  82686. * @returns a string containng the defines string
  82687. */
  82688. getEffectDefines(): string;
  82689. /**
  82690. * Returns the string "BoxParticleEmitter"
  82691. * @returns a string containing the class name
  82692. */
  82693. getClassName(): string;
  82694. /**
  82695. * Serializes the particle system to a JSON object.
  82696. * @returns the JSON object
  82697. */
  82698. serialize(): any;
  82699. /**
  82700. * Parse properties from a JSON object
  82701. * @param serializationObject defines the JSON object
  82702. */
  82703. parse(serializationObject: any): void;
  82704. }
  82705. }
  82706. declare module BABYLON {
  82707. /**
  82708. * Particle emitter emitting particles from the inside of a cone.
  82709. * It emits the particles alongside the cone volume from the base to the particle.
  82710. * The emission direction might be randomized.
  82711. */
  82712. export class ConeParticleEmitter implements IParticleEmitterType {
  82713. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82714. directionRandomizer: number;
  82715. private _radius;
  82716. private _angle;
  82717. private _height;
  82718. /**
  82719. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82720. */
  82721. radiusRange: number;
  82722. /**
  82723. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82724. */
  82725. heightRange: number;
  82726. /**
  82727. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82728. */
  82729. emitFromSpawnPointOnly: boolean;
  82730. /**
  82731. * Gets or sets the radius of the emission cone
  82732. */
  82733. radius: number;
  82734. /**
  82735. * Gets or sets the angle of the emission cone
  82736. */
  82737. angle: number;
  82738. private _buildHeight;
  82739. /**
  82740. * Creates a new instance ConeParticleEmitter
  82741. * @param radius the radius of the emission cone (1 by default)
  82742. * @param angle the cone base angle (PI by default)
  82743. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82744. */
  82745. constructor(radius?: number, angle?: number,
  82746. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82747. directionRandomizer?: number);
  82748. /**
  82749. * Called by the particle System when the direction is computed for the created particle.
  82750. * @param worldMatrix is the world matrix of the particle system
  82751. * @param directionToUpdate is the direction vector to update with the result
  82752. * @param particle is the particle we are computed the direction for
  82753. */
  82754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82755. /**
  82756. * Called by the particle System when the position is computed for the created particle.
  82757. * @param worldMatrix is the world matrix of the particle system
  82758. * @param positionToUpdate is the position vector to update with the result
  82759. * @param particle is the particle we are computed the position for
  82760. */
  82761. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82762. /**
  82763. * Clones the current emitter and returns a copy of it
  82764. * @returns the new emitter
  82765. */
  82766. clone(): ConeParticleEmitter;
  82767. /**
  82768. * Called by the GPUParticleSystem to setup the update shader
  82769. * @param effect defines the update shader
  82770. */
  82771. applyToShader(effect: Effect): void;
  82772. /**
  82773. * Returns a string to use to update the GPU particles update shader
  82774. * @returns a string containng the defines string
  82775. */
  82776. getEffectDefines(): string;
  82777. /**
  82778. * Returns the string "ConeParticleEmitter"
  82779. * @returns a string containing the class name
  82780. */
  82781. getClassName(): string;
  82782. /**
  82783. * Serializes the particle system to a JSON object.
  82784. * @returns the JSON object
  82785. */
  82786. serialize(): any;
  82787. /**
  82788. * Parse properties from a JSON object
  82789. * @param serializationObject defines the JSON object
  82790. */
  82791. parse(serializationObject: any): void;
  82792. }
  82793. }
  82794. declare module BABYLON {
  82795. /**
  82796. * Particle emitter emitting particles from the inside of a cylinder.
  82797. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82798. */
  82799. export class CylinderParticleEmitter implements IParticleEmitterType {
  82800. /**
  82801. * The radius of the emission cylinder.
  82802. */
  82803. radius: number;
  82804. /**
  82805. * The height of the emission cylinder.
  82806. */
  82807. height: number;
  82808. /**
  82809. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82810. */
  82811. radiusRange: number;
  82812. /**
  82813. * How much to randomize the particle direction [0-1].
  82814. */
  82815. directionRandomizer: number;
  82816. /**
  82817. * Creates a new instance CylinderParticleEmitter
  82818. * @param radius the radius of the emission cylinder (1 by default)
  82819. * @param height the height of the emission cylinder (1 by default)
  82820. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82821. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82822. */
  82823. constructor(
  82824. /**
  82825. * The radius of the emission cylinder.
  82826. */
  82827. radius?: number,
  82828. /**
  82829. * The height of the emission cylinder.
  82830. */
  82831. height?: number,
  82832. /**
  82833. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82834. */
  82835. radiusRange?: number,
  82836. /**
  82837. * How much to randomize the particle direction [0-1].
  82838. */
  82839. directionRandomizer?: number);
  82840. /**
  82841. * Called by the particle System when the direction is computed for the created particle.
  82842. * @param worldMatrix is the world matrix of the particle system
  82843. * @param directionToUpdate is the direction vector to update with the result
  82844. * @param particle is the particle we are computed the direction for
  82845. */
  82846. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82847. /**
  82848. * Called by the particle System when the position is computed for the created particle.
  82849. * @param worldMatrix is the world matrix of the particle system
  82850. * @param positionToUpdate is the position vector to update with the result
  82851. * @param particle is the particle we are computed the position for
  82852. */
  82853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82854. /**
  82855. * Clones the current emitter and returns a copy of it
  82856. * @returns the new emitter
  82857. */
  82858. clone(): CylinderParticleEmitter;
  82859. /**
  82860. * Called by the GPUParticleSystem to setup the update shader
  82861. * @param effect defines the update shader
  82862. */
  82863. applyToShader(effect: Effect): void;
  82864. /**
  82865. * Returns a string to use to update the GPU particles update shader
  82866. * @returns a string containng the defines string
  82867. */
  82868. getEffectDefines(): string;
  82869. /**
  82870. * Returns the string "CylinderParticleEmitter"
  82871. * @returns a string containing the class name
  82872. */
  82873. getClassName(): string;
  82874. /**
  82875. * Serializes the particle system to a JSON object.
  82876. * @returns the JSON object
  82877. */
  82878. serialize(): any;
  82879. /**
  82880. * Parse properties from a JSON object
  82881. * @param serializationObject defines the JSON object
  82882. */
  82883. parse(serializationObject: any): void;
  82884. }
  82885. /**
  82886. * Particle emitter emitting particles from the inside of a cylinder.
  82887. * It emits the particles randomly between two vectors.
  82888. */
  82889. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82890. /**
  82891. * The min limit of the emission direction.
  82892. */
  82893. direction1: Vector3;
  82894. /**
  82895. * The max limit of the emission direction.
  82896. */
  82897. direction2: Vector3;
  82898. /**
  82899. * Creates a new instance CylinderDirectedParticleEmitter
  82900. * @param radius the radius of the emission cylinder (1 by default)
  82901. * @param height the height of the emission cylinder (1 by default)
  82902. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82903. * @param direction1 the min limit of the emission direction (up vector by default)
  82904. * @param direction2 the max limit of the emission direction (up vector by default)
  82905. */
  82906. constructor(radius?: number, height?: number, radiusRange?: number,
  82907. /**
  82908. * The min limit of the emission direction.
  82909. */
  82910. direction1?: Vector3,
  82911. /**
  82912. * The max limit of the emission direction.
  82913. */
  82914. direction2?: Vector3);
  82915. /**
  82916. * Called by the particle System when the direction is computed for the created particle.
  82917. * @param worldMatrix is the world matrix of the particle system
  82918. * @param directionToUpdate is the direction vector to update with the result
  82919. * @param particle is the particle we are computed the direction for
  82920. */
  82921. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82922. /**
  82923. * Clones the current emitter and returns a copy of it
  82924. * @returns the new emitter
  82925. */
  82926. clone(): CylinderDirectedParticleEmitter;
  82927. /**
  82928. * Called by the GPUParticleSystem to setup the update shader
  82929. * @param effect defines the update shader
  82930. */
  82931. applyToShader(effect: Effect): void;
  82932. /**
  82933. * Returns a string to use to update the GPU particles update shader
  82934. * @returns a string containng the defines string
  82935. */
  82936. getEffectDefines(): string;
  82937. /**
  82938. * Returns the string "CylinderDirectedParticleEmitter"
  82939. * @returns a string containing the class name
  82940. */
  82941. getClassName(): string;
  82942. /**
  82943. * Serializes the particle system to a JSON object.
  82944. * @returns the JSON object
  82945. */
  82946. serialize(): any;
  82947. /**
  82948. * Parse properties from a JSON object
  82949. * @param serializationObject defines the JSON object
  82950. */
  82951. parse(serializationObject: any): void;
  82952. }
  82953. }
  82954. declare module BABYLON {
  82955. /**
  82956. * Particle emitter emitting particles from the inside of a hemisphere.
  82957. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  82958. */
  82959. export class HemisphericParticleEmitter implements IParticleEmitterType {
  82960. /**
  82961. * The radius of the emission hemisphere.
  82962. */
  82963. radius: number;
  82964. /**
  82965. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82966. */
  82967. radiusRange: number;
  82968. /**
  82969. * How much to randomize the particle direction [0-1].
  82970. */
  82971. directionRandomizer: number;
  82972. /**
  82973. * Creates a new instance HemisphericParticleEmitter
  82974. * @param radius the radius of the emission hemisphere (1 by default)
  82975. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82976. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82977. */
  82978. constructor(
  82979. /**
  82980. * The radius of the emission hemisphere.
  82981. */
  82982. radius?: number,
  82983. /**
  82984. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82985. */
  82986. radiusRange?: number,
  82987. /**
  82988. * How much to randomize the particle direction [0-1].
  82989. */
  82990. directionRandomizer?: number);
  82991. /**
  82992. * Called by the particle System when the direction is computed for the created particle.
  82993. * @param worldMatrix is the world matrix of the particle system
  82994. * @param directionToUpdate is the direction vector to update with the result
  82995. * @param particle is the particle we are computed the direction for
  82996. */
  82997. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82998. /**
  82999. * Called by the particle System when the position is computed for the created particle.
  83000. * @param worldMatrix is the world matrix of the particle system
  83001. * @param positionToUpdate is the position vector to update with the result
  83002. * @param particle is the particle we are computed the position for
  83003. */
  83004. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83005. /**
  83006. * Clones the current emitter and returns a copy of it
  83007. * @returns the new emitter
  83008. */
  83009. clone(): HemisphericParticleEmitter;
  83010. /**
  83011. * Called by the GPUParticleSystem to setup the update shader
  83012. * @param effect defines the update shader
  83013. */
  83014. applyToShader(effect: Effect): void;
  83015. /**
  83016. * Returns a string to use to update the GPU particles update shader
  83017. * @returns a string containng the defines string
  83018. */
  83019. getEffectDefines(): string;
  83020. /**
  83021. * Returns the string "HemisphericParticleEmitter"
  83022. * @returns a string containing the class name
  83023. */
  83024. getClassName(): string;
  83025. /**
  83026. * Serializes the particle system to a JSON object.
  83027. * @returns the JSON object
  83028. */
  83029. serialize(): any;
  83030. /**
  83031. * Parse properties from a JSON object
  83032. * @param serializationObject defines the JSON object
  83033. */
  83034. parse(serializationObject: any): void;
  83035. }
  83036. }
  83037. declare module BABYLON {
  83038. /**
  83039. * Particle emitter emitting particles from a point.
  83040. * It emits the particles randomly between 2 given directions.
  83041. */
  83042. export class PointParticleEmitter implements IParticleEmitterType {
  83043. /**
  83044. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83045. */
  83046. direction1: Vector3;
  83047. /**
  83048. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83049. */
  83050. direction2: Vector3;
  83051. /**
  83052. * Creates a new instance PointParticleEmitter
  83053. */
  83054. constructor();
  83055. /**
  83056. * Called by the particle System when the direction is computed for the created particle.
  83057. * @param worldMatrix is the world matrix of the particle system
  83058. * @param directionToUpdate is the direction vector to update with the result
  83059. * @param particle is the particle we are computed the direction for
  83060. */
  83061. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83062. /**
  83063. * Called by the particle System when the position is computed for the created particle.
  83064. * @param worldMatrix is the world matrix of the particle system
  83065. * @param positionToUpdate is the position vector to update with the result
  83066. * @param particle is the particle we are computed the position for
  83067. */
  83068. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83069. /**
  83070. * Clones the current emitter and returns a copy of it
  83071. * @returns the new emitter
  83072. */
  83073. clone(): PointParticleEmitter;
  83074. /**
  83075. * Called by the GPUParticleSystem to setup the update shader
  83076. * @param effect defines the update shader
  83077. */
  83078. applyToShader(effect: Effect): void;
  83079. /**
  83080. * Returns a string to use to update the GPU particles update shader
  83081. * @returns a string containng the defines string
  83082. */
  83083. getEffectDefines(): string;
  83084. /**
  83085. * Returns the string "PointParticleEmitter"
  83086. * @returns a string containing the class name
  83087. */
  83088. getClassName(): string;
  83089. /**
  83090. * Serializes the particle system to a JSON object.
  83091. * @returns the JSON object
  83092. */
  83093. serialize(): any;
  83094. /**
  83095. * Parse properties from a JSON object
  83096. * @param serializationObject defines the JSON object
  83097. */
  83098. parse(serializationObject: any): void;
  83099. }
  83100. }
  83101. declare module BABYLON {
  83102. /**
  83103. * Particle emitter emitting particles from the inside of a sphere.
  83104. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83105. */
  83106. export class SphereParticleEmitter implements IParticleEmitterType {
  83107. /**
  83108. * The radius of the emission sphere.
  83109. */
  83110. radius: number;
  83111. /**
  83112. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83113. */
  83114. radiusRange: number;
  83115. /**
  83116. * How much to randomize the particle direction [0-1].
  83117. */
  83118. directionRandomizer: number;
  83119. /**
  83120. * Creates a new instance SphereParticleEmitter
  83121. * @param radius the radius of the emission sphere (1 by default)
  83122. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83123. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83124. */
  83125. constructor(
  83126. /**
  83127. * The radius of the emission sphere.
  83128. */
  83129. radius?: number,
  83130. /**
  83131. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83132. */
  83133. radiusRange?: number,
  83134. /**
  83135. * How much to randomize the particle direction [0-1].
  83136. */
  83137. directionRandomizer?: number);
  83138. /**
  83139. * Called by the particle System when the direction is computed for the created particle.
  83140. * @param worldMatrix is the world matrix of the particle system
  83141. * @param directionToUpdate is the direction vector to update with the result
  83142. * @param particle is the particle we are computed the direction for
  83143. */
  83144. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83145. /**
  83146. * Called by the particle System when the position is computed for the created particle.
  83147. * @param worldMatrix is the world matrix of the particle system
  83148. * @param positionToUpdate is the position vector to update with the result
  83149. * @param particle is the particle we are computed the position for
  83150. */
  83151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83152. /**
  83153. * Clones the current emitter and returns a copy of it
  83154. * @returns the new emitter
  83155. */
  83156. clone(): SphereParticleEmitter;
  83157. /**
  83158. * Called by the GPUParticleSystem to setup the update shader
  83159. * @param effect defines the update shader
  83160. */
  83161. applyToShader(effect: Effect): void;
  83162. /**
  83163. * Returns a string to use to update the GPU particles update shader
  83164. * @returns a string containng the defines string
  83165. */
  83166. getEffectDefines(): string;
  83167. /**
  83168. * Returns the string "SphereParticleEmitter"
  83169. * @returns a string containing the class name
  83170. */
  83171. getClassName(): string;
  83172. /**
  83173. * Serializes the particle system to a JSON object.
  83174. * @returns the JSON object
  83175. */
  83176. serialize(): any;
  83177. /**
  83178. * Parse properties from a JSON object
  83179. * @param serializationObject defines the JSON object
  83180. */
  83181. parse(serializationObject: any): void;
  83182. }
  83183. /**
  83184. * Particle emitter emitting particles from the inside of a sphere.
  83185. * It emits the particles randomly between two vectors.
  83186. */
  83187. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83188. /**
  83189. * The min limit of the emission direction.
  83190. */
  83191. direction1: Vector3;
  83192. /**
  83193. * The max limit of the emission direction.
  83194. */
  83195. direction2: Vector3;
  83196. /**
  83197. * Creates a new instance SphereDirectedParticleEmitter
  83198. * @param radius the radius of the emission sphere (1 by default)
  83199. * @param direction1 the min limit of the emission direction (up vector by default)
  83200. * @param direction2 the max limit of the emission direction (up vector by default)
  83201. */
  83202. constructor(radius?: number,
  83203. /**
  83204. * The min limit of the emission direction.
  83205. */
  83206. direction1?: Vector3,
  83207. /**
  83208. * The max limit of the emission direction.
  83209. */
  83210. direction2?: Vector3);
  83211. /**
  83212. * Called by the particle System when the direction is computed for the created particle.
  83213. * @param worldMatrix is the world matrix of the particle system
  83214. * @param directionToUpdate is the direction vector to update with the result
  83215. * @param particle is the particle we are computed the direction for
  83216. */
  83217. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83218. /**
  83219. * Clones the current emitter and returns a copy of it
  83220. * @returns the new emitter
  83221. */
  83222. clone(): SphereDirectedParticleEmitter;
  83223. /**
  83224. * Called by the GPUParticleSystem to setup the update shader
  83225. * @param effect defines the update shader
  83226. */
  83227. applyToShader(effect: Effect): void;
  83228. /**
  83229. * Returns a string to use to update the GPU particles update shader
  83230. * @returns a string containng the defines string
  83231. */
  83232. getEffectDefines(): string;
  83233. /**
  83234. * Returns the string "SphereDirectedParticleEmitter"
  83235. * @returns a string containing the class name
  83236. */
  83237. getClassName(): string;
  83238. /**
  83239. * Serializes the particle system to a JSON object.
  83240. * @returns the JSON object
  83241. */
  83242. serialize(): any;
  83243. /**
  83244. * Parse properties from a JSON object
  83245. * @param serializationObject defines the JSON object
  83246. */
  83247. parse(serializationObject: any): void;
  83248. }
  83249. }
  83250. declare module BABYLON {
  83251. /**
  83252. * Interface representing a particle system in Babylon.js.
  83253. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83254. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83255. */
  83256. export interface IParticleSystem {
  83257. /**
  83258. * List of animations used by the particle system.
  83259. */
  83260. animations: Animation[];
  83261. /**
  83262. * The id of the Particle system.
  83263. */
  83264. id: string;
  83265. /**
  83266. * The name of the Particle system.
  83267. */
  83268. name: string;
  83269. /**
  83270. * The emitter represents the Mesh or position we are attaching the particle system to.
  83271. */
  83272. emitter: Nullable<AbstractMesh | Vector3>;
  83273. /**
  83274. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83275. */
  83276. isBillboardBased: boolean;
  83277. /**
  83278. * The rendering group used by the Particle system to chose when to render.
  83279. */
  83280. renderingGroupId: number;
  83281. /**
  83282. * The layer mask we are rendering the particles through.
  83283. */
  83284. layerMask: number;
  83285. /**
  83286. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83287. */
  83288. updateSpeed: number;
  83289. /**
  83290. * The amount of time the particle system is running (depends of the overall update speed).
  83291. */
  83292. targetStopDuration: number;
  83293. /**
  83294. * The texture used to render each particle. (this can be a spritesheet)
  83295. */
  83296. particleTexture: Nullable<Texture>;
  83297. /**
  83298. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83299. */
  83300. blendMode: number;
  83301. /**
  83302. * Minimum life time of emitting particles.
  83303. */
  83304. minLifeTime: number;
  83305. /**
  83306. * Maximum life time of emitting particles.
  83307. */
  83308. maxLifeTime: number;
  83309. /**
  83310. * Minimum Size of emitting particles.
  83311. */
  83312. minSize: number;
  83313. /**
  83314. * Maximum Size of emitting particles.
  83315. */
  83316. maxSize: number;
  83317. /**
  83318. * Minimum scale of emitting particles on X axis.
  83319. */
  83320. minScaleX: number;
  83321. /**
  83322. * Maximum scale of emitting particles on X axis.
  83323. */
  83324. maxScaleX: number;
  83325. /**
  83326. * Minimum scale of emitting particles on Y axis.
  83327. */
  83328. minScaleY: number;
  83329. /**
  83330. * Maximum scale of emitting particles on Y axis.
  83331. */
  83332. maxScaleY: number;
  83333. /**
  83334. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83335. */
  83336. color1: Color4;
  83337. /**
  83338. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83339. */
  83340. color2: Color4;
  83341. /**
  83342. * Color the particle will have at the end of its lifetime.
  83343. */
  83344. colorDead: Color4;
  83345. /**
  83346. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83347. */
  83348. emitRate: number;
  83349. /**
  83350. * You can use gravity if you want to give an orientation to your particles.
  83351. */
  83352. gravity: Vector3;
  83353. /**
  83354. * Minimum power of emitting particles.
  83355. */
  83356. minEmitPower: number;
  83357. /**
  83358. * Maximum power of emitting particles.
  83359. */
  83360. maxEmitPower: number;
  83361. /**
  83362. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83363. */
  83364. minAngularSpeed: number;
  83365. /**
  83366. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83367. */
  83368. maxAngularSpeed: number;
  83369. /**
  83370. * Gets or sets the minimal initial rotation in radians.
  83371. */
  83372. minInitialRotation: number;
  83373. /**
  83374. * Gets or sets the maximal initial rotation in radians.
  83375. */
  83376. maxInitialRotation: number;
  83377. /**
  83378. * The particle emitter type defines the emitter used by the particle system.
  83379. * It can be for example box, sphere, or cone...
  83380. */
  83381. particleEmitterType: Nullable<IParticleEmitterType>;
  83382. /**
  83383. * Defines the delay in milliseconds before starting the system (0 by default)
  83384. */
  83385. startDelay: number;
  83386. /**
  83387. * 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
  83388. */
  83389. preWarmCycles: number;
  83390. /**
  83391. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83392. */
  83393. preWarmStepOffset: number;
  83394. /**
  83395. * 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)
  83396. */
  83397. spriteCellChangeSpeed: number;
  83398. /**
  83399. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83400. */
  83401. startSpriteCellID: number;
  83402. /**
  83403. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83404. */
  83405. endSpriteCellID: number;
  83406. /**
  83407. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83408. */
  83409. spriteCellWidth: number;
  83410. /**
  83411. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83412. */
  83413. spriteCellHeight: number;
  83414. /**
  83415. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83416. */
  83417. spriteRandomStartCell: boolean;
  83418. /**
  83419. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83420. */
  83421. isAnimationSheetEnabled: boolean;
  83422. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83423. translationPivot: Vector2;
  83424. /**
  83425. * Gets or sets a texture used to add random noise to particle positions
  83426. */
  83427. noiseTexture: Nullable<BaseTexture>;
  83428. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83429. noiseStrength: Vector3;
  83430. /**
  83431. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83432. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83433. */
  83434. billboardMode: number;
  83435. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83436. limitVelocityDamping: number;
  83437. /**
  83438. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83439. */
  83440. beginAnimationOnStart: boolean;
  83441. /**
  83442. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83443. */
  83444. beginAnimationFrom: number;
  83445. /**
  83446. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83447. */
  83448. beginAnimationTo: number;
  83449. /**
  83450. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83451. */
  83452. beginAnimationLoop: boolean;
  83453. /**
  83454. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83455. */
  83456. disposeOnStop: boolean;
  83457. /**
  83458. * Gets the maximum number of particles active at the same time.
  83459. * @returns The max number of active particles.
  83460. */
  83461. getCapacity(): number;
  83462. /**
  83463. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83464. * @returns True if it has been started, otherwise false.
  83465. */
  83466. isStarted(): boolean;
  83467. /**
  83468. * Animates the particle system for this frame.
  83469. */
  83470. animate(): void;
  83471. /**
  83472. * Renders the particle system in its current state.
  83473. * @returns the current number of particles
  83474. */
  83475. render(): number;
  83476. /**
  83477. * Dispose the particle system and frees its associated resources.
  83478. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83479. */
  83480. dispose(disposeTexture?: boolean): void;
  83481. /**
  83482. * Clones the particle system.
  83483. * @param name The name of the cloned object
  83484. * @param newEmitter The new emitter to use
  83485. * @returns the cloned particle system
  83486. */
  83487. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83488. /**
  83489. * Serializes the particle system to a JSON object.
  83490. * @returns the JSON object
  83491. */
  83492. serialize(): any;
  83493. /**
  83494. * Rebuild the particle system
  83495. */
  83496. rebuild(): void;
  83497. /**
  83498. * Starts the particle system and begins to emit
  83499. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83500. */
  83501. start(delay?: number): void;
  83502. /**
  83503. * Stops the particle system.
  83504. */
  83505. stop(): void;
  83506. /**
  83507. * Remove all active particles
  83508. */
  83509. reset(): void;
  83510. /**
  83511. * Is this system ready to be used/rendered
  83512. * @return true if the system is ready
  83513. */
  83514. isReady(): boolean;
  83515. /**
  83516. * Adds a new color gradient
  83517. * @param gradient defines the gradient to use (between 0 and 1)
  83518. * @param color1 defines the color to affect to the specified gradient
  83519. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83520. * @returns the current particle system
  83521. */
  83522. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83523. /**
  83524. * Remove a specific color gradient
  83525. * @param gradient defines the gradient to remove
  83526. * @returns the current particle system
  83527. */
  83528. removeColorGradient(gradient: number): IParticleSystem;
  83529. /**
  83530. * Adds a new size gradient
  83531. * @param gradient defines the gradient to use (between 0 and 1)
  83532. * @param factor defines the size factor to affect to the specified gradient
  83533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83534. * @returns the current particle system
  83535. */
  83536. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83537. /**
  83538. * Remove a specific size gradient
  83539. * @param gradient defines the gradient to remove
  83540. * @returns the current particle system
  83541. */
  83542. removeSizeGradient(gradient: number): IParticleSystem;
  83543. /**
  83544. * Gets the current list of color gradients.
  83545. * You must use addColorGradient and removeColorGradient to udpate this list
  83546. * @returns the list of color gradients
  83547. */
  83548. getColorGradients(): Nullable<Array<ColorGradient>>;
  83549. /**
  83550. * Gets the current list of size gradients.
  83551. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83552. * @returns the list of size gradients
  83553. */
  83554. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83555. /**
  83556. * Gets the current list of angular speed gradients.
  83557. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83558. * @returns the list of angular speed gradients
  83559. */
  83560. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83561. /**
  83562. * Adds a new angular speed gradient
  83563. * @param gradient defines the gradient to use (between 0 and 1)
  83564. * @param factor defines the angular speed to affect to the specified gradient
  83565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83566. * @returns the current particle system
  83567. */
  83568. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83569. /**
  83570. * Remove a specific angular speed gradient
  83571. * @param gradient defines the gradient to remove
  83572. * @returns the current particle system
  83573. */
  83574. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83575. /**
  83576. * Gets the current list of velocity gradients.
  83577. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83578. * @returns the list of velocity gradients
  83579. */
  83580. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83581. /**
  83582. * Adds a new velocity gradient
  83583. * @param gradient defines the gradient to use (between 0 and 1)
  83584. * @param factor defines the velocity to affect to the specified gradient
  83585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83586. * @returns the current particle system
  83587. */
  83588. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83589. /**
  83590. * Remove a specific velocity gradient
  83591. * @param gradient defines the gradient to remove
  83592. * @returns the current particle system
  83593. */
  83594. removeVelocityGradient(gradient: number): IParticleSystem;
  83595. /**
  83596. * Gets the current list of limit velocity gradients.
  83597. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83598. * @returns the list of limit velocity gradients
  83599. */
  83600. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83601. /**
  83602. * Adds a new limit velocity gradient
  83603. * @param gradient defines the gradient to use (between 0 and 1)
  83604. * @param factor defines the limit velocity to affect to the specified gradient
  83605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83606. * @returns the current particle system
  83607. */
  83608. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83609. /**
  83610. * Remove a specific limit velocity gradient
  83611. * @param gradient defines the gradient to remove
  83612. * @returns the current particle system
  83613. */
  83614. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83615. /**
  83616. * Adds a new drag gradient
  83617. * @param gradient defines the gradient to use (between 0 and 1)
  83618. * @param factor defines the drag to affect to the specified gradient
  83619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83620. * @returns the current particle system
  83621. */
  83622. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83623. /**
  83624. * Remove a specific drag gradient
  83625. * @param gradient defines the gradient to remove
  83626. * @returns the current particle system
  83627. */
  83628. removeDragGradient(gradient: number): IParticleSystem;
  83629. /**
  83630. * Gets the current list of drag gradients.
  83631. * You must use addDragGradient and removeDragGradient to udpate this list
  83632. * @returns the list of drag gradients
  83633. */
  83634. getDragGradients(): Nullable<Array<FactorGradient>>;
  83635. /**
  83636. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83637. * @param gradient defines the gradient to use (between 0 and 1)
  83638. * @param factor defines the emit rate to affect to the specified gradient
  83639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83640. * @returns the current particle system
  83641. */
  83642. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83643. /**
  83644. * Remove a specific emit rate gradient
  83645. * @param gradient defines the gradient to remove
  83646. * @returns the current particle system
  83647. */
  83648. removeEmitRateGradient(gradient: number): IParticleSystem;
  83649. /**
  83650. * Gets the current list of emit rate gradients.
  83651. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83652. * @returns the list of emit rate gradients
  83653. */
  83654. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83655. /**
  83656. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83657. * @param gradient defines the gradient to use (between 0 and 1)
  83658. * @param factor defines the start size to affect to the specified gradient
  83659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83660. * @returns the current particle system
  83661. */
  83662. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83663. /**
  83664. * Remove a specific start size gradient
  83665. * @param gradient defines the gradient to remove
  83666. * @returns the current particle system
  83667. */
  83668. removeStartSizeGradient(gradient: number): IParticleSystem;
  83669. /**
  83670. * Gets the current list of start size gradients.
  83671. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83672. * @returns the list of start size gradients
  83673. */
  83674. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83675. /**
  83676. * Adds a new life time gradient
  83677. * @param gradient defines the gradient to use (between 0 and 1)
  83678. * @param factor defines the life time factor to affect to the specified gradient
  83679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83680. * @returns the current particle system
  83681. */
  83682. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83683. /**
  83684. * Remove a specific life time gradient
  83685. * @param gradient defines the gradient to remove
  83686. * @returns the current particle system
  83687. */
  83688. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83689. /**
  83690. * Gets the current list of life time gradients.
  83691. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83692. * @returns the list of life time gradients
  83693. */
  83694. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83695. /**
  83696. * Gets the current list of color gradients.
  83697. * You must use addColorGradient and removeColorGradient to udpate this list
  83698. * @returns the list of color gradients
  83699. */
  83700. getColorGradients(): Nullable<Array<ColorGradient>>;
  83701. /**
  83702. * Adds a new ramp gradient used to remap particle colors
  83703. * @param gradient defines the gradient to use (between 0 and 1)
  83704. * @param color defines the color to affect to the specified gradient
  83705. * @returns the current particle system
  83706. */
  83707. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83708. /**
  83709. * Gets the current list of ramp gradients.
  83710. * You must use addRampGradient and removeRampGradient to udpate this list
  83711. * @returns the list of ramp gradients
  83712. */
  83713. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83714. /** Gets or sets a boolean indicating that ramp gradients must be used
  83715. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83716. */
  83717. useRampGradients: boolean;
  83718. /**
  83719. * Adds a new color remap gradient
  83720. * @param gradient defines the gradient to use (between 0 and 1)
  83721. * @param min defines the color remap minimal range
  83722. * @param max defines the color remap maximal range
  83723. * @returns the current particle system
  83724. */
  83725. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83726. /**
  83727. * Gets the current list of color remap gradients.
  83728. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83729. * @returns the list of color remap gradients
  83730. */
  83731. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83732. /**
  83733. * Adds a new alpha remap gradient
  83734. * @param gradient defines the gradient to use (between 0 and 1)
  83735. * @param min defines the alpha remap minimal range
  83736. * @param max defines the alpha remap maximal range
  83737. * @returns the current particle system
  83738. */
  83739. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83740. /**
  83741. * Gets the current list of alpha remap gradients.
  83742. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83743. * @returns the list of alpha remap gradients
  83744. */
  83745. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83746. /**
  83747. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83748. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83749. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83750. * @returns the emitter
  83751. */
  83752. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83753. /**
  83754. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83755. * @param radius The radius of the hemisphere to emit from
  83756. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83757. * @returns the emitter
  83758. */
  83759. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83760. /**
  83761. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83762. * @param radius The radius of the sphere to emit from
  83763. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83764. * @returns the emitter
  83765. */
  83766. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83767. /**
  83768. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83769. * @param radius The radius of the sphere to emit from
  83770. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83771. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83772. * @returns the emitter
  83773. */
  83774. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83775. /**
  83776. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83777. * @param radius The radius of the emission cylinder
  83778. * @param height The height of the emission cylinder
  83779. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83780. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83781. * @returns the emitter
  83782. */
  83783. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83784. /**
  83785. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83786. * @param radius The radius of the cylinder to emit from
  83787. * @param height The height of the emission cylinder
  83788. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83789. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83790. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83791. * @returns the emitter
  83792. */
  83793. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83794. /**
  83795. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83796. * @param radius The radius of the cone to emit from
  83797. * @param angle The base angle of the cone
  83798. * @returns the emitter
  83799. */
  83800. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83801. /**
  83802. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83803. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83804. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83805. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83806. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83807. * @returns the emitter
  83808. */
  83809. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83810. /**
  83811. * Get hosting scene
  83812. * @returns the scene
  83813. */
  83814. getScene(): Scene;
  83815. }
  83816. }
  83817. declare module BABYLON {
  83818. /** @hidden */
  83819. export var linePixelShader: {
  83820. name: string;
  83821. shader: string;
  83822. };
  83823. }
  83824. declare module BABYLON {
  83825. /** @hidden */
  83826. export var lineVertexShader: {
  83827. name: string;
  83828. shader: string;
  83829. };
  83830. }
  83831. declare module BABYLON {
  83832. interface AbstractMesh {
  83833. /**
  83834. * Gets the edgesRenderer associated with the mesh
  83835. */
  83836. edgesRenderer: Nullable<EdgesRenderer>;
  83837. }
  83838. interface LinesMesh {
  83839. /**
  83840. * Enables the edge rendering mode on the mesh.
  83841. * This mode makes the mesh edges visible
  83842. * @param epsilon defines the maximal distance between two angles to detect a face
  83843. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83844. * @returns the currentAbstractMesh
  83845. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83846. */
  83847. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83848. }
  83849. interface InstancedLinesMesh {
  83850. /**
  83851. * Enables the edge rendering mode on the mesh.
  83852. * This mode makes the mesh edges visible
  83853. * @param epsilon defines the maximal distance between two angles to detect a face
  83854. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83855. * @returns the current InstancedLinesMesh
  83856. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83857. */
  83858. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83859. }
  83860. /**
  83861. * Defines the minimum contract an Edges renderer should follow.
  83862. */
  83863. export interface IEdgesRenderer extends IDisposable {
  83864. /**
  83865. * Gets or sets a boolean indicating if the edgesRenderer is active
  83866. */
  83867. isEnabled: boolean;
  83868. /**
  83869. * Renders the edges of the attached mesh,
  83870. */
  83871. render(): void;
  83872. /**
  83873. * Checks wether or not the edges renderer is ready to render.
  83874. * @return true if ready, otherwise false.
  83875. */
  83876. isReady(): boolean;
  83877. }
  83878. /**
  83879. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83880. */
  83881. export class EdgesRenderer implements IEdgesRenderer {
  83882. /**
  83883. * Define the size of the edges with an orthographic camera
  83884. */
  83885. edgesWidthScalerForOrthographic: number;
  83886. /**
  83887. * Define the size of the edges with a perspective camera
  83888. */
  83889. edgesWidthScalerForPerspective: number;
  83890. protected _source: AbstractMesh;
  83891. protected _linesPositions: number[];
  83892. protected _linesNormals: number[];
  83893. protected _linesIndices: number[];
  83894. protected _epsilon: number;
  83895. protected _indicesCount: number;
  83896. protected _lineShader: ShaderMaterial;
  83897. protected _ib: DataBuffer;
  83898. protected _buffers: {
  83899. [key: string]: Nullable<VertexBuffer>;
  83900. };
  83901. protected _checkVerticesInsteadOfIndices: boolean;
  83902. private _meshRebuildObserver;
  83903. private _meshDisposeObserver;
  83904. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83905. isEnabled: boolean;
  83906. /**
  83907. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83908. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83909. * @param source Mesh used to create edges
  83910. * @param epsilon sum of angles in adjacency to check for edge
  83911. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83912. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83913. */
  83914. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83915. protected _prepareRessources(): void;
  83916. /** @hidden */
  83917. _rebuild(): void;
  83918. /**
  83919. * Releases the required resources for the edges renderer
  83920. */
  83921. dispose(): void;
  83922. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83923. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83924. /**
  83925. * Checks if the pair of p0 and p1 is en edge
  83926. * @param faceIndex
  83927. * @param edge
  83928. * @param faceNormals
  83929. * @param p0
  83930. * @param p1
  83931. * @private
  83932. */
  83933. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83934. /**
  83935. * push line into the position, normal and index buffer
  83936. * @protected
  83937. */
  83938. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83939. /**
  83940. * Generates lines edges from adjacencjes
  83941. * @private
  83942. */
  83943. _generateEdgesLines(): void;
  83944. /**
  83945. * Checks wether or not the edges renderer is ready to render.
  83946. * @return true if ready, otherwise false.
  83947. */
  83948. isReady(): boolean;
  83949. /**
  83950. * Renders the edges of the attached mesh,
  83951. */
  83952. render(): void;
  83953. }
  83954. /**
  83955. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83956. */
  83957. export class LineEdgesRenderer extends EdgesRenderer {
  83958. /**
  83959. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83960. * @param source LineMesh used to generate edges
  83961. * @param epsilon not important (specified angle for edge detection)
  83962. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83963. */
  83964. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83965. /**
  83966. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83967. */
  83968. _generateEdgesLines(): void;
  83969. }
  83970. }
  83971. declare module BABYLON {
  83972. /**
  83973. * This represents the object necessary to create a rendering group.
  83974. * This is exclusively used and created by the rendering manager.
  83975. * To modify the behavior, you use the available helpers in your scene or meshes.
  83976. * @hidden
  83977. */
  83978. export class RenderingGroup {
  83979. index: number;
  83980. private static _zeroVector;
  83981. private _scene;
  83982. private _opaqueSubMeshes;
  83983. private _transparentSubMeshes;
  83984. private _alphaTestSubMeshes;
  83985. private _depthOnlySubMeshes;
  83986. private _particleSystems;
  83987. private _spriteManagers;
  83988. private _opaqueSortCompareFn;
  83989. private _alphaTestSortCompareFn;
  83990. private _transparentSortCompareFn;
  83991. private _renderOpaque;
  83992. private _renderAlphaTest;
  83993. private _renderTransparent;
  83994. /** @hidden */
  83995. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83996. onBeforeTransparentRendering: () => void;
  83997. /**
  83998. * Set the opaque sort comparison function.
  83999. * If null the sub meshes will be render in the order they were created
  84000. */
  84001. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84002. /**
  84003. * Set the alpha test sort comparison function.
  84004. * If null the sub meshes will be render in the order they were created
  84005. */
  84006. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84007. /**
  84008. * Set the transparent sort comparison function.
  84009. * If null the sub meshes will be render in the order they were created
  84010. */
  84011. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84012. /**
  84013. * Creates a new rendering group.
  84014. * @param index The rendering group index
  84015. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84016. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84017. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84018. */
  84019. 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>);
  84020. /**
  84021. * Render all the sub meshes contained in the group.
  84022. * @param customRenderFunction Used to override the default render behaviour of the group.
  84023. * @returns true if rendered some submeshes.
  84024. */
  84025. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84026. /**
  84027. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84028. * @param subMeshes The submeshes to render
  84029. */
  84030. private renderOpaqueSorted;
  84031. /**
  84032. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84033. * @param subMeshes The submeshes to render
  84034. */
  84035. private renderAlphaTestSorted;
  84036. /**
  84037. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84038. * @param subMeshes The submeshes to render
  84039. */
  84040. private renderTransparentSorted;
  84041. /**
  84042. * Renders the submeshes in a specified order.
  84043. * @param subMeshes The submeshes to sort before render
  84044. * @param sortCompareFn The comparison function use to sort
  84045. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84046. * @param transparent Specifies to activate blending if true
  84047. */
  84048. private static renderSorted;
  84049. /**
  84050. * Renders the submeshes in the order they were dispatched (no sort applied).
  84051. * @param subMeshes The submeshes to render
  84052. */
  84053. private static renderUnsorted;
  84054. /**
  84055. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84056. * are rendered back to front if in the same alpha index.
  84057. *
  84058. * @param a The first submesh
  84059. * @param b The second submesh
  84060. * @returns The result of the comparison
  84061. */
  84062. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84063. /**
  84064. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84065. * are rendered back to front.
  84066. *
  84067. * @param a The first submesh
  84068. * @param b The second submesh
  84069. * @returns The result of the comparison
  84070. */
  84071. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84072. /**
  84073. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84074. * are rendered front to back (prevent overdraw).
  84075. *
  84076. * @param a The first submesh
  84077. * @param b The second submesh
  84078. * @returns The result of the comparison
  84079. */
  84080. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84081. /**
  84082. * Resets the different lists of submeshes to prepare a new frame.
  84083. */
  84084. prepare(): void;
  84085. dispose(): void;
  84086. /**
  84087. * Inserts the submesh in its correct queue depending on its material.
  84088. * @param subMesh The submesh to dispatch
  84089. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84090. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84091. */
  84092. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84093. dispatchSprites(spriteManager: ISpriteManager): void;
  84094. dispatchParticles(particleSystem: IParticleSystem): void;
  84095. private _renderParticles;
  84096. private _renderSprites;
  84097. }
  84098. }
  84099. declare module BABYLON {
  84100. /**
  84101. * Interface describing the different options available in the rendering manager
  84102. * regarding Auto Clear between groups.
  84103. */
  84104. export interface IRenderingManagerAutoClearSetup {
  84105. /**
  84106. * Defines whether or not autoclear is enable.
  84107. */
  84108. autoClear: boolean;
  84109. /**
  84110. * Defines whether or not to autoclear the depth buffer.
  84111. */
  84112. depth: boolean;
  84113. /**
  84114. * Defines whether or not to autoclear the stencil buffer.
  84115. */
  84116. stencil: boolean;
  84117. }
  84118. /**
  84119. * This class is used by the onRenderingGroupObservable
  84120. */
  84121. export class RenderingGroupInfo {
  84122. /**
  84123. * The Scene that being rendered
  84124. */
  84125. scene: Scene;
  84126. /**
  84127. * The camera currently used for the rendering pass
  84128. */
  84129. camera: Nullable<Camera>;
  84130. /**
  84131. * The ID of the renderingGroup being processed
  84132. */
  84133. renderingGroupId: number;
  84134. }
  84135. /**
  84136. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84137. * It is enable to manage the different groups as well as the different necessary sort functions.
  84138. * This should not be used directly aside of the few static configurations
  84139. */
  84140. export class RenderingManager {
  84141. /**
  84142. * The max id used for rendering groups (not included)
  84143. */
  84144. static MAX_RENDERINGGROUPS: number;
  84145. /**
  84146. * The min id used for rendering groups (included)
  84147. */
  84148. static MIN_RENDERINGGROUPS: number;
  84149. /**
  84150. * Used to globally prevent autoclearing scenes.
  84151. */
  84152. static AUTOCLEAR: boolean;
  84153. /**
  84154. * @hidden
  84155. */
  84156. _useSceneAutoClearSetup: boolean;
  84157. private _scene;
  84158. private _renderingGroups;
  84159. private _depthStencilBufferAlreadyCleaned;
  84160. private _autoClearDepthStencil;
  84161. private _customOpaqueSortCompareFn;
  84162. private _customAlphaTestSortCompareFn;
  84163. private _customTransparentSortCompareFn;
  84164. private _renderingGroupInfo;
  84165. /**
  84166. * Instantiates a new rendering group for a particular scene
  84167. * @param scene Defines the scene the groups belongs to
  84168. */
  84169. constructor(scene: Scene);
  84170. private _clearDepthStencilBuffer;
  84171. /**
  84172. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84173. * @hidden
  84174. */
  84175. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84176. /**
  84177. * Resets the different information of the group to prepare a new frame
  84178. * @hidden
  84179. */
  84180. reset(): void;
  84181. /**
  84182. * Dispose and release the group and its associated resources.
  84183. * @hidden
  84184. */
  84185. dispose(): void;
  84186. /**
  84187. * Clear the info related to rendering groups preventing retention points during dispose.
  84188. */
  84189. freeRenderingGroups(): void;
  84190. private _prepareRenderingGroup;
  84191. /**
  84192. * Add a sprite manager to the rendering manager in order to render it this frame.
  84193. * @param spriteManager Define the sprite manager to render
  84194. */
  84195. dispatchSprites(spriteManager: ISpriteManager): void;
  84196. /**
  84197. * Add a particle system to the rendering manager in order to render it this frame.
  84198. * @param particleSystem Define the particle system to render
  84199. */
  84200. dispatchParticles(particleSystem: IParticleSystem): void;
  84201. /**
  84202. * Add a submesh to the manager in order to render it this frame
  84203. * @param subMesh The submesh to dispatch
  84204. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84205. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84206. */
  84207. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84208. /**
  84209. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84210. * This allowed control for front to back rendering or reversly depending of the special needs.
  84211. *
  84212. * @param renderingGroupId The rendering group id corresponding to its index
  84213. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84214. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84215. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84216. */
  84217. 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;
  84218. /**
  84219. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84220. *
  84221. * @param renderingGroupId The rendering group id corresponding to its index
  84222. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84223. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84224. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84225. */
  84226. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84227. /**
  84228. * Gets the current auto clear configuration for one rendering group of the rendering
  84229. * manager.
  84230. * @param index the rendering group index to get the information for
  84231. * @returns The auto clear setup for the requested rendering group
  84232. */
  84233. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84234. }
  84235. }
  84236. declare module BABYLON {
  84237. /**
  84238. * This Helps creating a texture that will be created from a camera in your scene.
  84239. * It is basically a dynamic texture that could be used to create special effects for instance.
  84240. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84241. */
  84242. export class RenderTargetTexture extends Texture {
  84243. isCube: boolean;
  84244. /**
  84245. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84246. */
  84247. static readonly REFRESHRATE_RENDER_ONCE: number;
  84248. /**
  84249. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84250. */
  84251. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84252. /**
  84253. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84254. * the central point of your effect and can save a lot of performances.
  84255. */
  84256. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84257. /**
  84258. * Use this predicate to dynamically define the list of mesh you want to render.
  84259. * If set, the renderList property will be overwritten.
  84260. */
  84261. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84262. private _renderList;
  84263. /**
  84264. * Use this list to define the list of mesh you want to render.
  84265. */
  84266. renderList: Nullable<Array<AbstractMesh>>;
  84267. private _hookArray;
  84268. /**
  84269. * Define if particles should be rendered in your texture.
  84270. */
  84271. renderParticles: boolean;
  84272. /**
  84273. * Define if sprites should be rendered in your texture.
  84274. */
  84275. renderSprites: boolean;
  84276. /**
  84277. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84278. */
  84279. coordinatesMode: number;
  84280. /**
  84281. * Define the camera used to render the texture.
  84282. */
  84283. activeCamera: Nullable<Camera>;
  84284. /**
  84285. * Override the render function of the texture with your own one.
  84286. */
  84287. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84288. /**
  84289. * Define if camera post processes should be use while rendering the texture.
  84290. */
  84291. useCameraPostProcesses: boolean;
  84292. /**
  84293. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84294. */
  84295. ignoreCameraViewport: boolean;
  84296. private _postProcessManager;
  84297. private _postProcesses;
  84298. private _resizeObserver;
  84299. /**
  84300. * An event triggered when the texture is unbind.
  84301. */
  84302. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84303. /**
  84304. * An event triggered when the texture is unbind.
  84305. */
  84306. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84307. private _onAfterUnbindObserver;
  84308. /**
  84309. * Set a after unbind callback in the texture.
  84310. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84311. */
  84312. onAfterUnbind: () => void;
  84313. /**
  84314. * An event triggered before rendering the texture
  84315. */
  84316. onBeforeRenderObservable: Observable<number>;
  84317. private _onBeforeRenderObserver;
  84318. /**
  84319. * Set a before render callback in the texture.
  84320. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84321. */
  84322. onBeforeRender: (faceIndex: number) => void;
  84323. /**
  84324. * An event triggered after rendering the texture
  84325. */
  84326. onAfterRenderObservable: Observable<number>;
  84327. private _onAfterRenderObserver;
  84328. /**
  84329. * Set a after render callback in the texture.
  84330. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84331. */
  84332. onAfterRender: (faceIndex: number) => void;
  84333. /**
  84334. * An event triggered after the texture clear
  84335. */
  84336. onClearObservable: Observable<Engine>;
  84337. private _onClearObserver;
  84338. /**
  84339. * Set a clear callback in the texture.
  84340. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84341. */
  84342. onClear: (Engine: Engine) => void;
  84343. /**
  84344. * Define the clear color of the Render Target if it should be different from the scene.
  84345. */
  84346. clearColor: Color4;
  84347. protected _size: number | {
  84348. width: number;
  84349. height: number;
  84350. };
  84351. protected _initialSizeParameter: number | {
  84352. width: number;
  84353. height: number;
  84354. } | {
  84355. ratio: number;
  84356. };
  84357. protected _sizeRatio: Nullable<number>;
  84358. /** @hidden */
  84359. _generateMipMaps: boolean;
  84360. protected _renderingManager: RenderingManager;
  84361. /** @hidden */
  84362. _waitingRenderList: string[];
  84363. protected _doNotChangeAspectRatio: boolean;
  84364. protected _currentRefreshId: number;
  84365. protected _refreshRate: number;
  84366. protected _textureMatrix: Matrix;
  84367. protected _samples: number;
  84368. protected _renderTargetOptions: RenderTargetCreationOptions;
  84369. /**
  84370. * Gets render target creation options that were used.
  84371. */
  84372. readonly renderTargetOptions: RenderTargetCreationOptions;
  84373. protected _engine: Engine;
  84374. protected _onRatioRescale(): void;
  84375. /**
  84376. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84377. * It must define where the camera used to render the texture is set
  84378. */
  84379. boundingBoxPosition: Vector3;
  84380. private _boundingBoxSize;
  84381. /**
  84382. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84383. * When defined, the cubemap will switch to local mode
  84384. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84385. * @example https://www.babylonjs-playground.com/#RNASML
  84386. */
  84387. boundingBoxSize: Vector3;
  84388. /**
  84389. * In case the RTT has been created with a depth texture, get the associated
  84390. * depth texture.
  84391. * Otherwise, return null.
  84392. */
  84393. depthStencilTexture: Nullable<InternalTexture>;
  84394. /**
  84395. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84396. * or used a shadow, depth texture...
  84397. * @param name The friendly name of the texture
  84398. * @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)
  84399. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84400. * @param generateMipMaps True if mip maps need to be generated after render.
  84401. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84402. * @param type The type of the buffer in the RTT (int, half float, float...)
  84403. * @param isCube True if a cube texture needs to be created
  84404. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84405. * @param generateDepthBuffer True to generate a depth buffer
  84406. * @param generateStencilBuffer True to generate a stencil buffer
  84407. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84408. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84409. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84410. */
  84411. constructor(name: string, size: number | {
  84412. width: number;
  84413. height: number;
  84414. } | {
  84415. ratio: number;
  84416. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84417. /**
  84418. * Creates a depth stencil texture.
  84419. * This is only available in WebGL 2 or with the depth texture extension available.
  84420. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84421. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84422. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84423. */
  84424. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84425. private _processSizeParameter;
  84426. /**
  84427. * Define the number of samples to use in case of MSAA.
  84428. * It defaults to one meaning no MSAA has been enabled.
  84429. */
  84430. samples: number;
  84431. /**
  84432. * Resets the refresh counter of the texture and start bak from scratch.
  84433. * Could be useful to regenerate the texture if it is setup to render only once.
  84434. */
  84435. resetRefreshCounter(): void;
  84436. /**
  84437. * Define the refresh rate of the texture or the rendering frequency.
  84438. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84439. */
  84440. refreshRate: number;
  84441. /**
  84442. * Adds a post process to the render target rendering passes.
  84443. * @param postProcess define the post process to add
  84444. */
  84445. addPostProcess(postProcess: PostProcess): void;
  84446. /**
  84447. * Clear all the post processes attached to the render target
  84448. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84449. */
  84450. clearPostProcesses(dispose?: boolean): void;
  84451. /**
  84452. * Remove one of the post process from the list of attached post processes to the texture
  84453. * @param postProcess define the post process to remove from the list
  84454. */
  84455. removePostProcess(postProcess: PostProcess): void;
  84456. /** @hidden */
  84457. _shouldRender(): boolean;
  84458. /**
  84459. * Gets the actual render size of the texture.
  84460. * @returns the width of the render size
  84461. */
  84462. getRenderSize(): number;
  84463. /**
  84464. * Gets the actual render width of the texture.
  84465. * @returns the width of the render size
  84466. */
  84467. getRenderWidth(): number;
  84468. /**
  84469. * Gets the actual render height of the texture.
  84470. * @returns the height of the render size
  84471. */
  84472. getRenderHeight(): number;
  84473. /**
  84474. * Get if the texture can be rescaled or not.
  84475. */
  84476. readonly canRescale: boolean;
  84477. /**
  84478. * Resize the texture using a ratio.
  84479. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84480. */
  84481. scale(ratio: number): void;
  84482. /**
  84483. * Get the texture reflection matrix used to rotate/transform the reflection.
  84484. * @returns the reflection matrix
  84485. */
  84486. getReflectionTextureMatrix(): Matrix;
  84487. /**
  84488. * Resize the texture to a new desired size.
  84489. * Be carrefull as it will recreate all the data in the new texture.
  84490. * @param size Define the new size. It can be:
  84491. * - a number for squared texture,
  84492. * - an object containing { width: number, height: number }
  84493. * - or an object containing a ratio { ratio: number }
  84494. */
  84495. resize(size: number | {
  84496. width: number;
  84497. height: number;
  84498. } | {
  84499. ratio: number;
  84500. }): void;
  84501. /**
  84502. * Renders all the objects from the render list into the texture.
  84503. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84504. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84505. */
  84506. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84507. private _bestReflectionRenderTargetDimension;
  84508. /**
  84509. * @hidden
  84510. * @param faceIndex face index to bind to if this is a cubetexture
  84511. */
  84512. _bindFrameBuffer(faceIndex?: number): void;
  84513. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84514. private renderToTarget;
  84515. /**
  84516. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84517. * This allowed control for front to back rendering or reversly depending of the special needs.
  84518. *
  84519. * @param renderingGroupId The rendering group id corresponding to its index
  84520. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84521. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84522. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84523. */
  84524. 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;
  84525. /**
  84526. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84527. *
  84528. * @param renderingGroupId The rendering group id corresponding to its index
  84529. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84530. */
  84531. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84532. /**
  84533. * Clones the texture.
  84534. * @returns the cloned texture
  84535. */
  84536. clone(): RenderTargetTexture;
  84537. /**
  84538. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84539. * @returns The JSON representation of the texture
  84540. */
  84541. serialize(): any;
  84542. /**
  84543. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84544. */
  84545. disposeFramebufferObjects(): void;
  84546. /**
  84547. * Dispose the texture and release its associated resources.
  84548. */
  84549. dispose(): void;
  84550. /** @hidden */
  84551. _rebuild(): void;
  84552. /**
  84553. * Clear the info related to rendering groups preventing retention point in material dispose.
  84554. */
  84555. freeRenderingGroups(): void;
  84556. /**
  84557. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84558. * @returns the view count
  84559. */
  84560. getViewCount(): number;
  84561. }
  84562. }
  84563. declare module BABYLON {
  84564. /**
  84565. * Base class for the main features of a material in Babylon.js
  84566. */
  84567. export class Material implements IAnimatable {
  84568. /**
  84569. * Returns the triangle fill mode
  84570. */
  84571. static readonly TriangleFillMode: number;
  84572. /**
  84573. * Returns the wireframe mode
  84574. */
  84575. static readonly WireFrameFillMode: number;
  84576. /**
  84577. * Returns the point fill mode
  84578. */
  84579. static readonly PointFillMode: number;
  84580. /**
  84581. * Returns the point list draw mode
  84582. */
  84583. static readonly PointListDrawMode: number;
  84584. /**
  84585. * Returns the line list draw mode
  84586. */
  84587. static readonly LineListDrawMode: number;
  84588. /**
  84589. * Returns the line loop draw mode
  84590. */
  84591. static readonly LineLoopDrawMode: number;
  84592. /**
  84593. * Returns the line strip draw mode
  84594. */
  84595. static readonly LineStripDrawMode: number;
  84596. /**
  84597. * Returns the triangle strip draw mode
  84598. */
  84599. static readonly TriangleStripDrawMode: number;
  84600. /**
  84601. * Returns the triangle fan draw mode
  84602. */
  84603. static readonly TriangleFanDrawMode: number;
  84604. /**
  84605. * Stores the clock-wise side orientation
  84606. */
  84607. static readonly ClockWiseSideOrientation: number;
  84608. /**
  84609. * Stores the counter clock-wise side orientation
  84610. */
  84611. static readonly CounterClockWiseSideOrientation: number;
  84612. /**
  84613. * The dirty texture flag value
  84614. */
  84615. static readonly TextureDirtyFlag: number;
  84616. /**
  84617. * The dirty light flag value
  84618. */
  84619. static readonly LightDirtyFlag: number;
  84620. /**
  84621. * The dirty fresnel flag value
  84622. */
  84623. static readonly FresnelDirtyFlag: number;
  84624. /**
  84625. * The dirty attribute flag value
  84626. */
  84627. static readonly AttributesDirtyFlag: number;
  84628. /**
  84629. * The dirty misc flag value
  84630. */
  84631. static readonly MiscDirtyFlag: number;
  84632. /**
  84633. * The all dirty flag value
  84634. */
  84635. static readonly AllDirtyFlag: number;
  84636. /**
  84637. * The ID of the material
  84638. */
  84639. id: string;
  84640. /**
  84641. * Gets or sets the unique id of the material
  84642. */
  84643. uniqueId: number;
  84644. /**
  84645. * The name of the material
  84646. */
  84647. name: string;
  84648. /**
  84649. * Gets or sets user defined metadata
  84650. */
  84651. metadata: any;
  84652. /**
  84653. * For internal use only. Please do not use.
  84654. */
  84655. reservedDataStore: any;
  84656. /**
  84657. * Specifies if the ready state should be checked on each call
  84658. */
  84659. checkReadyOnEveryCall: boolean;
  84660. /**
  84661. * Specifies if the ready state should be checked once
  84662. */
  84663. checkReadyOnlyOnce: boolean;
  84664. /**
  84665. * The state of the material
  84666. */
  84667. state: string;
  84668. /**
  84669. * The alpha value of the material
  84670. */
  84671. protected _alpha: number;
  84672. /**
  84673. * List of inspectable custom properties (used by the Inspector)
  84674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84675. */
  84676. inspectableCustomProperties: IInspectable[];
  84677. /**
  84678. * Sets the alpha value of the material
  84679. */
  84680. /**
  84681. * Gets the alpha value of the material
  84682. */
  84683. alpha: number;
  84684. /**
  84685. * Specifies if back face culling is enabled
  84686. */
  84687. protected _backFaceCulling: boolean;
  84688. /**
  84689. * Sets the back-face culling state
  84690. */
  84691. /**
  84692. * Gets the back-face culling state
  84693. */
  84694. backFaceCulling: boolean;
  84695. /**
  84696. * Stores the value for side orientation
  84697. */
  84698. sideOrientation: number;
  84699. /**
  84700. * Callback triggered when the material is compiled
  84701. */
  84702. onCompiled: Nullable<(effect: Effect) => void>;
  84703. /**
  84704. * Callback triggered when an error occurs
  84705. */
  84706. onError: Nullable<(effect: Effect, errors: string) => void>;
  84707. /**
  84708. * Callback triggered to get the render target textures
  84709. */
  84710. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84711. /**
  84712. * Gets a boolean indicating that current material needs to register RTT
  84713. */
  84714. readonly hasRenderTargetTextures: boolean;
  84715. /**
  84716. * Specifies if the material should be serialized
  84717. */
  84718. doNotSerialize: boolean;
  84719. /**
  84720. * @hidden
  84721. */
  84722. _storeEffectOnSubMeshes: boolean;
  84723. /**
  84724. * Stores the animations for the material
  84725. */
  84726. animations: Nullable<Array<Animation>>;
  84727. /**
  84728. * An event triggered when the material is disposed
  84729. */
  84730. onDisposeObservable: Observable<Material>;
  84731. /**
  84732. * An observer which watches for dispose events
  84733. */
  84734. private _onDisposeObserver;
  84735. private _onUnBindObservable;
  84736. /**
  84737. * Called during a dispose event
  84738. */
  84739. onDispose: () => void;
  84740. private _onBindObservable;
  84741. /**
  84742. * An event triggered when the material is bound
  84743. */
  84744. readonly onBindObservable: Observable<AbstractMesh>;
  84745. /**
  84746. * An observer which watches for bind events
  84747. */
  84748. private _onBindObserver;
  84749. /**
  84750. * Called during a bind event
  84751. */
  84752. onBind: (Mesh: AbstractMesh) => void;
  84753. /**
  84754. * An event triggered when the material is unbound
  84755. */
  84756. readonly onUnBindObservable: Observable<Material>;
  84757. /**
  84758. * Stores the value of the alpha mode
  84759. */
  84760. private _alphaMode;
  84761. /**
  84762. * Sets the value of the alpha mode.
  84763. *
  84764. * | Value | Type | Description |
  84765. * | --- | --- | --- |
  84766. * | 0 | ALPHA_DISABLE | |
  84767. * | 1 | ALPHA_ADD | |
  84768. * | 2 | ALPHA_COMBINE | |
  84769. * | 3 | ALPHA_SUBTRACT | |
  84770. * | 4 | ALPHA_MULTIPLY | |
  84771. * | 5 | ALPHA_MAXIMIZED | |
  84772. * | 6 | ALPHA_ONEONE | |
  84773. * | 7 | ALPHA_PREMULTIPLIED | |
  84774. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84775. * | 9 | ALPHA_INTERPOLATE | |
  84776. * | 10 | ALPHA_SCREENMODE | |
  84777. *
  84778. */
  84779. /**
  84780. * Gets the value of the alpha mode
  84781. */
  84782. alphaMode: number;
  84783. /**
  84784. * Stores the state of the need depth pre-pass value
  84785. */
  84786. private _needDepthPrePass;
  84787. /**
  84788. * Sets the need depth pre-pass value
  84789. */
  84790. /**
  84791. * Gets the depth pre-pass value
  84792. */
  84793. needDepthPrePass: boolean;
  84794. /**
  84795. * Specifies if depth writing should be disabled
  84796. */
  84797. disableDepthWrite: boolean;
  84798. /**
  84799. * Specifies if depth writing should be forced
  84800. */
  84801. forceDepthWrite: boolean;
  84802. /**
  84803. * Specifies if there should be a separate pass for culling
  84804. */
  84805. separateCullingPass: boolean;
  84806. /**
  84807. * Stores the state specifing if fog should be enabled
  84808. */
  84809. private _fogEnabled;
  84810. /**
  84811. * Sets the state for enabling fog
  84812. */
  84813. /**
  84814. * Gets the value of the fog enabled state
  84815. */
  84816. fogEnabled: boolean;
  84817. /**
  84818. * Stores the size of points
  84819. */
  84820. pointSize: number;
  84821. /**
  84822. * Stores the z offset value
  84823. */
  84824. zOffset: number;
  84825. /**
  84826. * Gets a value specifying if wireframe mode is enabled
  84827. */
  84828. /**
  84829. * Sets the state of wireframe mode
  84830. */
  84831. wireframe: boolean;
  84832. /**
  84833. * Gets the value specifying if point clouds are enabled
  84834. */
  84835. /**
  84836. * Sets the state of point cloud mode
  84837. */
  84838. pointsCloud: boolean;
  84839. /**
  84840. * Gets the material fill mode
  84841. */
  84842. /**
  84843. * Sets the material fill mode
  84844. */
  84845. fillMode: number;
  84846. /**
  84847. * @hidden
  84848. * Stores the effects for the material
  84849. */
  84850. _effect: Nullable<Effect>;
  84851. /**
  84852. * @hidden
  84853. * Specifies if the material was previously ready
  84854. */
  84855. _wasPreviouslyReady: boolean;
  84856. /**
  84857. * Specifies if uniform buffers should be used
  84858. */
  84859. private _useUBO;
  84860. /**
  84861. * Stores a reference to the scene
  84862. */
  84863. private _scene;
  84864. /**
  84865. * Stores the fill mode state
  84866. */
  84867. private _fillMode;
  84868. /**
  84869. * Specifies if the depth write state should be cached
  84870. */
  84871. private _cachedDepthWriteState;
  84872. /**
  84873. * Stores the uniform buffer
  84874. */
  84875. protected _uniformBuffer: UniformBuffer;
  84876. /** @hidden */
  84877. _indexInSceneMaterialArray: number;
  84878. /** @hidden */
  84879. meshMap: Nullable<{
  84880. [id: string]: AbstractMesh | undefined;
  84881. }>;
  84882. /**
  84883. * Creates a material instance
  84884. * @param name defines the name of the material
  84885. * @param scene defines the scene to reference
  84886. * @param doNotAdd specifies if the material should be added to the scene
  84887. */
  84888. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84889. /**
  84890. * Returns a string representation of the current material
  84891. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84892. * @returns a string with material information
  84893. */
  84894. toString(fullDetails?: boolean): string;
  84895. /**
  84896. * Gets the class name of the material
  84897. * @returns a string with the class name of the material
  84898. */
  84899. getClassName(): string;
  84900. /**
  84901. * Specifies if updates for the material been locked
  84902. */
  84903. readonly isFrozen: boolean;
  84904. /**
  84905. * Locks updates for the material
  84906. */
  84907. freeze(): void;
  84908. /**
  84909. * Unlocks updates for the material
  84910. */
  84911. unfreeze(): void;
  84912. /**
  84913. * Specifies if the material is ready to be used
  84914. * @param mesh defines the mesh to check
  84915. * @param useInstances specifies if instances should be used
  84916. * @returns a boolean indicating if the material is ready to be used
  84917. */
  84918. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84919. /**
  84920. * Specifies that the submesh is ready to be used
  84921. * @param mesh defines the mesh to check
  84922. * @param subMesh defines which submesh to check
  84923. * @param useInstances specifies that instances should be used
  84924. * @returns a boolean indicating that the submesh is ready or not
  84925. */
  84926. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84927. /**
  84928. * Returns the material effect
  84929. * @returns the effect associated with the material
  84930. */
  84931. getEffect(): Nullable<Effect>;
  84932. /**
  84933. * Returns the current scene
  84934. * @returns a Scene
  84935. */
  84936. getScene(): Scene;
  84937. /**
  84938. * Specifies if the material will require alpha blending
  84939. * @returns a boolean specifying if alpha blending is needed
  84940. */
  84941. needAlphaBlending(): boolean;
  84942. /**
  84943. * Specifies if the mesh will require alpha blending
  84944. * @param mesh defines the mesh to check
  84945. * @returns a boolean specifying if alpha blending is needed for the mesh
  84946. */
  84947. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84948. /**
  84949. * Specifies if this material should be rendered in alpha test mode
  84950. * @returns a boolean specifying if an alpha test is needed.
  84951. */
  84952. needAlphaTesting(): boolean;
  84953. /**
  84954. * Gets the texture used for the alpha test
  84955. * @returns the texture to use for alpha testing
  84956. */
  84957. getAlphaTestTexture(): Nullable<BaseTexture>;
  84958. /**
  84959. * Marks the material to indicate that it needs to be re-calculated
  84960. */
  84961. markDirty(): void;
  84962. /** @hidden */
  84963. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84964. /**
  84965. * Binds the material to the mesh
  84966. * @param world defines the world transformation matrix
  84967. * @param mesh defines the mesh to bind the material to
  84968. */
  84969. bind(world: Matrix, mesh?: Mesh): void;
  84970. /**
  84971. * Binds the submesh to the material
  84972. * @param world defines the world transformation matrix
  84973. * @param mesh defines the mesh containing the submesh
  84974. * @param subMesh defines the submesh to bind the material to
  84975. */
  84976. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84977. /**
  84978. * Binds the world matrix to the material
  84979. * @param world defines the world transformation matrix
  84980. */
  84981. bindOnlyWorldMatrix(world: Matrix): void;
  84982. /**
  84983. * Binds the scene's uniform buffer to the effect.
  84984. * @param effect defines the effect to bind to the scene uniform buffer
  84985. * @param sceneUbo defines the uniform buffer storing scene data
  84986. */
  84987. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84988. /**
  84989. * Binds the view matrix to the effect
  84990. * @param effect defines the effect to bind the view matrix to
  84991. */
  84992. bindView(effect: Effect): void;
  84993. /**
  84994. * Binds the view projection matrix to the effect
  84995. * @param effect defines the effect to bind the view projection matrix to
  84996. */
  84997. bindViewProjection(effect: Effect): void;
  84998. /**
  84999. * Specifies if material alpha testing should be turned on for the mesh
  85000. * @param mesh defines the mesh to check
  85001. */
  85002. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85003. /**
  85004. * Processes to execute after binding the material to a mesh
  85005. * @param mesh defines the rendered mesh
  85006. */
  85007. protected _afterBind(mesh?: Mesh): void;
  85008. /**
  85009. * Unbinds the material from the mesh
  85010. */
  85011. unbind(): void;
  85012. /**
  85013. * Gets the active textures from the material
  85014. * @returns an array of textures
  85015. */
  85016. getActiveTextures(): BaseTexture[];
  85017. /**
  85018. * Specifies if the material uses a texture
  85019. * @param texture defines the texture to check against the material
  85020. * @returns a boolean specifying if the material uses the texture
  85021. */
  85022. hasTexture(texture: BaseTexture): boolean;
  85023. /**
  85024. * Makes a duplicate of the material, and gives it a new name
  85025. * @param name defines the new name for the duplicated material
  85026. * @returns the cloned material
  85027. */
  85028. clone(name: string): Nullable<Material>;
  85029. /**
  85030. * Gets the meshes bound to the material
  85031. * @returns an array of meshes bound to the material
  85032. */
  85033. getBindedMeshes(): AbstractMesh[];
  85034. /**
  85035. * Force shader compilation
  85036. * @param mesh defines the mesh associated with this material
  85037. * @param onCompiled defines a function to execute once the material is compiled
  85038. * @param options defines the options to configure the compilation
  85039. */
  85040. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85041. clipPlane: boolean;
  85042. }>): void;
  85043. /**
  85044. * Force shader compilation
  85045. * @param mesh defines the mesh that will use this material
  85046. * @param options defines additional options for compiling the shaders
  85047. * @returns a promise that resolves when the compilation completes
  85048. */
  85049. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85050. clipPlane: boolean;
  85051. }>): Promise<void>;
  85052. private static readonly _AllDirtyCallBack;
  85053. private static readonly _ImageProcessingDirtyCallBack;
  85054. private static readonly _TextureDirtyCallBack;
  85055. private static readonly _FresnelDirtyCallBack;
  85056. private static readonly _MiscDirtyCallBack;
  85057. private static readonly _LightsDirtyCallBack;
  85058. private static readonly _AttributeDirtyCallBack;
  85059. private static _FresnelAndMiscDirtyCallBack;
  85060. private static _TextureAndMiscDirtyCallBack;
  85061. private static readonly _DirtyCallbackArray;
  85062. private static readonly _RunDirtyCallBacks;
  85063. /**
  85064. * Marks a define in the material to indicate that it needs to be re-computed
  85065. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85066. */
  85067. markAsDirty(flag: number): void;
  85068. /**
  85069. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85070. * @param func defines a function which checks material defines against the submeshes
  85071. */
  85072. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85073. /**
  85074. * Indicates that we need to re-calculated for all submeshes
  85075. */
  85076. protected _markAllSubMeshesAsAllDirty(): void;
  85077. /**
  85078. * Indicates that image processing needs to be re-calculated for all submeshes
  85079. */
  85080. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85081. /**
  85082. * Indicates that textures need to be re-calculated for all submeshes
  85083. */
  85084. protected _markAllSubMeshesAsTexturesDirty(): void;
  85085. /**
  85086. * Indicates that fresnel needs to be re-calculated for all submeshes
  85087. */
  85088. protected _markAllSubMeshesAsFresnelDirty(): void;
  85089. /**
  85090. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85091. */
  85092. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85093. /**
  85094. * Indicates that lights need to be re-calculated for all submeshes
  85095. */
  85096. protected _markAllSubMeshesAsLightsDirty(): void;
  85097. /**
  85098. * Indicates that attributes need to be re-calculated for all submeshes
  85099. */
  85100. protected _markAllSubMeshesAsAttributesDirty(): void;
  85101. /**
  85102. * Indicates that misc needs to be re-calculated for all submeshes
  85103. */
  85104. protected _markAllSubMeshesAsMiscDirty(): void;
  85105. /**
  85106. * Indicates that textures and misc need to be re-calculated for all submeshes
  85107. */
  85108. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85109. /**
  85110. * Disposes the material
  85111. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85112. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85113. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85114. */
  85115. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85116. /** @hidden */
  85117. private releaseVertexArrayObject;
  85118. /**
  85119. * Serializes this material
  85120. * @returns the serialized material object
  85121. */
  85122. serialize(): any;
  85123. /**
  85124. * Creates a material from parsed material data
  85125. * @param parsedMaterial defines parsed material data
  85126. * @param scene defines the hosting scene
  85127. * @param rootUrl defines the root URL to use to load textures
  85128. * @returns a new material
  85129. */
  85130. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85131. }
  85132. }
  85133. declare module BABYLON {
  85134. /**
  85135. * Base class for submeshes
  85136. */
  85137. export class BaseSubMesh {
  85138. /** @hidden */
  85139. _materialDefines: Nullable<MaterialDefines>;
  85140. /** @hidden */
  85141. _materialEffect: Nullable<Effect>;
  85142. /**
  85143. * Gets associated effect
  85144. */
  85145. readonly effect: Nullable<Effect>;
  85146. /**
  85147. * Sets associated effect (effect used to render this submesh)
  85148. * @param effect defines the effect to associate with
  85149. * @param defines defines the set of defines used to compile this effect
  85150. */
  85151. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85152. }
  85153. /**
  85154. * Defines a subdivision inside a mesh
  85155. */
  85156. export class SubMesh extends BaseSubMesh implements ICullable {
  85157. /** the material index to use */
  85158. materialIndex: number;
  85159. /** vertex index start */
  85160. verticesStart: number;
  85161. /** vertices count */
  85162. verticesCount: number;
  85163. /** index start */
  85164. indexStart: number;
  85165. /** indices count */
  85166. indexCount: number;
  85167. /** @hidden */
  85168. _linesIndexCount: number;
  85169. private _mesh;
  85170. private _renderingMesh;
  85171. private _boundingInfo;
  85172. private _linesIndexBuffer;
  85173. /** @hidden */
  85174. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85175. /** @hidden */
  85176. _trianglePlanes: Plane[];
  85177. /** @hidden */
  85178. _lastColliderTransformMatrix: Nullable<Matrix>;
  85179. /** @hidden */
  85180. _renderId: number;
  85181. /** @hidden */
  85182. _alphaIndex: number;
  85183. /** @hidden */
  85184. _distanceToCamera: number;
  85185. /** @hidden */
  85186. _id: number;
  85187. private _currentMaterial;
  85188. /**
  85189. * Add a new submesh to a mesh
  85190. * @param materialIndex defines the material index to use
  85191. * @param verticesStart defines vertex index start
  85192. * @param verticesCount defines vertices count
  85193. * @param indexStart defines index start
  85194. * @param indexCount defines indices count
  85195. * @param mesh defines the parent mesh
  85196. * @param renderingMesh defines an optional rendering mesh
  85197. * @param createBoundingBox defines if bounding box should be created for this submesh
  85198. * @returns the new submesh
  85199. */
  85200. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85201. /**
  85202. * Creates a new submesh
  85203. * @param materialIndex defines the material index to use
  85204. * @param verticesStart defines vertex index start
  85205. * @param verticesCount defines vertices count
  85206. * @param indexStart defines index start
  85207. * @param indexCount defines indices count
  85208. * @param mesh defines the parent mesh
  85209. * @param renderingMesh defines an optional rendering mesh
  85210. * @param createBoundingBox defines if bounding box should be created for this submesh
  85211. */
  85212. constructor(
  85213. /** the material index to use */
  85214. materialIndex: number,
  85215. /** vertex index start */
  85216. verticesStart: number,
  85217. /** vertices count */
  85218. verticesCount: number,
  85219. /** index start */
  85220. indexStart: number,
  85221. /** indices count */
  85222. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85223. /**
  85224. * Returns true if this submesh covers the entire parent mesh
  85225. * @ignorenaming
  85226. */
  85227. readonly IsGlobal: boolean;
  85228. /**
  85229. * Returns the submesh BoudingInfo object
  85230. * @returns current bounding info (or mesh's one if the submesh is global)
  85231. */
  85232. getBoundingInfo(): BoundingInfo;
  85233. /**
  85234. * Sets the submesh BoundingInfo
  85235. * @param boundingInfo defines the new bounding info to use
  85236. * @returns the SubMesh
  85237. */
  85238. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85239. /**
  85240. * Returns the mesh of the current submesh
  85241. * @return the parent mesh
  85242. */
  85243. getMesh(): AbstractMesh;
  85244. /**
  85245. * Returns the rendering mesh of the submesh
  85246. * @returns the rendering mesh (could be different from parent mesh)
  85247. */
  85248. getRenderingMesh(): Mesh;
  85249. /**
  85250. * Returns the submesh material
  85251. * @returns null or the current material
  85252. */
  85253. getMaterial(): Nullable<Material>;
  85254. /**
  85255. * Sets a new updated BoundingInfo object to the submesh
  85256. * @param data defines an optional position array to use to determine the bounding info
  85257. * @returns the SubMesh
  85258. */
  85259. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85260. /** @hidden */
  85261. _checkCollision(collider: Collider): boolean;
  85262. /**
  85263. * Updates the submesh BoundingInfo
  85264. * @param world defines the world matrix to use to update the bounding info
  85265. * @returns the submesh
  85266. */
  85267. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85268. /**
  85269. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85270. * @param frustumPlanes defines the frustum planes
  85271. * @returns true if the submesh is intersecting with the frustum
  85272. */
  85273. isInFrustum(frustumPlanes: Plane[]): boolean;
  85274. /**
  85275. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85276. * @param frustumPlanes defines the frustum planes
  85277. * @returns true if the submesh is inside the frustum
  85278. */
  85279. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85280. /**
  85281. * Renders the submesh
  85282. * @param enableAlphaMode defines if alpha needs to be used
  85283. * @returns the submesh
  85284. */
  85285. render(enableAlphaMode: boolean): SubMesh;
  85286. /**
  85287. * @hidden
  85288. */
  85289. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85290. /**
  85291. * Checks if the submesh intersects with a ray
  85292. * @param ray defines the ray to test
  85293. * @returns true is the passed ray intersects the submesh bounding box
  85294. */
  85295. canIntersects(ray: Ray): boolean;
  85296. /**
  85297. * Intersects current submesh with a ray
  85298. * @param ray defines the ray to test
  85299. * @param positions defines mesh's positions array
  85300. * @param indices defines mesh's indices array
  85301. * @param fastCheck defines if only bounding info should be used
  85302. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85303. * @returns intersection info or null if no intersection
  85304. */
  85305. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85306. /** @hidden */
  85307. private _intersectLines;
  85308. /** @hidden */
  85309. private _intersectUnIndexedLines;
  85310. /** @hidden */
  85311. private _intersectTriangles;
  85312. /** @hidden */
  85313. private _intersectUnIndexedTriangles;
  85314. /** @hidden */
  85315. _rebuild(): void;
  85316. /**
  85317. * Creates a new submesh from the passed mesh
  85318. * @param newMesh defines the new hosting mesh
  85319. * @param newRenderingMesh defines an optional rendering mesh
  85320. * @returns the new submesh
  85321. */
  85322. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85323. /**
  85324. * Release associated resources
  85325. */
  85326. dispose(): void;
  85327. /**
  85328. * Gets the class name
  85329. * @returns the string "SubMesh".
  85330. */
  85331. getClassName(): string;
  85332. /**
  85333. * Creates a new submesh from indices data
  85334. * @param materialIndex the index of the main mesh material
  85335. * @param startIndex the index where to start the copy in the mesh indices array
  85336. * @param indexCount the number of indices to copy then from the startIndex
  85337. * @param mesh the main mesh to create the submesh from
  85338. * @param renderingMesh the optional rendering mesh
  85339. * @returns a new submesh
  85340. */
  85341. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85342. }
  85343. }
  85344. declare module BABYLON {
  85345. /**
  85346. * Class used to store geometry data (vertex buffers + index buffer)
  85347. */
  85348. export class Geometry implements IGetSetVerticesData {
  85349. /**
  85350. * Gets or sets the ID of the geometry
  85351. */
  85352. id: string;
  85353. /**
  85354. * Gets or sets the unique ID of the geometry
  85355. */
  85356. uniqueId: number;
  85357. /**
  85358. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85359. */
  85360. delayLoadState: number;
  85361. /**
  85362. * Gets the file containing the data to load when running in delay load state
  85363. */
  85364. delayLoadingFile: Nullable<string>;
  85365. /**
  85366. * Callback called when the geometry is updated
  85367. */
  85368. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85369. private _scene;
  85370. private _engine;
  85371. private _meshes;
  85372. private _totalVertices;
  85373. /** @hidden */
  85374. _indices: IndicesArray;
  85375. /** @hidden */
  85376. _vertexBuffers: {
  85377. [key: string]: VertexBuffer;
  85378. };
  85379. private _isDisposed;
  85380. private _extend;
  85381. private _boundingBias;
  85382. /** @hidden */
  85383. _delayInfo: Array<string>;
  85384. private _indexBuffer;
  85385. private _indexBufferIsUpdatable;
  85386. /** @hidden */
  85387. _boundingInfo: Nullable<BoundingInfo>;
  85388. /** @hidden */
  85389. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85390. /** @hidden */
  85391. _softwareSkinningFrameId: number;
  85392. private _vertexArrayObjects;
  85393. private _updatable;
  85394. /** @hidden */
  85395. _positions: Nullable<Vector3[]>;
  85396. /**
  85397. * 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
  85398. */
  85399. /**
  85400. * 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
  85401. */
  85402. boundingBias: Vector2;
  85403. /**
  85404. * Static function used to attach a new empty geometry to a mesh
  85405. * @param mesh defines the mesh to attach the geometry to
  85406. * @returns the new Geometry
  85407. */
  85408. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85409. /**
  85410. * Creates a new geometry
  85411. * @param id defines the unique ID
  85412. * @param scene defines the hosting scene
  85413. * @param vertexData defines the VertexData used to get geometry data
  85414. * @param updatable defines if geometry must be updatable (false by default)
  85415. * @param mesh defines the mesh that will be associated with the geometry
  85416. */
  85417. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85418. /**
  85419. * Gets the current extend of the geometry
  85420. */
  85421. readonly extend: {
  85422. minimum: Vector3;
  85423. maximum: Vector3;
  85424. };
  85425. /**
  85426. * Gets the hosting scene
  85427. * @returns the hosting Scene
  85428. */
  85429. getScene(): Scene;
  85430. /**
  85431. * Gets the hosting engine
  85432. * @returns the hosting Engine
  85433. */
  85434. getEngine(): Engine;
  85435. /**
  85436. * Defines if the geometry is ready to use
  85437. * @returns true if the geometry is ready to be used
  85438. */
  85439. isReady(): boolean;
  85440. /**
  85441. * Gets a value indicating that the geometry should not be serialized
  85442. */
  85443. readonly doNotSerialize: boolean;
  85444. /** @hidden */
  85445. _rebuild(): void;
  85446. /**
  85447. * Affects all geometry data in one call
  85448. * @param vertexData defines the geometry data
  85449. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85450. */
  85451. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85452. /**
  85453. * Set specific vertex data
  85454. * @param kind defines the data kind (Position, normal, etc...)
  85455. * @param data defines the vertex data to use
  85456. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85457. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85458. */
  85459. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85460. /**
  85461. * Removes a specific vertex data
  85462. * @param kind defines the data kind (Position, normal, etc...)
  85463. */
  85464. removeVerticesData(kind: string): void;
  85465. /**
  85466. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85467. * @param buffer defines the vertex buffer to use
  85468. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85469. */
  85470. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85471. /**
  85472. * Update a specific vertex buffer
  85473. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85474. * It will do nothing if the buffer is not updatable
  85475. * @param kind defines the data kind (Position, normal, etc...)
  85476. * @param data defines the data to use
  85477. * @param offset defines the offset in the target buffer where to store the data
  85478. * @param useBytes set to true if the offset is in bytes
  85479. */
  85480. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85481. /**
  85482. * Update a specific vertex buffer
  85483. * This function will create a new buffer if the current one is not updatable
  85484. * @param kind defines the data kind (Position, normal, etc...)
  85485. * @param data defines the data to use
  85486. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85487. */
  85488. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85489. private _updateBoundingInfo;
  85490. /** @hidden */
  85491. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85492. /**
  85493. * Gets total number of vertices
  85494. * @returns the total number of vertices
  85495. */
  85496. getTotalVertices(): number;
  85497. /**
  85498. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85499. * @param kind defines the data kind (Position, normal, etc...)
  85500. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85501. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85502. * @returns a float array containing vertex data
  85503. */
  85504. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85505. /**
  85506. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85507. * @param kind defines the data kind (Position, normal, etc...)
  85508. * @returns true if the vertex buffer with the specified kind is updatable
  85509. */
  85510. isVertexBufferUpdatable(kind: string): boolean;
  85511. /**
  85512. * Gets a specific vertex buffer
  85513. * @param kind defines the data kind (Position, normal, etc...)
  85514. * @returns a VertexBuffer
  85515. */
  85516. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85517. /**
  85518. * Returns all vertex buffers
  85519. * @return an object holding all vertex buffers indexed by kind
  85520. */
  85521. getVertexBuffers(): Nullable<{
  85522. [key: string]: VertexBuffer;
  85523. }>;
  85524. /**
  85525. * Gets a boolean indicating if specific vertex buffer is present
  85526. * @param kind defines the data kind (Position, normal, etc...)
  85527. * @returns true if data is present
  85528. */
  85529. isVerticesDataPresent(kind: string): boolean;
  85530. /**
  85531. * Gets a list of all attached data kinds (Position, normal, etc...)
  85532. * @returns a list of string containing all kinds
  85533. */
  85534. getVerticesDataKinds(): string[];
  85535. /**
  85536. * Update index buffer
  85537. * @param indices defines the indices to store in the index buffer
  85538. * @param offset defines the offset in the target buffer where to store the data
  85539. * @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)
  85540. */
  85541. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85542. /**
  85543. * Creates a new index buffer
  85544. * @param indices defines the indices to store in the index buffer
  85545. * @param totalVertices defines the total number of vertices (could be null)
  85546. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85547. */
  85548. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85549. /**
  85550. * Return the total number of indices
  85551. * @returns the total number of indices
  85552. */
  85553. getTotalIndices(): number;
  85554. /**
  85555. * Gets the index buffer array
  85556. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85557. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85558. * @returns the index buffer array
  85559. */
  85560. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85561. /**
  85562. * Gets the index buffer
  85563. * @return the index buffer
  85564. */
  85565. getIndexBuffer(): Nullable<DataBuffer>;
  85566. /** @hidden */
  85567. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85568. /**
  85569. * Release the associated resources for a specific mesh
  85570. * @param mesh defines the source mesh
  85571. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85572. */
  85573. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85574. /**
  85575. * Apply current geometry to a given mesh
  85576. * @param mesh defines the mesh to apply geometry to
  85577. */
  85578. applyToMesh(mesh: Mesh): void;
  85579. private _updateExtend;
  85580. private _applyToMesh;
  85581. private notifyUpdate;
  85582. /**
  85583. * Load the geometry if it was flagged as delay loaded
  85584. * @param scene defines the hosting scene
  85585. * @param onLoaded defines a callback called when the geometry is loaded
  85586. */
  85587. load(scene: Scene, onLoaded?: () => void): void;
  85588. private _queueLoad;
  85589. /**
  85590. * Invert the geometry to move from a right handed system to a left handed one.
  85591. */
  85592. toLeftHanded(): void;
  85593. /** @hidden */
  85594. _resetPointsArrayCache(): void;
  85595. /** @hidden */
  85596. _generatePointsArray(): boolean;
  85597. /**
  85598. * Gets a value indicating if the geometry is disposed
  85599. * @returns true if the geometry was disposed
  85600. */
  85601. isDisposed(): boolean;
  85602. private _disposeVertexArrayObjects;
  85603. /**
  85604. * Free all associated resources
  85605. */
  85606. dispose(): void;
  85607. /**
  85608. * Clone the current geometry into a new geometry
  85609. * @param id defines the unique ID of the new geometry
  85610. * @returns a new geometry object
  85611. */
  85612. copy(id: string): Geometry;
  85613. /**
  85614. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85615. * @return a JSON representation of the current geometry data (without the vertices data)
  85616. */
  85617. serialize(): any;
  85618. private toNumberArray;
  85619. /**
  85620. * Serialize all vertices data into a JSON oject
  85621. * @returns a JSON representation of the current geometry data
  85622. */
  85623. serializeVerticeData(): any;
  85624. /**
  85625. * Extracts a clone of a mesh geometry
  85626. * @param mesh defines the source mesh
  85627. * @param id defines the unique ID of the new geometry object
  85628. * @returns the new geometry object
  85629. */
  85630. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85631. /**
  85632. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85633. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85634. * Be aware Math.random() could cause collisions, but:
  85635. * "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"
  85636. * @returns a string containing a new GUID
  85637. */
  85638. static RandomId(): string;
  85639. /** @hidden */
  85640. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85641. private static _CleanMatricesWeights;
  85642. /**
  85643. * Create a new geometry from persisted data (Using .babylon file format)
  85644. * @param parsedVertexData defines the persisted data
  85645. * @param scene defines the hosting scene
  85646. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85647. * @returns the new geometry object
  85648. */
  85649. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85650. }
  85651. }
  85652. declare module BABYLON {
  85653. /**
  85654. * Define an interface for all classes that will get and set the data on vertices
  85655. */
  85656. export interface IGetSetVerticesData {
  85657. /**
  85658. * Gets a boolean indicating if specific vertex data is present
  85659. * @param kind defines the vertex data kind to use
  85660. * @returns true is data kind is present
  85661. */
  85662. isVerticesDataPresent(kind: string): boolean;
  85663. /**
  85664. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85665. * @param kind defines the data kind (Position, normal, etc...)
  85666. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85667. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85668. * @returns a float array containing vertex data
  85669. */
  85670. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85671. /**
  85672. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85673. * @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.
  85674. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85675. * @returns the indices array or an empty array if the mesh has no geometry
  85676. */
  85677. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85678. /**
  85679. * Set specific vertex data
  85680. * @param kind defines the data kind (Position, normal, etc...)
  85681. * @param data defines the vertex data to use
  85682. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85683. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85684. */
  85685. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85686. /**
  85687. * Update a specific associated vertex buffer
  85688. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85689. * - VertexBuffer.PositionKind
  85690. * - VertexBuffer.UVKind
  85691. * - VertexBuffer.UV2Kind
  85692. * - VertexBuffer.UV3Kind
  85693. * - VertexBuffer.UV4Kind
  85694. * - VertexBuffer.UV5Kind
  85695. * - VertexBuffer.UV6Kind
  85696. * - VertexBuffer.ColorKind
  85697. * - VertexBuffer.MatricesIndicesKind
  85698. * - VertexBuffer.MatricesIndicesExtraKind
  85699. * - VertexBuffer.MatricesWeightsKind
  85700. * - VertexBuffer.MatricesWeightsExtraKind
  85701. * @param data defines the data source
  85702. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85703. * @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)
  85704. */
  85705. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85706. /**
  85707. * Creates a new index buffer
  85708. * @param indices defines the indices to store in the index buffer
  85709. * @param totalVertices defines the total number of vertices (could be null)
  85710. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85711. */
  85712. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85713. }
  85714. /**
  85715. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85716. */
  85717. export class VertexData {
  85718. /**
  85719. * Mesh side orientation : usually the external or front surface
  85720. */
  85721. static readonly FRONTSIDE: number;
  85722. /**
  85723. * Mesh side orientation : usually the internal or back surface
  85724. */
  85725. static readonly BACKSIDE: number;
  85726. /**
  85727. * Mesh side orientation : both internal and external or front and back surfaces
  85728. */
  85729. static readonly DOUBLESIDE: number;
  85730. /**
  85731. * Mesh side orientation : by default, `FRONTSIDE`
  85732. */
  85733. static readonly DEFAULTSIDE: number;
  85734. /**
  85735. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85736. */
  85737. positions: Nullable<FloatArray>;
  85738. /**
  85739. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85740. */
  85741. normals: Nullable<FloatArray>;
  85742. /**
  85743. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85744. */
  85745. tangents: Nullable<FloatArray>;
  85746. /**
  85747. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85748. */
  85749. uvs: Nullable<FloatArray>;
  85750. /**
  85751. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85752. */
  85753. uvs2: Nullable<FloatArray>;
  85754. /**
  85755. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85756. */
  85757. uvs3: Nullable<FloatArray>;
  85758. /**
  85759. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85760. */
  85761. uvs4: Nullable<FloatArray>;
  85762. /**
  85763. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85764. */
  85765. uvs5: Nullable<FloatArray>;
  85766. /**
  85767. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85768. */
  85769. uvs6: Nullable<FloatArray>;
  85770. /**
  85771. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85772. */
  85773. colors: Nullable<FloatArray>;
  85774. /**
  85775. * 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).
  85776. */
  85777. matricesIndices: Nullable<FloatArray>;
  85778. /**
  85779. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85780. */
  85781. matricesWeights: Nullable<FloatArray>;
  85782. /**
  85783. * An array extending the number of possible indices
  85784. */
  85785. matricesIndicesExtra: Nullable<FloatArray>;
  85786. /**
  85787. * An array extending the number of possible weights when the number of indices is extended
  85788. */
  85789. matricesWeightsExtra: Nullable<FloatArray>;
  85790. /**
  85791. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85792. */
  85793. indices: Nullable<IndicesArray>;
  85794. /**
  85795. * Uses the passed data array to set the set the values for the specified kind of data
  85796. * @param data a linear array of floating numbers
  85797. * @param kind the type of data that is being set, eg positions, colors etc
  85798. */
  85799. set(data: FloatArray, kind: string): void;
  85800. /**
  85801. * Associates the vertexData to the passed Mesh.
  85802. * Sets it as updatable or not (default `false`)
  85803. * @param mesh the mesh the vertexData is applied to
  85804. * @param updatable when used and having the value true allows new data to update the vertexData
  85805. * @returns the VertexData
  85806. */
  85807. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85808. /**
  85809. * Associates the vertexData to the passed Geometry.
  85810. * Sets it as updatable or not (default `false`)
  85811. * @param geometry the geometry the vertexData is applied to
  85812. * @param updatable when used and having the value true allows new data to update the vertexData
  85813. * @returns VertexData
  85814. */
  85815. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85816. /**
  85817. * Updates the associated mesh
  85818. * @param mesh the mesh to be updated
  85819. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85820. * @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
  85821. * @returns VertexData
  85822. */
  85823. updateMesh(mesh: Mesh): VertexData;
  85824. /**
  85825. * Updates the associated geometry
  85826. * @param geometry the geometry to be updated
  85827. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85828. * @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
  85829. * @returns VertexData.
  85830. */
  85831. updateGeometry(geometry: Geometry): VertexData;
  85832. private _applyTo;
  85833. private _update;
  85834. /**
  85835. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85836. * @param matrix the transforming matrix
  85837. * @returns the VertexData
  85838. */
  85839. transform(matrix: Matrix): VertexData;
  85840. /**
  85841. * Merges the passed VertexData into the current one
  85842. * @param other the VertexData to be merged into the current one
  85843. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85844. * @returns the modified VertexData
  85845. */
  85846. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85847. private _mergeElement;
  85848. private _validate;
  85849. /**
  85850. * Serializes the VertexData
  85851. * @returns a serialized object
  85852. */
  85853. serialize(): any;
  85854. /**
  85855. * Extracts the vertexData from a mesh
  85856. * @param mesh the mesh from which to extract the VertexData
  85857. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85858. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85859. * @returns the object VertexData associated to the passed mesh
  85860. */
  85861. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85862. /**
  85863. * Extracts the vertexData from the geometry
  85864. * @param geometry the geometry from which to extract the VertexData
  85865. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85866. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85867. * @returns the object VertexData associated to the passed mesh
  85868. */
  85869. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85870. private static _ExtractFrom;
  85871. /**
  85872. * Creates the VertexData for a Ribbon
  85873. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85874. * * pathArray array of paths, each of which an array of successive Vector3
  85875. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85876. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85877. * * 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
  85878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85879. * * 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)
  85880. * * 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)
  85881. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85882. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85883. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85884. * @returns the VertexData of the ribbon
  85885. */
  85886. static CreateRibbon(options: {
  85887. pathArray: Vector3[][];
  85888. closeArray?: boolean;
  85889. closePath?: boolean;
  85890. offset?: number;
  85891. sideOrientation?: number;
  85892. frontUVs?: Vector4;
  85893. backUVs?: Vector4;
  85894. invertUV?: boolean;
  85895. uvs?: Vector2[];
  85896. colors?: Color4[];
  85897. }): VertexData;
  85898. /**
  85899. * Creates the VertexData for a box
  85900. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85901. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85902. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85903. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85904. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85905. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85906. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85907. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85908. * * 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)
  85909. * * 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)
  85910. * @returns the VertexData of the box
  85911. */
  85912. static CreateBox(options: {
  85913. size?: number;
  85914. width?: number;
  85915. height?: number;
  85916. depth?: number;
  85917. faceUV?: Vector4[];
  85918. faceColors?: Color4[];
  85919. sideOrientation?: number;
  85920. frontUVs?: Vector4;
  85921. backUVs?: Vector4;
  85922. }): VertexData;
  85923. /**
  85924. * Creates the VertexData for a tiled box
  85925. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85926. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85927. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85928. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85929. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85930. * @returns the VertexData of the box
  85931. */
  85932. static CreateTiledBox(options: {
  85933. pattern?: number;
  85934. width?: number;
  85935. height?: number;
  85936. depth?: number;
  85937. tileSize?: number;
  85938. tileWidth?: number;
  85939. tileHeight?: number;
  85940. alignHorizontal?: number;
  85941. alignVertical?: number;
  85942. faceUV?: Vector4[];
  85943. faceColors?: Color4[];
  85944. sideOrientation?: number;
  85945. }): VertexData;
  85946. /**
  85947. * Creates the VertexData for a tiled plane
  85948. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85949. * * pattern a limited pattern arrangement depending on the number
  85950. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85951. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85952. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85954. * * 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)
  85955. * * 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)
  85956. * @returns the VertexData of the tiled plane
  85957. */
  85958. static CreateTiledPlane(options: {
  85959. pattern?: number;
  85960. tileSize?: number;
  85961. tileWidth?: number;
  85962. tileHeight?: number;
  85963. size?: number;
  85964. width?: number;
  85965. height?: number;
  85966. alignHorizontal?: number;
  85967. alignVertical?: number;
  85968. sideOrientation?: number;
  85969. frontUVs?: Vector4;
  85970. backUVs?: Vector4;
  85971. }): VertexData;
  85972. /**
  85973. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85974. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85975. * * segments sets the number of horizontal strips optional, default 32
  85976. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85977. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85978. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85979. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85980. * * 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
  85981. * * 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
  85982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85983. * * 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)
  85984. * * 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)
  85985. * @returns the VertexData of the ellipsoid
  85986. */
  85987. static CreateSphere(options: {
  85988. segments?: number;
  85989. diameter?: number;
  85990. diameterX?: number;
  85991. diameterY?: number;
  85992. diameterZ?: number;
  85993. arc?: number;
  85994. slice?: number;
  85995. sideOrientation?: number;
  85996. frontUVs?: Vector4;
  85997. backUVs?: Vector4;
  85998. }): VertexData;
  85999. /**
  86000. * Creates the VertexData for a cylinder, cone or prism
  86001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86002. * * height sets the height (y direction) of the cylinder, optional, default 2
  86003. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86004. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86005. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86006. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86007. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86008. * * 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
  86009. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86010. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86011. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86012. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86014. * * 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)
  86015. * * 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)
  86016. * @returns the VertexData of the cylinder, cone or prism
  86017. */
  86018. static CreateCylinder(options: {
  86019. height?: number;
  86020. diameterTop?: number;
  86021. diameterBottom?: number;
  86022. diameter?: number;
  86023. tessellation?: number;
  86024. subdivisions?: number;
  86025. arc?: number;
  86026. faceColors?: Color4[];
  86027. faceUV?: Vector4[];
  86028. hasRings?: boolean;
  86029. enclose?: boolean;
  86030. sideOrientation?: number;
  86031. frontUVs?: Vector4;
  86032. backUVs?: Vector4;
  86033. }): VertexData;
  86034. /**
  86035. * Creates the VertexData for a torus
  86036. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86037. * * diameter the diameter of the torus, optional default 1
  86038. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86039. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86041. * * 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)
  86042. * * 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)
  86043. * @returns the VertexData of the torus
  86044. */
  86045. static CreateTorus(options: {
  86046. diameter?: number;
  86047. thickness?: number;
  86048. tessellation?: number;
  86049. sideOrientation?: number;
  86050. frontUVs?: Vector4;
  86051. backUVs?: Vector4;
  86052. }): VertexData;
  86053. /**
  86054. * Creates the VertexData of the LineSystem
  86055. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86056. * - lines an array of lines, each line being an array of successive Vector3
  86057. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86058. * @returns the VertexData of the LineSystem
  86059. */
  86060. static CreateLineSystem(options: {
  86061. lines: Vector3[][];
  86062. colors?: Nullable<Color4[][]>;
  86063. }): VertexData;
  86064. /**
  86065. * Create the VertexData for a DashedLines
  86066. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86067. * - points an array successive Vector3
  86068. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86069. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86070. * - dashNb the intended total number of dashes, optional, default 200
  86071. * @returns the VertexData for the DashedLines
  86072. */
  86073. static CreateDashedLines(options: {
  86074. points: Vector3[];
  86075. dashSize?: number;
  86076. gapSize?: number;
  86077. dashNb?: number;
  86078. }): VertexData;
  86079. /**
  86080. * Creates the VertexData for a Ground
  86081. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86082. * - width the width (x direction) of the ground, optional, default 1
  86083. * - height the height (z direction) of the ground, optional, default 1
  86084. * - subdivisions the number of subdivisions per side, optional, default 1
  86085. * @returns the VertexData of the Ground
  86086. */
  86087. static CreateGround(options: {
  86088. width?: number;
  86089. height?: number;
  86090. subdivisions?: number;
  86091. subdivisionsX?: number;
  86092. subdivisionsY?: number;
  86093. }): VertexData;
  86094. /**
  86095. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86096. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86097. * * xmin the ground minimum X coordinate, optional, default -1
  86098. * * zmin the ground minimum Z coordinate, optional, default -1
  86099. * * xmax the ground maximum X coordinate, optional, default 1
  86100. * * zmax the ground maximum Z coordinate, optional, default 1
  86101. * * 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}
  86102. * * 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}
  86103. * @returns the VertexData of the TiledGround
  86104. */
  86105. static CreateTiledGround(options: {
  86106. xmin: number;
  86107. zmin: number;
  86108. xmax: number;
  86109. zmax: number;
  86110. subdivisions?: {
  86111. w: number;
  86112. h: number;
  86113. };
  86114. precision?: {
  86115. w: number;
  86116. h: number;
  86117. };
  86118. }): VertexData;
  86119. /**
  86120. * Creates the VertexData of the Ground designed from a heightmap
  86121. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86122. * * width the width (x direction) of the ground
  86123. * * height the height (z direction) of the ground
  86124. * * subdivisions the number of subdivisions per side
  86125. * * minHeight the minimum altitude on the ground, optional, default 0
  86126. * * maxHeight the maximum altitude on the ground, optional default 1
  86127. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86128. * * buffer the array holding the image color data
  86129. * * bufferWidth the width of image
  86130. * * bufferHeight the height of image
  86131. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86132. * @returns the VertexData of the Ground designed from a heightmap
  86133. */
  86134. static CreateGroundFromHeightMap(options: {
  86135. width: number;
  86136. height: number;
  86137. subdivisions: number;
  86138. minHeight: number;
  86139. maxHeight: number;
  86140. colorFilter: Color3;
  86141. buffer: Uint8Array;
  86142. bufferWidth: number;
  86143. bufferHeight: number;
  86144. alphaFilter: number;
  86145. }): VertexData;
  86146. /**
  86147. * Creates the VertexData for a Plane
  86148. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86149. * * size sets the width and height of the plane to the value of size, optional default 1
  86150. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86151. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86152. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86153. * * 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)
  86154. * * 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)
  86155. * @returns the VertexData of the box
  86156. */
  86157. static CreatePlane(options: {
  86158. size?: number;
  86159. width?: number;
  86160. height?: number;
  86161. sideOrientation?: number;
  86162. frontUVs?: Vector4;
  86163. backUVs?: Vector4;
  86164. }): VertexData;
  86165. /**
  86166. * Creates the VertexData of the Disc or regular Polygon
  86167. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86168. * * radius the radius of the disc, optional default 0.5
  86169. * * tessellation the number of polygon sides, optional, default 64
  86170. * * 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
  86171. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86172. * * 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)
  86173. * * 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)
  86174. * @returns the VertexData of the box
  86175. */
  86176. static CreateDisc(options: {
  86177. radius?: number;
  86178. tessellation?: number;
  86179. arc?: number;
  86180. sideOrientation?: number;
  86181. frontUVs?: Vector4;
  86182. backUVs?: Vector4;
  86183. }): VertexData;
  86184. /**
  86185. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86186. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86187. * @param polygon a mesh built from polygonTriangulation.build()
  86188. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86189. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86190. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86191. * @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)
  86192. * @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)
  86193. * @returns the VertexData of the Polygon
  86194. */
  86195. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86196. /**
  86197. * Creates the VertexData of the IcoSphere
  86198. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86199. * * radius the radius of the IcoSphere, optional default 1
  86200. * * radiusX allows stretching in the x direction, optional, default radius
  86201. * * radiusY allows stretching in the y direction, optional, default radius
  86202. * * radiusZ allows stretching in the z direction, optional, default radius
  86203. * * flat when true creates a flat shaded mesh, optional, default true
  86204. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86206. * * 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)
  86207. * * 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)
  86208. * @returns the VertexData of the IcoSphere
  86209. */
  86210. static CreateIcoSphere(options: {
  86211. radius?: number;
  86212. radiusX?: number;
  86213. radiusY?: number;
  86214. radiusZ?: number;
  86215. flat?: boolean;
  86216. subdivisions?: number;
  86217. sideOrientation?: number;
  86218. frontUVs?: Vector4;
  86219. backUVs?: Vector4;
  86220. }): VertexData;
  86221. /**
  86222. * Creates the VertexData for a Polyhedron
  86223. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86224. * * type provided types are:
  86225. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86226. * * 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)
  86227. * * size the size of the IcoSphere, optional default 1
  86228. * * sizeX allows stretching in the x direction, optional, default size
  86229. * * sizeY allows stretching in the y direction, optional, default size
  86230. * * sizeZ allows stretching in the z direction, optional, default size
  86231. * * 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
  86232. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86233. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86234. * * flat when true creates a flat shaded mesh, optional, default true
  86235. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86237. * * 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)
  86238. * * 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)
  86239. * @returns the VertexData of the Polyhedron
  86240. */
  86241. static CreatePolyhedron(options: {
  86242. type?: number;
  86243. size?: number;
  86244. sizeX?: number;
  86245. sizeY?: number;
  86246. sizeZ?: number;
  86247. custom?: any;
  86248. faceUV?: Vector4[];
  86249. faceColors?: Color4[];
  86250. flat?: boolean;
  86251. sideOrientation?: number;
  86252. frontUVs?: Vector4;
  86253. backUVs?: Vector4;
  86254. }): VertexData;
  86255. /**
  86256. * Creates the VertexData for a TorusKnot
  86257. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86258. * * radius the radius of the torus knot, optional, default 2
  86259. * * tube the thickness of the tube, optional, default 0.5
  86260. * * radialSegments the number of sides on each tube segments, optional, default 32
  86261. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86262. * * p the number of windings around the z axis, optional, default 2
  86263. * * q the number of windings around the x axis, optional, default 3
  86264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86265. * * 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)
  86266. * * 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)
  86267. * @returns the VertexData of the Torus Knot
  86268. */
  86269. static CreateTorusKnot(options: {
  86270. radius?: number;
  86271. tube?: number;
  86272. radialSegments?: number;
  86273. tubularSegments?: number;
  86274. p?: number;
  86275. q?: number;
  86276. sideOrientation?: number;
  86277. frontUVs?: Vector4;
  86278. backUVs?: Vector4;
  86279. }): VertexData;
  86280. /**
  86281. * Compute normals for given positions and indices
  86282. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86283. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86284. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86285. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86286. * * facetNormals : optional array of facet normals (vector3)
  86287. * * facetPositions : optional array of facet positions (vector3)
  86288. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86289. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86290. * * bInfo : optional bounding info, required for facetPartitioning computation
  86291. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86292. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86293. * * useRightHandedSystem: optional boolean to for right handed system computation
  86294. * * depthSort : optional boolean to enable the facet depth sort computation
  86295. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86296. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86297. */
  86298. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86299. facetNormals?: any;
  86300. facetPositions?: any;
  86301. facetPartitioning?: any;
  86302. ratio?: number;
  86303. bInfo?: any;
  86304. bbSize?: Vector3;
  86305. subDiv?: any;
  86306. useRightHandedSystem?: boolean;
  86307. depthSort?: boolean;
  86308. distanceTo?: Vector3;
  86309. depthSortedFacets?: any;
  86310. }): void;
  86311. /** @hidden */
  86312. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86313. /**
  86314. * Applies VertexData created from the imported parameters to the geometry
  86315. * @param parsedVertexData the parsed data from an imported file
  86316. * @param geometry the geometry to apply the VertexData to
  86317. */
  86318. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86319. }
  86320. }
  86321. declare module BABYLON {
  86322. /**
  86323. * Class containing static functions to help procedurally build meshes
  86324. */
  86325. export class DiscBuilder {
  86326. /**
  86327. * Creates a plane polygonal mesh. By default, this is a disc
  86328. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86329. * * 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
  86330. * * 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
  86331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86334. * @param name defines the name of the mesh
  86335. * @param options defines the options used to create the mesh
  86336. * @param scene defines the hosting scene
  86337. * @returns the plane polygonal mesh
  86338. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86339. */
  86340. static CreateDisc(name: string, options: {
  86341. radius?: number;
  86342. tessellation?: number;
  86343. arc?: number;
  86344. updatable?: boolean;
  86345. sideOrientation?: number;
  86346. frontUVs?: Vector4;
  86347. backUVs?: Vector4;
  86348. }, scene?: Nullable<Scene>): Mesh;
  86349. }
  86350. }
  86351. declare module BABYLON {
  86352. /**
  86353. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86354. *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.
  86355. * The SPS is also a particle system. It provides some methods to manage the particles.
  86356. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86357. *
  86358. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86359. */
  86360. export class SolidParticleSystem implements IDisposable {
  86361. /**
  86362. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86363. * Example : var p = SPS.particles[i];
  86364. */
  86365. particles: SolidParticle[];
  86366. /**
  86367. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86368. */
  86369. nbParticles: number;
  86370. /**
  86371. * If the particles must ever face the camera (default false). Useful for planar particles.
  86372. */
  86373. billboard: boolean;
  86374. /**
  86375. * Recompute normals when adding a shape
  86376. */
  86377. recomputeNormals: boolean;
  86378. /**
  86379. * This a counter ofr your own usage. It's not set by any SPS functions.
  86380. */
  86381. counter: number;
  86382. /**
  86383. * The SPS name. This name is also given to the underlying mesh.
  86384. */
  86385. name: string;
  86386. /**
  86387. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86388. */
  86389. mesh: Mesh;
  86390. /**
  86391. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86392. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86393. */
  86394. vars: any;
  86395. /**
  86396. * This array is populated when the SPS is set as 'pickable'.
  86397. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86398. * Each element of this array is an object `{idx: int, faceId: int}`.
  86399. * `idx` is the picked particle index in the `SPS.particles` array
  86400. * `faceId` is the picked face index counted within this particle.
  86401. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86402. */
  86403. pickedParticles: {
  86404. idx: number;
  86405. faceId: number;
  86406. }[];
  86407. /**
  86408. * This array is populated when `enableDepthSort` is set to true.
  86409. * Each element of this array is an instance of the class DepthSortedParticle.
  86410. */
  86411. depthSortedParticles: DepthSortedParticle[];
  86412. /**
  86413. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86414. * @hidden
  86415. */
  86416. _bSphereOnly: boolean;
  86417. /**
  86418. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86419. * @hidden
  86420. */
  86421. _bSphereRadiusFactor: number;
  86422. private _scene;
  86423. private _positions;
  86424. private _indices;
  86425. private _normals;
  86426. private _colors;
  86427. private _uvs;
  86428. private _indices32;
  86429. private _positions32;
  86430. private _normals32;
  86431. private _fixedNormal32;
  86432. private _colors32;
  86433. private _uvs32;
  86434. private _index;
  86435. private _updatable;
  86436. private _pickable;
  86437. private _isVisibilityBoxLocked;
  86438. private _alwaysVisible;
  86439. private _depthSort;
  86440. private _shapeCounter;
  86441. private _copy;
  86442. private _color;
  86443. private _computeParticleColor;
  86444. private _computeParticleTexture;
  86445. private _computeParticleRotation;
  86446. private _computeParticleVertex;
  86447. private _computeBoundingBox;
  86448. private _depthSortParticles;
  86449. private _camera;
  86450. private _mustUnrotateFixedNormals;
  86451. private _particlesIntersect;
  86452. private _needs32Bits;
  86453. /**
  86454. * Creates a SPS (Solid Particle System) object.
  86455. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86456. * @param scene (Scene) is the scene in which the SPS is added.
  86457. * @param options defines the options of the sps e.g.
  86458. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86459. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86460. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86461. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86462. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86463. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86464. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86465. */
  86466. constructor(name: string, scene: Scene, options?: {
  86467. updatable?: boolean;
  86468. isPickable?: boolean;
  86469. enableDepthSort?: boolean;
  86470. particleIntersection?: boolean;
  86471. boundingSphereOnly?: boolean;
  86472. bSphereRadiusFactor?: number;
  86473. });
  86474. /**
  86475. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86476. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86477. * @returns the created mesh
  86478. */
  86479. buildMesh(): Mesh;
  86480. /**
  86481. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86482. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86483. * Thus the particles generated from `digest()` have their property `position` set yet.
  86484. * @param mesh ( Mesh ) is the mesh to be digested
  86485. * @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
  86486. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86487. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86488. * @returns the current SPS
  86489. */
  86490. digest(mesh: Mesh, options?: {
  86491. facetNb?: number;
  86492. number?: number;
  86493. delta?: number;
  86494. }): SolidParticleSystem;
  86495. private _unrotateFixedNormals;
  86496. private _resetCopy;
  86497. private _meshBuilder;
  86498. private _posToShape;
  86499. private _uvsToShapeUV;
  86500. private _addParticle;
  86501. /**
  86502. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86503. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86504. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86505. * @param nb (positive integer) the number of particles to be created from this model
  86506. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86507. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86508. * @returns the number of shapes in the system
  86509. */
  86510. addShape(mesh: Mesh, nb: number, options?: {
  86511. positionFunction?: any;
  86512. vertexFunction?: any;
  86513. }): number;
  86514. private _rebuildParticle;
  86515. /**
  86516. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86517. * @returns the SPS.
  86518. */
  86519. rebuildMesh(): SolidParticleSystem;
  86520. /**
  86521. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86522. * This method calls `updateParticle()` for each particle of the SPS.
  86523. * For an animated SPS, it is usually called within the render loop.
  86524. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86525. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86526. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86527. * @returns the SPS.
  86528. */
  86529. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86530. /**
  86531. * Disposes the SPS.
  86532. */
  86533. dispose(): void;
  86534. /**
  86535. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86536. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86537. * @returns the SPS.
  86538. */
  86539. refreshVisibleSize(): SolidParticleSystem;
  86540. /**
  86541. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86542. * @param size the size (float) of the visibility box
  86543. * note : this doesn't lock the SPS mesh bounding box.
  86544. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86545. */
  86546. setVisibilityBox(size: number): void;
  86547. /**
  86548. * Gets whether the SPS as always visible or not
  86549. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86550. */
  86551. /**
  86552. * Sets the SPS as always visible or not
  86553. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86554. */
  86555. isAlwaysVisible: boolean;
  86556. /**
  86557. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86558. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86559. */
  86560. /**
  86561. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86562. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86563. */
  86564. isVisibilityBoxLocked: boolean;
  86565. /**
  86566. * Tells to `setParticles()` to compute the particle rotations or not.
  86567. * Default value : true. The SPS is faster when it's set to false.
  86568. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86569. */
  86570. /**
  86571. * Gets if `setParticles()` computes the particle rotations or not.
  86572. * Default value : true. The SPS is faster when it's set to false.
  86573. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86574. */
  86575. computeParticleRotation: boolean;
  86576. /**
  86577. * Tells to `setParticles()` to compute the particle colors or not.
  86578. * Default value : true. The SPS is faster when it's set to false.
  86579. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86580. */
  86581. /**
  86582. * Gets if `setParticles()` computes the particle colors or not.
  86583. * Default value : true. The SPS is faster when it's set to false.
  86584. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86585. */
  86586. computeParticleColor: boolean;
  86587. /**
  86588. * Gets if `setParticles()` computes the particle textures or not.
  86589. * Default value : true. The SPS is faster when it's set to false.
  86590. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86591. */
  86592. computeParticleTexture: boolean;
  86593. /**
  86594. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86595. * Default value : false. The SPS is faster when it's set to false.
  86596. * Note : the particle custom vertex positions aren't stored values.
  86597. */
  86598. /**
  86599. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86600. * Default value : false. The SPS is faster when it's set to false.
  86601. * Note : the particle custom vertex positions aren't stored values.
  86602. */
  86603. computeParticleVertex: boolean;
  86604. /**
  86605. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86606. */
  86607. /**
  86608. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86609. */
  86610. computeBoundingBox: boolean;
  86611. /**
  86612. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86613. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86614. * Default : `true`
  86615. */
  86616. /**
  86617. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86618. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86619. * Default : `true`
  86620. */
  86621. depthSortParticles: boolean;
  86622. /**
  86623. * This function does nothing. It may be overwritten to set all the particle first values.
  86624. * The SPS doesn't call this function, you may have to call it by your own.
  86625. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86626. */
  86627. initParticles(): void;
  86628. /**
  86629. * This function does nothing. It may be overwritten to recycle a particle.
  86630. * The SPS doesn't call this function, you may have to call it by your own.
  86631. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86632. * @param particle The particle to recycle
  86633. * @returns the recycled particle
  86634. */
  86635. recycleParticle(particle: SolidParticle): SolidParticle;
  86636. /**
  86637. * Updates a particle : this function should be overwritten by the user.
  86638. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86639. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86640. * @example : just set a particle position or velocity and recycle conditions
  86641. * @param particle The particle to update
  86642. * @returns the updated particle
  86643. */
  86644. updateParticle(particle: SolidParticle): SolidParticle;
  86645. /**
  86646. * Updates a vertex of a particle : it can be overwritten by the user.
  86647. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86648. * @param particle the current particle
  86649. * @param vertex the current index of the current particle
  86650. * @param pt the index of the current vertex in the particle shape
  86651. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86652. * @example : just set a vertex particle position
  86653. * @returns the updated vertex
  86654. */
  86655. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86656. /**
  86657. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86658. * This does nothing and may be overwritten by the user.
  86659. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86660. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86661. * @param update the boolean update value actually passed to setParticles()
  86662. */
  86663. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86664. /**
  86665. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86666. * This will be passed three parameters.
  86667. * This does nothing and may be overwritten by the user.
  86668. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86669. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86670. * @param update the boolean update value actually passed to setParticles()
  86671. */
  86672. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86673. }
  86674. }
  86675. declare module BABYLON {
  86676. /**
  86677. * Represents one particle of a solid particle system.
  86678. */
  86679. export class SolidParticle {
  86680. /**
  86681. * particle global index
  86682. */
  86683. idx: number;
  86684. /**
  86685. * The color of the particle
  86686. */
  86687. color: Nullable<Color4>;
  86688. /**
  86689. * The world space position of the particle.
  86690. */
  86691. position: Vector3;
  86692. /**
  86693. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86694. */
  86695. rotation: Vector3;
  86696. /**
  86697. * The world space rotation quaternion of the particle.
  86698. */
  86699. rotationQuaternion: Nullable<Quaternion>;
  86700. /**
  86701. * The scaling of the particle.
  86702. */
  86703. scaling: Vector3;
  86704. /**
  86705. * The uvs of the particle.
  86706. */
  86707. uvs: Vector4;
  86708. /**
  86709. * The current speed of the particle.
  86710. */
  86711. velocity: Vector3;
  86712. /**
  86713. * The pivot point in the particle local space.
  86714. */
  86715. pivot: Vector3;
  86716. /**
  86717. * Must the particle be translated from its pivot point in its local space ?
  86718. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86719. * Default : false
  86720. */
  86721. translateFromPivot: boolean;
  86722. /**
  86723. * Is the particle active or not ?
  86724. */
  86725. alive: boolean;
  86726. /**
  86727. * Is the particle visible or not ?
  86728. */
  86729. isVisible: boolean;
  86730. /**
  86731. * Index of this particle in the global "positions" array (Internal use)
  86732. * @hidden
  86733. */
  86734. _pos: number;
  86735. /**
  86736. * @hidden Index of this particle in the global "indices" array (Internal use)
  86737. */
  86738. _ind: number;
  86739. /**
  86740. * @hidden ModelShape of this particle (Internal use)
  86741. */
  86742. _model: ModelShape;
  86743. /**
  86744. * ModelShape id of this particle
  86745. */
  86746. shapeId: number;
  86747. /**
  86748. * Index of the particle in its shape id (Internal use)
  86749. */
  86750. idxInShape: number;
  86751. /**
  86752. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86753. */
  86754. _modelBoundingInfo: BoundingInfo;
  86755. /**
  86756. * @hidden Particle BoundingInfo object (Internal use)
  86757. */
  86758. _boundingInfo: BoundingInfo;
  86759. /**
  86760. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86761. */
  86762. _sps: SolidParticleSystem;
  86763. /**
  86764. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86765. */
  86766. _stillInvisible: boolean;
  86767. /**
  86768. * @hidden Last computed particle rotation matrix
  86769. */
  86770. _rotationMatrix: number[];
  86771. /**
  86772. * Parent particle Id, if any.
  86773. * Default null.
  86774. */
  86775. parentId: Nullable<number>;
  86776. /**
  86777. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86778. * The possible values are :
  86779. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86780. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86781. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86782. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86783. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86784. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86785. * */
  86786. cullingStrategy: number;
  86787. /**
  86788. * @hidden Internal global position in the SPS.
  86789. */
  86790. _globalPosition: Vector3;
  86791. /**
  86792. * Creates a Solid Particle object.
  86793. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86794. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86795. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86796. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86797. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86798. * @param shapeId (integer) is the model shape identifier in the SPS.
  86799. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86800. * @param sps defines the sps it is associated to
  86801. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86802. */
  86803. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86804. /**
  86805. * Legacy support, changed scale to scaling
  86806. */
  86807. /**
  86808. * Legacy support, changed scale to scaling
  86809. */
  86810. scale: Vector3;
  86811. /**
  86812. * Legacy support, changed quaternion to rotationQuaternion
  86813. */
  86814. /**
  86815. * Legacy support, changed quaternion to rotationQuaternion
  86816. */
  86817. quaternion: Nullable<Quaternion>;
  86818. /**
  86819. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86820. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86821. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86822. * @returns true if it intersects
  86823. */
  86824. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86825. /**
  86826. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86827. * A particle is in the frustum if its bounding box intersects the frustum
  86828. * @param frustumPlanes defines the frustum to test
  86829. * @returns true if the particle is in the frustum planes
  86830. */
  86831. isInFrustum(frustumPlanes: Plane[]): boolean;
  86832. /**
  86833. * get the rotation matrix of the particle
  86834. * @hidden
  86835. */
  86836. getRotationMatrix(m: Matrix): void;
  86837. }
  86838. /**
  86839. * Represents the shape of the model used by one particle of a solid particle system.
  86840. * SPS internal tool, don't use it manually.
  86841. */
  86842. export class ModelShape {
  86843. /**
  86844. * The shape id
  86845. * @hidden
  86846. */
  86847. shapeID: number;
  86848. /**
  86849. * flat array of model positions (internal use)
  86850. * @hidden
  86851. */
  86852. _shape: Vector3[];
  86853. /**
  86854. * flat array of model UVs (internal use)
  86855. * @hidden
  86856. */
  86857. _shapeUV: number[];
  86858. /**
  86859. * length of the shape in the model indices array (internal use)
  86860. * @hidden
  86861. */
  86862. _indicesLength: number;
  86863. /**
  86864. * Custom position function (internal use)
  86865. * @hidden
  86866. */
  86867. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  86868. /**
  86869. * Custom vertex function (internal use)
  86870. * @hidden
  86871. */
  86872. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  86873. /**
  86874. * 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.
  86875. * SPS internal tool, don't use it manually.
  86876. * @hidden
  86877. */
  86878. 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>);
  86879. }
  86880. /**
  86881. * Represents a Depth Sorted Particle in the solid particle system.
  86882. */
  86883. export class DepthSortedParticle {
  86884. /**
  86885. * Index of the particle in the "indices" array
  86886. */
  86887. ind: number;
  86888. /**
  86889. * Length of the particle shape in the "indices" array
  86890. */
  86891. indicesLength: number;
  86892. /**
  86893. * Squared distance from the particle to the camera
  86894. */
  86895. sqDistance: number;
  86896. }
  86897. }
  86898. declare module BABYLON {
  86899. /**
  86900. * @hidden
  86901. */
  86902. export class _MeshCollisionData {
  86903. _checkCollisions: boolean;
  86904. _collisionMask: number;
  86905. _collisionGroup: number;
  86906. _collider: Nullable<Collider>;
  86907. _oldPositionForCollisions: Vector3;
  86908. _diffPositionForCollisions: Vector3;
  86909. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  86910. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  86911. }
  86912. }
  86913. declare module BABYLON {
  86914. /** @hidden */
  86915. class _FacetDataStorage {
  86916. facetPositions: Vector3[];
  86917. facetNormals: Vector3[];
  86918. facetPartitioning: number[][];
  86919. facetNb: number;
  86920. partitioningSubdivisions: number;
  86921. partitioningBBoxRatio: number;
  86922. facetDataEnabled: boolean;
  86923. facetParameters: any;
  86924. bbSize: Vector3;
  86925. subDiv: {
  86926. max: number;
  86927. X: number;
  86928. Y: number;
  86929. Z: number;
  86930. };
  86931. facetDepthSort: boolean;
  86932. facetDepthSortEnabled: boolean;
  86933. depthSortedIndices: IndicesArray;
  86934. depthSortedFacets: {
  86935. ind: number;
  86936. sqDistance: number;
  86937. }[];
  86938. facetDepthSortFunction: (f1: {
  86939. ind: number;
  86940. sqDistance: number;
  86941. }, f2: {
  86942. ind: number;
  86943. sqDistance: number;
  86944. }) => number;
  86945. facetDepthSortFrom: Vector3;
  86946. facetDepthSortOrigin: Vector3;
  86947. invertedMatrix: Matrix;
  86948. }
  86949. /**
  86950. * @hidden
  86951. **/
  86952. class _InternalAbstractMeshDataInfo {
  86953. _hasVertexAlpha: boolean;
  86954. _useVertexColors: boolean;
  86955. _numBoneInfluencers: number;
  86956. _applyFog: boolean;
  86957. _receiveShadows: boolean;
  86958. _facetData: _FacetDataStorage;
  86959. _visibility: number;
  86960. _skeleton: Nullable<Skeleton>;
  86961. _layerMask: number;
  86962. _computeBonesUsingShaders: boolean;
  86963. _isActive: boolean;
  86964. _onlyForInstances: boolean;
  86965. _isActiveIntermediate: boolean;
  86966. _onlyForInstancesIntermediate: boolean;
  86967. }
  86968. /**
  86969. * Class used to store all common mesh properties
  86970. */
  86971. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  86972. /** No occlusion */
  86973. static OCCLUSION_TYPE_NONE: number;
  86974. /** Occlusion set to optimisitic */
  86975. static OCCLUSION_TYPE_OPTIMISTIC: number;
  86976. /** Occlusion set to strict */
  86977. static OCCLUSION_TYPE_STRICT: number;
  86978. /** Use an accurante occlusion algorithm */
  86979. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  86980. /** Use a conservative occlusion algorithm */
  86981. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  86982. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  86983. * Test order :
  86984. * Is the bounding sphere outside the frustum ?
  86985. * If not, are the bounding box vertices outside the frustum ?
  86986. * It not, then the cullable object is in the frustum.
  86987. */
  86988. static readonly CULLINGSTRATEGY_STANDARD: number;
  86989. /** Culling strategy : Bounding Sphere Only.
  86990. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  86991. * It's also less accurate than the standard because some not visible objects can still be selected.
  86992. * Test : is the bounding sphere outside the frustum ?
  86993. * If not, then the cullable object is in the frustum.
  86994. */
  86995. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  86996. /** Culling strategy : Optimistic Inclusion.
  86997. * This in an inclusion test first, then the standard exclusion test.
  86998. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  86999. * 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.
  87000. * Anyway, it's as accurate as the standard strategy.
  87001. * Test :
  87002. * Is the cullable object bounding sphere center in the frustum ?
  87003. * If not, apply the default culling strategy.
  87004. */
  87005. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87006. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87007. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87008. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87009. * 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.
  87010. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87011. * Test :
  87012. * Is the cullable object bounding sphere center in the frustum ?
  87013. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87014. */
  87015. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87016. /**
  87017. * No billboard
  87018. */
  87019. static readonly BILLBOARDMODE_NONE: number;
  87020. /** Billboard on X axis */
  87021. static readonly BILLBOARDMODE_X: number;
  87022. /** Billboard on Y axis */
  87023. static readonly BILLBOARDMODE_Y: number;
  87024. /** Billboard on Z axis */
  87025. static readonly BILLBOARDMODE_Z: number;
  87026. /** Billboard on all axes */
  87027. static readonly BILLBOARDMODE_ALL: number;
  87028. /** @hidden */
  87029. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87030. /**
  87031. * The culling strategy to use to check whether the mesh must be rendered or not.
  87032. * This value can be changed at any time and will be used on the next render mesh selection.
  87033. * The possible values are :
  87034. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87035. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87036. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87037. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87038. * Please read each static variable documentation to get details about the culling process.
  87039. * */
  87040. cullingStrategy: number;
  87041. /**
  87042. * Gets the number of facets in the mesh
  87043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87044. */
  87045. readonly facetNb: number;
  87046. /**
  87047. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87048. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87049. */
  87050. partitioningSubdivisions: number;
  87051. /**
  87052. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87053. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87054. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87055. */
  87056. partitioningBBoxRatio: number;
  87057. /**
  87058. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87059. * Works only for updatable meshes.
  87060. * Doesn't work with multi-materials
  87061. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87062. */
  87063. mustDepthSortFacets: boolean;
  87064. /**
  87065. * The location (Vector3) where the facet depth sort must be computed from.
  87066. * By default, the active camera position.
  87067. * Used only when facet depth sort is enabled
  87068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87069. */
  87070. facetDepthSortFrom: Vector3;
  87071. /**
  87072. * gets a boolean indicating if facetData is enabled
  87073. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87074. */
  87075. readonly isFacetDataEnabled: boolean;
  87076. /** @hidden */
  87077. _updateNonUniformScalingState(value: boolean): boolean;
  87078. /**
  87079. * An event triggered when this mesh collides with another one
  87080. */
  87081. onCollideObservable: Observable<AbstractMesh>;
  87082. /** Set a function to call when this mesh collides with another one */
  87083. onCollide: () => void;
  87084. /**
  87085. * An event triggered when the collision's position changes
  87086. */
  87087. onCollisionPositionChangeObservable: Observable<Vector3>;
  87088. /** Set a function to call when the collision's position changes */
  87089. onCollisionPositionChange: () => void;
  87090. /**
  87091. * An event triggered when material is changed
  87092. */
  87093. onMaterialChangedObservable: Observable<AbstractMesh>;
  87094. /**
  87095. * Gets or sets the orientation for POV movement & rotation
  87096. */
  87097. definedFacingForward: boolean;
  87098. /** @hidden */
  87099. _occlusionQuery: Nullable<WebGLQuery>;
  87100. /** @hidden */
  87101. _renderingGroup: Nullable<RenderingGroup>;
  87102. /**
  87103. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87104. */
  87105. /**
  87106. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87107. */
  87108. visibility: number;
  87109. /** Gets or sets the alpha index used to sort transparent meshes
  87110. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87111. */
  87112. alphaIndex: number;
  87113. /**
  87114. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87115. */
  87116. isVisible: boolean;
  87117. /**
  87118. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87119. */
  87120. isPickable: boolean;
  87121. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87122. showSubMeshesBoundingBox: boolean;
  87123. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87124. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87125. */
  87126. isBlocker: boolean;
  87127. /**
  87128. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87129. */
  87130. enablePointerMoveEvents: boolean;
  87131. /**
  87132. * Specifies the rendering group id for this mesh (0 by default)
  87133. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87134. */
  87135. renderingGroupId: number;
  87136. private _material;
  87137. /** Gets or sets current material */
  87138. material: Nullable<Material>;
  87139. /**
  87140. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87141. * @see http://doc.babylonjs.com/babylon101/shadows
  87142. */
  87143. receiveShadows: boolean;
  87144. /** Defines color to use when rendering outline */
  87145. outlineColor: Color3;
  87146. /** Define width to use when rendering outline */
  87147. outlineWidth: number;
  87148. /** Defines color to use when rendering overlay */
  87149. overlayColor: Color3;
  87150. /** Defines alpha to use when rendering overlay */
  87151. overlayAlpha: number;
  87152. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87153. hasVertexAlpha: boolean;
  87154. /** 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) */
  87155. useVertexColors: boolean;
  87156. /**
  87157. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87158. */
  87159. computeBonesUsingShaders: boolean;
  87160. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87161. numBoneInfluencers: number;
  87162. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87163. applyFog: boolean;
  87164. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87165. useOctreeForRenderingSelection: boolean;
  87166. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87167. useOctreeForPicking: boolean;
  87168. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87169. useOctreeForCollisions: boolean;
  87170. /**
  87171. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87172. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87173. */
  87174. layerMask: number;
  87175. /**
  87176. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87177. */
  87178. alwaysSelectAsActiveMesh: boolean;
  87179. /**
  87180. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87181. */
  87182. doNotSyncBoundingInfo: boolean;
  87183. /**
  87184. * Gets or sets the current action manager
  87185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87186. */
  87187. actionManager: Nullable<AbstractActionManager>;
  87188. private _meshCollisionData;
  87189. /**
  87190. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87192. */
  87193. ellipsoid: Vector3;
  87194. /**
  87195. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87196. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87197. */
  87198. ellipsoidOffset: Vector3;
  87199. /**
  87200. * Gets or sets a collision mask used to mask collisions (default is -1).
  87201. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87202. */
  87203. collisionMask: number;
  87204. /**
  87205. * Gets or sets the current collision group mask (-1 by default).
  87206. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87207. */
  87208. collisionGroup: number;
  87209. /**
  87210. * Defines edge width used when edgesRenderer is enabled
  87211. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87212. */
  87213. edgesWidth: number;
  87214. /**
  87215. * Defines edge color used when edgesRenderer is enabled
  87216. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87217. */
  87218. edgesColor: Color4;
  87219. /** @hidden */
  87220. _edgesRenderer: Nullable<IEdgesRenderer>;
  87221. /** @hidden */
  87222. _masterMesh: Nullable<AbstractMesh>;
  87223. /** @hidden */
  87224. _boundingInfo: Nullable<BoundingInfo>;
  87225. /** @hidden */
  87226. _renderId: number;
  87227. /**
  87228. * Gets or sets the list of subMeshes
  87229. * @see http://doc.babylonjs.com/how_to/multi_materials
  87230. */
  87231. subMeshes: SubMesh[];
  87232. /** @hidden */
  87233. _intersectionsInProgress: AbstractMesh[];
  87234. /** @hidden */
  87235. _unIndexed: boolean;
  87236. /** @hidden */
  87237. _lightSources: Light[];
  87238. /** Gets the list of lights affecting that mesh */
  87239. readonly lightSources: Light[];
  87240. /** @hidden */
  87241. readonly _positions: Nullable<Vector3[]>;
  87242. /** @hidden */
  87243. _waitingData: {
  87244. lods: Nullable<any>;
  87245. actions: Nullable<any>;
  87246. freezeWorldMatrix: Nullable<boolean>;
  87247. };
  87248. /** @hidden */
  87249. _bonesTransformMatrices: Nullable<Float32Array>;
  87250. /**
  87251. * Gets or sets a skeleton to apply skining transformations
  87252. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87253. */
  87254. skeleton: Nullable<Skeleton>;
  87255. /**
  87256. * An event triggered when the mesh is rebuilt.
  87257. */
  87258. onRebuildObservable: Observable<AbstractMesh>;
  87259. /**
  87260. * Creates a new AbstractMesh
  87261. * @param name defines the name of the mesh
  87262. * @param scene defines the hosting scene
  87263. */
  87264. constructor(name: string, scene?: Nullable<Scene>);
  87265. /**
  87266. * Returns the string "AbstractMesh"
  87267. * @returns "AbstractMesh"
  87268. */
  87269. getClassName(): string;
  87270. /**
  87271. * Gets a string representation of the current mesh
  87272. * @param fullDetails defines a boolean indicating if full details must be included
  87273. * @returns a string representation of the current mesh
  87274. */
  87275. toString(fullDetails?: boolean): string;
  87276. /**
  87277. * @hidden
  87278. */
  87279. protected _getEffectiveParent(): Nullable<Node>;
  87280. /** @hidden */
  87281. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87282. /** @hidden */
  87283. _rebuild(): void;
  87284. /** @hidden */
  87285. _resyncLightSources(): void;
  87286. /** @hidden */
  87287. _resyncLighSource(light: Light): void;
  87288. /** @hidden */
  87289. _unBindEffect(): void;
  87290. /** @hidden */
  87291. _removeLightSource(light: Light): void;
  87292. private _markSubMeshesAsDirty;
  87293. /** @hidden */
  87294. _markSubMeshesAsLightDirty(): void;
  87295. /** @hidden */
  87296. _markSubMeshesAsAttributesDirty(): void;
  87297. /** @hidden */
  87298. _markSubMeshesAsMiscDirty(): void;
  87299. /**
  87300. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87301. */
  87302. scaling: Vector3;
  87303. /**
  87304. * Returns true if the mesh is blocked. Implemented by child classes
  87305. */
  87306. readonly isBlocked: boolean;
  87307. /**
  87308. * Returns the mesh itself by default. Implemented by child classes
  87309. * @param camera defines the camera to use to pick the right LOD level
  87310. * @returns the currentAbstractMesh
  87311. */
  87312. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87313. /**
  87314. * Returns 0 by default. Implemented by child classes
  87315. * @returns an integer
  87316. */
  87317. getTotalVertices(): number;
  87318. /**
  87319. * Returns a positive integer : the total number of indices in this mesh geometry.
  87320. * @returns the numner of indices or zero if the mesh has no geometry.
  87321. */
  87322. getTotalIndices(): number;
  87323. /**
  87324. * Returns null by default. Implemented by child classes
  87325. * @returns null
  87326. */
  87327. getIndices(): Nullable<IndicesArray>;
  87328. /**
  87329. * Returns the array of the requested vertex data kind. Implemented by child classes
  87330. * @param kind defines the vertex data kind to use
  87331. * @returns null
  87332. */
  87333. getVerticesData(kind: string): Nullable<FloatArray>;
  87334. /**
  87335. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87336. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87337. * Note that a new underlying VertexBuffer object is created each call.
  87338. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87339. * @param kind defines vertex data kind:
  87340. * * VertexBuffer.PositionKind
  87341. * * VertexBuffer.UVKind
  87342. * * VertexBuffer.UV2Kind
  87343. * * VertexBuffer.UV3Kind
  87344. * * VertexBuffer.UV4Kind
  87345. * * VertexBuffer.UV5Kind
  87346. * * VertexBuffer.UV6Kind
  87347. * * VertexBuffer.ColorKind
  87348. * * VertexBuffer.MatricesIndicesKind
  87349. * * VertexBuffer.MatricesIndicesExtraKind
  87350. * * VertexBuffer.MatricesWeightsKind
  87351. * * VertexBuffer.MatricesWeightsExtraKind
  87352. * @param data defines the data source
  87353. * @param updatable defines if the data must be flagged as updatable (or static)
  87354. * @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
  87355. * @returns the current mesh
  87356. */
  87357. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87358. /**
  87359. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87360. * If the mesh has no geometry, it is simply returned as it is.
  87361. * @param kind defines vertex data kind:
  87362. * * VertexBuffer.PositionKind
  87363. * * VertexBuffer.UVKind
  87364. * * VertexBuffer.UV2Kind
  87365. * * VertexBuffer.UV3Kind
  87366. * * VertexBuffer.UV4Kind
  87367. * * VertexBuffer.UV5Kind
  87368. * * VertexBuffer.UV6Kind
  87369. * * VertexBuffer.ColorKind
  87370. * * VertexBuffer.MatricesIndicesKind
  87371. * * VertexBuffer.MatricesIndicesExtraKind
  87372. * * VertexBuffer.MatricesWeightsKind
  87373. * * VertexBuffer.MatricesWeightsExtraKind
  87374. * @param data defines the data source
  87375. * @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
  87376. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87377. * @returns the current mesh
  87378. */
  87379. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87380. /**
  87381. * Sets the mesh indices,
  87382. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87383. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87384. * @param totalVertices Defines the total number of vertices
  87385. * @returns the current mesh
  87386. */
  87387. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87388. /**
  87389. * Gets a boolean indicating if specific vertex data is present
  87390. * @param kind defines the vertex data kind to use
  87391. * @returns true is data kind is present
  87392. */
  87393. isVerticesDataPresent(kind: string): boolean;
  87394. /**
  87395. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  87396. * @returns a BoundingInfo
  87397. */
  87398. getBoundingInfo(): BoundingInfo;
  87399. /**
  87400. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87401. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87402. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87403. * @returns the current mesh
  87404. */
  87405. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  87406. /**
  87407. * Overwrite the current bounding info
  87408. * @param boundingInfo defines the new bounding info
  87409. * @returns the current mesh
  87410. */
  87411. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87412. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87413. readonly useBones: boolean;
  87414. /** @hidden */
  87415. _preActivate(): void;
  87416. /** @hidden */
  87417. _preActivateForIntermediateRendering(renderId: number): void;
  87418. /** @hidden */
  87419. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87420. /** @hidden */
  87421. _postActivate(): void;
  87422. /** @hidden */
  87423. _freeze(): void;
  87424. /** @hidden */
  87425. _unFreeze(): void;
  87426. /**
  87427. * Gets the current world matrix
  87428. * @returns a Matrix
  87429. */
  87430. getWorldMatrix(): Matrix;
  87431. /** @hidden */
  87432. _getWorldMatrixDeterminant(): number;
  87433. /**
  87434. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87435. */
  87436. readonly isAnInstance: boolean;
  87437. /**
  87438. * Perform relative position change from the point of view of behind the front of the mesh.
  87439. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87440. * Supports definition of mesh facing forward or backward
  87441. * @param amountRight defines the distance on the right axis
  87442. * @param amountUp defines the distance on the up axis
  87443. * @param amountForward defines the distance on the forward axis
  87444. * @returns the current mesh
  87445. */
  87446. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87447. /**
  87448. * Calculate relative position change from the point of view of behind the front of the mesh.
  87449. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87450. * Supports definition of mesh facing forward or backward
  87451. * @param amountRight defines the distance on the right axis
  87452. * @param amountUp defines the distance on the up axis
  87453. * @param amountForward defines the distance on the forward axis
  87454. * @returns the new displacement vector
  87455. */
  87456. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87457. /**
  87458. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87459. * Supports definition of mesh facing forward or backward
  87460. * @param flipBack defines the flip
  87461. * @param twirlClockwise defines the twirl
  87462. * @param tiltRight defines the tilt
  87463. * @returns the current mesh
  87464. */
  87465. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87466. /**
  87467. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87468. * Supports definition of mesh facing forward or backward.
  87469. * @param flipBack defines the flip
  87470. * @param twirlClockwise defines the twirl
  87471. * @param tiltRight defines the tilt
  87472. * @returns the new rotation vector
  87473. */
  87474. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87475. /**
  87476. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87477. * This means the mesh underlying bounding box and sphere are recomputed.
  87478. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87479. * @returns the current mesh
  87480. */
  87481. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87482. /** @hidden */
  87483. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87484. /** @hidden */
  87485. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87486. /** @hidden */
  87487. _updateBoundingInfo(): AbstractMesh;
  87488. /** @hidden */
  87489. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87490. /** @hidden */
  87491. protected _afterComputeWorldMatrix(): void;
  87492. /** @hidden */
  87493. readonly _effectiveMesh: AbstractMesh;
  87494. /**
  87495. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87496. * A mesh is in the frustum if its bounding box intersects the frustum
  87497. * @param frustumPlanes defines the frustum to test
  87498. * @returns true if the mesh is in the frustum planes
  87499. */
  87500. isInFrustum(frustumPlanes: Plane[]): boolean;
  87501. /**
  87502. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87503. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87504. * @param frustumPlanes defines the frustum to test
  87505. * @returns true if the mesh is completely in the frustum planes
  87506. */
  87507. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87508. /**
  87509. * True if the mesh intersects another mesh or a SolidParticle object
  87510. * @param mesh defines a target mesh or SolidParticle to test
  87511. * @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)
  87512. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87513. * @returns true if there is an intersection
  87514. */
  87515. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87516. /**
  87517. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87518. * @param point defines the point to test
  87519. * @returns true if there is an intersection
  87520. */
  87521. intersectsPoint(point: Vector3): boolean;
  87522. /**
  87523. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87524. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87525. */
  87526. checkCollisions: boolean;
  87527. /**
  87528. * Gets Collider object used to compute collisions (not physics)
  87529. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87530. */
  87531. readonly collider: Nullable<Collider>;
  87532. /**
  87533. * Move the mesh using collision engine
  87534. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87535. * @param displacement defines the requested displacement vector
  87536. * @returns the current mesh
  87537. */
  87538. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87539. private _onCollisionPositionChange;
  87540. /** @hidden */
  87541. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87542. /** @hidden */
  87543. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87544. /** @hidden */
  87545. _checkCollision(collider: Collider): AbstractMesh;
  87546. /** @hidden */
  87547. _generatePointsArray(): boolean;
  87548. /**
  87549. * Checks if the passed Ray intersects with the mesh
  87550. * @param ray defines the ray to use
  87551. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87552. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87553. * @returns the picking info
  87554. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87555. */
  87556. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87557. /**
  87558. * Clones the current mesh
  87559. * @param name defines the mesh name
  87560. * @param newParent defines the new mesh parent
  87561. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87562. * @returns the new mesh
  87563. */
  87564. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87565. /**
  87566. * Disposes all the submeshes of the current meshnp
  87567. * @returns the current mesh
  87568. */
  87569. releaseSubMeshes(): AbstractMesh;
  87570. /**
  87571. * Releases resources associated with this abstract mesh.
  87572. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87573. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87574. */
  87575. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87576. /**
  87577. * Adds the passed mesh as a child to the current mesh
  87578. * @param mesh defines the child mesh
  87579. * @returns the current mesh
  87580. */
  87581. addChild(mesh: AbstractMesh): AbstractMesh;
  87582. /**
  87583. * Removes the passed mesh from the current mesh children list
  87584. * @param mesh defines the child mesh
  87585. * @returns the current mesh
  87586. */
  87587. removeChild(mesh: AbstractMesh): AbstractMesh;
  87588. /** @hidden */
  87589. private _initFacetData;
  87590. /**
  87591. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87592. * This method can be called within the render loop.
  87593. * 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
  87594. * @returns the current mesh
  87595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87596. */
  87597. updateFacetData(): AbstractMesh;
  87598. /**
  87599. * Returns the facetLocalNormals array.
  87600. * The normals are expressed in the mesh local spac
  87601. * @returns an array of Vector3
  87602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87603. */
  87604. getFacetLocalNormals(): Vector3[];
  87605. /**
  87606. * Returns the facetLocalPositions array.
  87607. * The facet positions are expressed in the mesh local space
  87608. * @returns an array of Vector3
  87609. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87610. */
  87611. getFacetLocalPositions(): Vector3[];
  87612. /**
  87613. * Returns the facetLocalPartioning array
  87614. * @returns an array of array of numbers
  87615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87616. */
  87617. getFacetLocalPartitioning(): number[][];
  87618. /**
  87619. * Returns the i-th facet position in the world system.
  87620. * This method allocates a new Vector3 per call
  87621. * @param i defines the facet index
  87622. * @returns a new Vector3
  87623. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87624. */
  87625. getFacetPosition(i: number): Vector3;
  87626. /**
  87627. * Sets the reference Vector3 with the i-th facet position in the world system
  87628. * @param i defines the facet index
  87629. * @param ref defines the target vector
  87630. * @returns the current mesh
  87631. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87632. */
  87633. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87634. /**
  87635. * Returns the i-th facet normal in the world system.
  87636. * This method allocates a new Vector3 per call
  87637. * @param i defines the facet index
  87638. * @returns a new Vector3
  87639. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87640. */
  87641. getFacetNormal(i: number): Vector3;
  87642. /**
  87643. * Sets the reference Vector3 with the i-th facet normal in the world system
  87644. * @param i defines the facet index
  87645. * @param ref defines the target vector
  87646. * @returns the current mesh
  87647. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87648. */
  87649. getFacetNormalToRef(i: number, ref: Vector3): this;
  87650. /**
  87651. * 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)
  87652. * @param x defines x coordinate
  87653. * @param y defines y coordinate
  87654. * @param z defines z coordinate
  87655. * @returns the array of facet indexes
  87656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87657. */
  87658. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87659. /**
  87660. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87661. * @param projected sets as the (x,y,z) world projection on the facet
  87662. * @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
  87663. * @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
  87664. * @param x defines x coordinate
  87665. * @param y defines y coordinate
  87666. * @param z defines z coordinate
  87667. * @returns the face index if found (or null instead)
  87668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87669. */
  87670. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87671. /**
  87672. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87673. * @param projected sets as the (x,y,z) local projection on the facet
  87674. * @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
  87675. * @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
  87676. * @param x defines x coordinate
  87677. * @param y defines y coordinate
  87678. * @param z defines z coordinate
  87679. * @returns the face index if found (or null instead)
  87680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87681. */
  87682. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87683. /**
  87684. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87685. * @returns the parameters
  87686. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87687. */
  87688. getFacetDataParameters(): any;
  87689. /**
  87690. * Disables the feature FacetData and frees the related memory
  87691. * @returns the current mesh
  87692. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87693. */
  87694. disableFacetData(): AbstractMesh;
  87695. /**
  87696. * Updates the AbstractMesh indices array
  87697. * @param indices defines the data source
  87698. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87699. * @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)
  87700. * @returns the current mesh
  87701. */
  87702. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87703. /**
  87704. * Creates new normals data for the mesh
  87705. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87706. * @returns the current mesh
  87707. */
  87708. createNormals(updatable: boolean): AbstractMesh;
  87709. /**
  87710. * Align the mesh with a normal
  87711. * @param normal defines the normal to use
  87712. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87713. * @returns the current mesh
  87714. */
  87715. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87716. /** @hidden */
  87717. _checkOcclusionQuery(): boolean;
  87718. /**
  87719. * Disables the mesh edge rendering mode
  87720. * @returns the currentAbstractMesh
  87721. */
  87722. disableEdgesRendering(): AbstractMesh;
  87723. /**
  87724. * Enables the edge rendering mode on the mesh.
  87725. * This mode makes the mesh edges visible
  87726. * @param epsilon defines the maximal distance between two angles to detect a face
  87727. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87728. * @returns the currentAbstractMesh
  87729. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87730. */
  87731. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87732. }
  87733. }
  87734. declare module BABYLON {
  87735. /**
  87736. * Interface used to define ActionEvent
  87737. */
  87738. export interface IActionEvent {
  87739. /** The mesh or sprite that triggered the action */
  87740. source: any;
  87741. /** The X mouse cursor position at the time of the event */
  87742. pointerX: number;
  87743. /** The Y mouse cursor position at the time of the event */
  87744. pointerY: number;
  87745. /** The mesh that is currently pointed at (can be null) */
  87746. meshUnderPointer: Nullable<AbstractMesh>;
  87747. /** the original (browser) event that triggered the ActionEvent */
  87748. sourceEvent?: any;
  87749. /** additional data for the event */
  87750. additionalData?: any;
  87751. }
  87752. /**
  87753. * ActionEvent is the event being sent when an action is triggered.
  87754. */
  87755. export class ActionEvent implements IActionEvent {
  87756. /** The mesh or sprite that triggered the action */
  87757. source: any;
  87758. /** The X mouse cursor position at the time of the event */
  87759. pointerX: number;
  87760. /** The Y mouse cursor position at the time of the event */
  87761. pointerY: number;
  87762. /** The mesh that is currently pointed at (can be null) */
  87763. meshUnderPointer: Nullable<AbstractMesh>;
  87764. /** the original (browser) event that triggered the ActionEvent */
  87765. sourceEvent?: any;
  87766. /** additional data for the event */
  87767. additionalData?: any;
  87768. /**
  87769. * Creates a new ActionEvent
  87770. * @param source The mesh or sprite that triggered the action
  87771. * @param pointerX The X mouse cursor position at the time of the event
  87772. * @param pointerY The Y mouse cursor position at the time of the event
  87773. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87774. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87775. * @param additionalData additional data for the event
  87776. */
  87777. constructor(
  87778. /** The mesh or sprite that triggered the action */
  87779. source: any,
  87780. /** The X mouse cursor position at the time of the event */
  87781. pointerX: number,
  87782. /** The Y mouse cursor position at the time of the event */
  87783. pointerY: number,
  87784. /** The mesh that is currently pointed at (can be null) */
  87785. meshUnderPointer: Nullable<AbstractMesh>,
  87786. /** the original (browser) event that triggered the ActionEvent */
  87787. sourceEvent?: any,
  87788. /** additional data for the event */
  87789. additionalData?: any);
  87790. /**
  87791. * Helper function to auto-create an ActionEvent from a source mesh.
  87792. * @param source The source mesh that triggered the event
  87793. * @param evt The original (browser) event
  87794. * @param additionalData additional data for the event
  87795. * @returns the new ActionEvent
  87796. */
  87797. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87798. /**
  87799. * Helper function to auto-create an ActionEvent from a source sprite
  87800. * @param source The source sprite that triggered the event
  87801. * @param scene Scene associated with the sprite
  87802. * @param evt The original (browser) event
  87803. * @param additionalData additional data for the event
  87804. * @returns the new ActionEvent
  87805. */
  87806. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87807. /**
  87808. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87809. * @param scene the scene where the event occurred
  87810. * @param evt The original (browser) event
  87811. * @returns the new ActionEvent
  87812. */
  87813. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87814. /**
  87815. * Helper function to auto-create an ActionEvent from a primitive
  87816. * @param prim defines the target primitive
  87817. * @param pointerPos defines the pointer position
  87818. * @param evt The original (browser) event
  87819. * @param additionalData additional data for the event
  87820. * @returns the new ActionEvent
  87821. */
  87822. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87823. }
  87824. }
  87825. declare module BABYLON {
  87826. /**
  87827. * Abstract class used to decouple action Manager from scene and meshes.
  87828. * Do not instantiate.
  87829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87830. */
  87831. export abstract class AbstractActionManager implements IDisposable {
  87832. /** Gets the list of active triggers */
  87833. static Triggers: {
  87834. [key: string]: number;
  87835. };
  87836. /** Gets the cursor to use when hovering items */
  87837. hoverCursor: string;
  87838. /** Gets the list of actions */
  87839. actions: IAction[];
  87840. /**
  87841. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87842. */
  87843. isRecursive: boolean;
  87844. /**
  87845. * Releases all associated resources
  87846. */
  87847. abstract dispose(): void;
  87848. /**
  87849. * Does this action manager has pointer triggers
  87850. */
  87851. abstract readonly hasPointerTriggers: boolean;
  87852. /**
  87853. * Does this action manager has pick triggers
  87854. */
  87855. abstract readonly hasPickTriggers: boolean;
  87856. /**
  87857. * Process a specific trigger
  87858. * @param trigger defines the trigger to process
  87859. * @param evt defines the event details to be processed
  87860. */
  87861. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  87862. /**
  87863. * Does this action manager handles actions of any of the given triggers
  87864. * @param triggers defines the triggers to be tested
  87865. * @return a boolean indicating whether one (or more) of the triggers is handled
  87866. */
  87867. abstract hasSpecificTriggers(triggers: number[]): boolean;
  87868. /**
  87869. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87870. * speed.
  87871. * @param triggerA defines the trigger to be tested
  87872. * @param triggerB defines the trigger to be tested
  87873. * @return a boolean indicating whether one (or more) of the triggers is handled
  87874. */
  87875. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87876. /**
  87877. * Does this action manager handles actions of a given trigger
  87878. * @param trigger defines the trigger to be tested
  87879. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87880. * @return whether the trigger is handled
  87881. */
  87882. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87883. /**
  87884. * Serialize this manager to a JSON object
  87885. * @param name defines the property name to store this manager
  87886. * @returns a JSON representation of this manager
  87887. */
  87888. abstract serialize(name: string): any;
  87889. /**
  87890. * Registers an action to this action manager
  87891. * @param action defines the action to be registered
  87892. * @return the action amended (prepared) after registration
  87893. */
  87894. abstract registerAction(action: IAction): Nullable<IAction>;
  87895. /**
  87896. * Unregisters an action to this action manager
  87897. * @param action defines the action to be unregistered
  87898. * @return a boolean indicating whether the action has been unregistered
  87899. */
  87900. abstract unregisterAction(action: IAction): Boolean;
  87901. /**
  87902. * Does exist one action manager with at least one trigger
  87903. **/
  87904. static readonly HasTriggers: boolean;
  87905. /**
  87906. * Does exist one action manager with at least one pick trigger
  87907. **/
  87908. static readonly HasPickTriggers: boolean;
  87909. /**
  87910. * Does exist one action manager that handles actions of a given trigger
  87911. * @param trigger defines the trigger to be tested
  87912. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  87913. **/
  87914. static HasSpecificTrigger(trigger: number): boolean;
  87915. }
  87916. }
  87917. declare module BABYLON {
  87918. /**
  87919. * Defines how a node can be built from a string name.
  87920. */
  87921. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  87922. /**
  87923. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  87924. */
  87925. export class Node implements IBehaviorAware<Node> {
  87926. /** @hidden */
  87927. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  87928. private static _NodeConstructors;
  87929. /**
  87930. * Add a new node constructor
  87931. * @param type defines the type name of the node to construct
  87932. * @param constructorFunc defines the constructor function
  87933. */
  87934. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  87935. /**
  87936. * Returns a node constructor based on type name
  87937. * @param type defines the type name
  87938. * @param name defines the new node name
  87939. * @param scene defines the hosting scene
  87940. * @param options defines optional options to transmit to constructors
  87941. * @returns the new constructor or null
  87942. */
  87943. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  87944. /**
  87945. * Gets or sets the name of the node
  87946. */
  87947. name: string;
  87948. /**
  87949. * Gets or sets the id of the node
  87950. */
  87951. id: string;
  87952. /**
  87953. * Gets or sets the unique id of the node
  87954. */
  87955. uniqueId: number;
  87956. /**
  87957. * Gets or sets a string used to store user defined state for the node
  87958. */
  87959. state: string;
  87960. /**
  87961. * Gets or sets an object used to store user defined information for the node
  87962. */
  87963. metadata: any;
  87964. /**
  87965. * For internal use only. Please do not use.
  87966. */
  87967. reservedDataStore: any;
  87968. /**
  87969. * List of inspectable custom properties (used by the Inspector)
  87970. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87971. */
  87972. inspectableCustomProperties: IInspectable[];
  87973. /**
  87974. * Gets or sets a boolean used to define if the node must be serialized
  87975. */
  87976. doNotSerialize: boolean;
  87977. /** @hidden */
  87978. _isDisposed: boolean;
  87979. /**
  87980. * Gets a list of Animations associated with the node
  87981. */
  87982. animations: Animation[];
  87983. protected _ranges: {
  87984. [name: string]: Nullable<AnimationRange>;
  87985. };
  87986. /**
  87987. * Callback raised when the node is ready to be used
  87988. */
  87989. onReady: Nullable<(node: Node) => void>;
  87990. private _isEnabled;
  87991. private _isParentEnabled;
  87992. private _isReady;
  87993. /** @hidden */
  87994. _currentRenderId: number;
  87995. private _parentUpdateId;
  87996. /** @hidden */
  87997. _childUpdateId: number;
  87998. /** @hidden */
  87999. _waitingParentId: Nullable<string>;
  88000. /** @hidden */
  88001. _scene: Scene;
  88002. /** @hidden */
  88003. _cache: any;
  88004. private _parentNode;
  88005. private _children;
  88006. /** @hidden */
  88007. _worldMatrix: Matrix;
  88008. /** @hidden */
  88009. _worldMatrixDeterminant: number;
  88010. /** @hidden */
  88011. _worldMatrixDeterminantIsDirty: boolean;
  88012. /** @hidden */
  88013. private _sceneRootNodesIndex;
  88014. /**
  88015. * Gets a boolean indicating if the node has been disposed
  88016. * @returns true if the node was disposed
  88017. */
  88018. isDisposed(): boolean;
  88019. /**
  88020. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88021. * @see https://doc.babylonjs.com/how_to/parenting
  88022. */
  88023. parent: Nullable<Node>;
  88024. private addToSceneRootNodes;
  88025. private removeFromSceneRootNodes;
  88026. private _animationPropertiesOverride;
  88027. /**
  88028. * Gets or sets the animation properties override
  88029. */
  88030. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88031. /**
  88032. * Gets a string idenfifying the name of the class
  88033. * @returns "Node" string
  88034. */
  88035. getClassName(): string;
  88036. /** @hidden */
  88037. readonly _isNode: boolean;
  88038. /**
  88039. * An event triggered when the mesh is disposed
  88040. */
  88041. onDisposeObservable: Observable<Node>;
  88042. private _onDisposeObserver;
  88043. /**
  88044. * Sets a callback that will be raised when the node will be disposed
  88045. */
  88046. onDispose: () => void;
  88047. /**
  88048. * Creates a new Node
  88049. * @param name the name and id to be given to this node
  88050. * @param scene the scene this node will be added to
  88051. * @param addToRootNodes the node will be added to scene.rootNodes
  88052. */
  88053. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88054. /**
  88055. * Gets the scene of the node
  88056. * @returns a scene
  88057. */
  88058. getScene(): Scene;
  88059. /**
  88060. * Gets the engine of the node
  88061. * @returns a Engine
  88062. */
  88063. getEngine(): Engine;
  88064. private _behaviors;
  88065. /**
  88066. * Attach a behavior to the node
  88067. * @see http://doc.babylonjs.com/features/behaviour
  88068. * @param behavior defines the behavior to attach
  88069. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88070. * @returns the current Node
  88071. */
  88072. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88073. /**
  88074. * Remove an attached behavior
  88075. * @see http://doc.babylonjs.com/features/behaviour
  88076. * @param behavior defines the behavior to attach
  88077. * @returns the current Node
  88078. */
  88079. removeBehavior(behavior: Behavior<Node>): Node;
  88080. /**
  88081. * Gets the list of attached behaviors
  88082. * @see http://doc.babylonjs.com/features/behaviour
  88083. */
  88084. readonly behaviors: Behavior<Node>[];
  88085. /**
  88086. * Gets an attached behavior by name
  88087. * @param name defines the name of the behavior to look for
  88088. * @see http://doc.babylonjs.com/features/behaviour
  88089. * @returns null if behavior was not found else the requested behavior
  88090. */
  88091. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88092. /**
  88093. * Returns the latest update of the World matrix
  88094. * @returns a Matrix
  88095. */
  88096. getWorldMatrix(): Matrix;
  88097. /** @hidden */
  88098. _getWorldMatrixDeterminant(): number;
  88099. /**
  88100. * Returns directly the latest state of the mesh World matrix.
  88101. * A Matrix is returned.
  88102. */
  88103. readonly worldMatrixFromCache: Matrix;
  88104. /** @hidden */
  88105. _initCache(): void;
  88106. /** @hidden */
  88107. updateCache(force?: boolean): void;
  88108. /** @hidden */
  88109. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88110. /** @hidden */
  88111. _updateCache(ignoreParentClass?: boolean): void;
  88112. /** @hidden */
  88113. _isSynchronized(): boolean;
  88114. /** @hidden */
  88115. _markSyncedWithParent(): void;
  88116. /** @hidden */
  88117. isSynchronizedWithParent(): boolean;
  88118. /** @hidden */
  88119. isSynchronized(): boolean;
  88120. /**
  88121. * Is this node ready to be used/rendered
  88122. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88123. * @return true if the node is ready
  88124. */
  88125. isReady(completeCheck?: boolean): boolean;
  88126. /**
  88127. * Is this node enabled?
  88128. * 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
  88129. * @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
  88130. * @return whether this node (and its parent) is enabled
  88131. */
  88132. isEnabled(checkAncestors?: boolean): boolean;
  88133. /** @hidden */
  88134. protected _syncParentEnabledState(): void;
  88135. /**
  88136. * Set the enabled state of this node
  88137. * @param value defines the new enabled state
  88138. */
  88139. setEnabled(value: boolean): void;
  88140. /**
  88141. * Is this node a descendant of the given node?
  88142. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88143. * @param ancestor defines the parent node to inspect
  88144. * @returns a boolean indicating if this node is a descendant of the given node
  88145. */
  88146. isDescendantOf(ancestor: Node): boolean;
  88147. /** @hidden */
  88148. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88149. /**
  88150. * Will return all nodes that have this node as ascendant
  88151. * @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
  88152. * @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
  88153. * @return all children nodes of all types
  88154. */
  88155. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88156. /**
  88157. * Get all child-meshes of this node
  88158. * @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)
  88159. * @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
  88160. * @returns an array of AbstractMesh
  88161. */
  88162. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88163. /**
  88164. * Get all direct children of this node
  88165. * @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
  88166. * @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)
  88167. * @returns an array of Node
  88168. */
  88169. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88170. /** @hidden */
  88171. _setReady(state: boolean): void;
  88172. /**
  88173. * Get an animation by name
  88174. * @param name defines the name of the animation to look for
  88175. * @returns null if not found else the requested animation
  88176. */
  88177. getAnimationByName(name: string): Nullable<Animation>;
  88178. /**
  88179. * Creates an animation range for this node
  88180. * @param name defines the name of the range
  88181. * @param from defines the starting key
  88182. * @param to defines the end key
  88183. */
  88184. createAnimationRange(name: string, from: number, to: number): void;
  88185. /**
  88186. * Delete a specific animation range
  88187. * @param name defines the name of the range to delete
  88188. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88189. */
  88190. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88191. /**
  88192. * Get an animation range by name
  88193. * @param name defines the name of the animation range to look for
  88194. * @returns null if not found else the requested animation range
  88195. */
  88196. getAnimationRange(name: string): Nullable<AnimationRange>;
  88197. /**
  88198. * Gets the list of all animation ranges defined on this node
  88199. * @returns an array
  88200. */
  88201. getAnimationRanges(): Nullable<AnimationRange>[];
  88202. /**
  88203. * Will start the animation sequence
  88204. * @param name defines the range frames for animation sequence
  88205. * @param loop defines if the animation should loop (false by default)
  88206. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88207. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88208. * @returns the object created for this animation. If range does not exist, it will return null
  88209. */
  88210. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88211. /**
  88212. * Serialize animation ranges into a JSON compatible object
  88213. * @returns serialization object
  88214. */
  88215. serializeAnimationRanges(): any;
  88216. /**
  88217. * Computes the world matrix of the node
  88218. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88219. * @returns the world matrix
  88220. */
  88221. computeWorldMatrix(force?: boolean): Matrix;
  88222. /**
  88223. * Releases resources associated with this node.
  88224. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88225. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88226. */
  88227. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88228. /**
  88229. * Parse animation range data from a serialization object and store them into a given node
  88230. * @param node defines where to store the animation ranges
  88231. * @param parsedNode defines the serialization object to read data from
  88232. * @param scene defines the hosting scene
  88233. */
  88234. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88235. /**
  88236. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88237. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88238. * @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
  88239. * @returns the new bounding vectors
  88240. */
  88241. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88242. min: Vector3;
  88243. max: Vector3;
  88244. };
  88245. }
  88246. }
  88247. declare module BABYLON {
  88248. /**
  88249. * @hidden
  88250. */
  88251. export class _IAnimationState {
  88252. key: number;
  88253. repeatCount: number;
  88254. workValue?: any;
  88255. loopMode?: number;
  88256. offsetValue?: any;
  88257. highLimitValue?: any;
  88258. }
  88259. /**
  88260. * Class used to store any kind of animation
  88261. */
  88262. export class Animation {
  88263. /**Name of the animation */
  88264. name: string;
  88265. /**Property to animate */
  88266. targetProperty: string;
  88267. /**The frames per second of the animation */
  88268. framePerSecond: number;
  88269. /**The data type of the animation */
  88270. dataType: number;
  88271. /**The loop mode of the animation */
  88272. loopMode?: number | undefined;
  88273. /**Specifies if blending should be enabled */
  88274. enableBlending?: boolean | undefined;
  88275. /**
  88276. * Use matrix interpolation instead of using direct key value when animating matrices
  88277. */
  88278. static AllowMatricesInterpolation: boolean;
  88279. /**
  88280. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88281. */
  88282. static AllowMatrixDecomposeForInterpolation: boolean;
  88283. /**
  88284. * Stores the key frames of the animation
  88285. */
  88286. private _keys;
  88287. /**
  88288. * Stores the easing function of the animation
  88289. */
  88290. private _easingFunction;
  88291. /**
  88292. * @hidden Internal use only
  88293. */
  88294. _runtimeAnimations: RuntimeAnimation[];
  88295. /**
  88296. * The set of event that will be linked to this animation
  88297. */
  88298. private _events;
  88299. /**
  88300. * Stores an array of target property paths
  88301. */
  88302. targetPropertyPath: string[];
  88303. /**
  88304. * Stores the blending speed of the animation
  88305. */
  88306. blendingSpeed: number;
  88307. /**
  88308. * Stores the animation ranges for the animation
  88309. */
  88310. private _ranges;
  88311. /**
  88312. * @hidden Internal use
  88313. */
  88314. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88315. /**
  88316. * Sets up an animation
  88317. * @param property The property to animate
  88318. * @param animationType The animation type to apply
  88319. * @param framePerSecond The frames per second of the animation
  88320. * @param easingFunction The easing function used in the animation
  88321. * @returns The created animation
  88322. */
  88323. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88324. /**
  88325. * Create and start an animation on a node
  88326. * @param name defines the name of the global animation that will be run on all nodes
  88327. * @param node defines the root node where the animation will take place
  88328. * @param targetProperty defines property to animate
  88329. * @param framePerSecond defines the number of frame per second yo use
  88330. * @param totalFrame defines the number of frames in total
  88331. * @param from defines the initial value
  88332. * @param to defines the final value
  88333. * @param loopMode defines which loop mode you want to use (off by default)
  88334. * @param easingFunction defines the easing function to use (linear by default)
  88335. * @param onAnimationEnd defines the callback to call when animation end
  88336. * @returns the animatable created for this animation
  88337. */
  88338. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88339. /**
  88340. * Create and start an animation on a node and its descendants
  88341. * @param name defines the name of the global animation that will be run on all nodes
  88342. * @param node defines the root node where the animation will take place
  88343. * @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
  88344. * @param targetProperty defines property to animate
  88345. * @param framePerSecond defines the number of frame per second to use
  88346. * @param totalFrame defines the number of frames in total
  88347. * @param from defines the initial value
  88348. * @param to defines the final value
  88349. * @param loopMode defines which loop mode you want to use (off by default)
  88350. * @param easingFunction defines the easing function to use (linear by default)
  88351. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88352. * @returns the list of animatables created for all nodes
  88353. * @example https://www.babylonjs-playground.com/#MH0VLI
  88354. */
  88355. 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[]>;
  88356. /**
  88357. * Creates a new animation, merges it with the existing animations and starts it
  88358. * @param name Name of the animation
  88359. * @param node Node which contains the scene that begins the animations
  88360. * @param targetProperty Specifies which property to animate
  88361. * @param framePerSecond The frames per second of the animation
  88362. * @param totalFrame The total number of frames
  88363. * @param from The frame at the beginning of the animation
  88364. * @param to The frame at the end of the animation
  88365. * @param loopMode Specifies the loop mode of the animation
  88366. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88367. * @param onAnimationEnd Callback to run once the animation is complete
  88368. * @returns Nullable animation
  88369. */
  88370. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88371. /**
  88372. * Transition property of an host to the target Value
  88373. * @param property The property to transition
  88374. * @param targetValue The target Value of the property
  88375. * @param host The object where the property to animate belongs
  88376. * @param scene Scene used to run the animation
  88377. * @param frameRate Framerate (in frame/s) to use
  88378. * @param transition The transition type we want to use
  88379. * @param duration The duration of the animation, in milliseconds
  88380. * @param onAnimationEnd Callback trigger at the end of the animation
  88381. * @returns Nullable animation
  88382. */
  88383. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88384. /**
  88385. * Return the array of runtime animations currently using this animation
  88386. */
  88387. readonly runtimeAnimations: RuntimeAnimation[];
  88388. /**
  88389. * Specifies if any of the runtime animations are currently running
  88390. */
  88391. readonly hasRunningRuntimeAnimations: boolean;
  88392. /**
  88393. * Initializes the animation
  88394. * @param name Name of the animation
  88395. * @param targetProperty Property to animate
  88396. * @param framePerSecond The frames per second of the animation
  88397. * @param dataType The data type of the animation
  88398. * @param loopMode The loop mode of the animation
  88399. * @param enableBlending Specifies if blending should be enabled
  88400. */
  88401. constructor(
  88402. /**Name of the animation */
  88403. name: string,
  88404. /**Property to animate */
  88405. targetProperty: string,
  88406. /**The frames per second of the animation */
  88407. framePerSecond: number,
  88408. /**The data type of the animation */
  88409. dataType: number,
  88410. /**The loop mode of the animation */
  88411. loopMode?: number | undefined,
  88412. /**Specifies if blending should be enabled */
  88413. enableBlending?: boolean | undefined);
  88414. /**
  88415. * Converts the animation to a string
  88416. * @param fullDetails support for multiple levels of logging within scene loading
  88417. * @returns String form of the animation
  88418. */
  88419. toString(fullDetails?: boolean): string;
  88420. /**
  88421. * Add an event to this animation
  88422. * @param event Event to add
  88423. */
  88424. addEvent(event: AnimationEvent): void;
  88425. /**
  88426. * Remove all events found at the given frame
  88427. * @param frame The frame to remove events from
  88428. */
  88429. removeEvents(frame: number): void;
  88430. /**
  88431. * Retrieves all the events from the animation
  88432. * @returns Events from the animation
  88433. */
  88434. getEvents(): AnimationEvent[];
  88435. /**
  88436. * Creates an animation range
  88437. * @param name Name of the animation range
  88438. * @param from Starting frame of the animation range
  88439. * @param to Ending frame of the animation
  88440. */
  88441. createRange(name: string, from: number, to: number): void;
  88442. /**
  88443. * Deletes an animation range by name
  88444. * @param name Name of the animation range to delete
  88445. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88446. */
  88447. deleteRange(name: string, deleteFrames?: boolean): void;
  88448. /**
  88449. * Gets the animation range by name, or null if not defined
  88450. * @param name Name of the animation range
  88451. * @returns Nullable animation range
  88452. */
  88453. getRange(name: string): Nullable<AnimationRange>;
  88454. /**
  88455. * Gets the key frames from the animation
  88456. * @returns The key frames of the animation
  88457. */
  88458. getKeys(): Array<IAnimationKey>;
  88459. /**
  88460. * Gets the highest frame rate of the animation
  88461. * @returns Highest frame rate of the animation
  88462. */
  88463. getHighestFrame(): number;
  88464. /**
  88465. * Gets the easing function of the animation
  88466. * @returns Easing function of the animation
  88467. */
  88468. getEasingFunction(): IEasingFunction;
  88469. /**
  88470. * Sets the easing function of the animation
  88471. * @param easingFunction A custom mathematical formula for animation
  88472. */
  88473. setEasingFunction(easingFunction: EasingFunction): void;
  88474. /**
  88475. * Interpolates a scalar linearly
  88476. * @param startValue Start value of the animation curve
  88477. * @param endValue End value of the animation curve
  88478. * @param gradient Scalar amount to interpolate
  88479. * @returns Interpolated scalar value
  88480. */
  88481. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88482. /**
  88483. * Interpolates a scalar cubically
  88484. * @param startValue Start value of the animation curve
  88485. * @param outTangent End tangent of the animation
  88486. * @param endValue End value of the animation curve
  88487. * @param inTangent Start tangent of the animation curve
  88488. * @param gradient Scalar amount to interpolate
  88489. * @returns Interpolated scalar value
  88490. */
  88491. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88492. /**
  88493. * Interpolates a quaternion using a spherical linear interpolation
  88494. * @param startValue Start value of the animation curve
  88495. * @param endValue End value of the animation curve
  88496. * @param gradient Scalar amount to interpolate
  88497. * @returns Interpolated quaternion value
  88498. */
  88499. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88500. /**
  88501. * Interpolates a quaternion cubically
  88502. * @param startValue Start value of the animation curve
  88503. * @param outTangent End tangent of the animation curve
  88504. * @param endValue End value of the animation curve
  88505. * @param inTangent Start tangent of the animation curve
  88506. * @param gradient Scalar amount to interpolate
  88507. * @returns Interpolated quaternion value
  88508. */
  88509. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88510. /**
  88511. * Interpolates a Vector3 linearl
  88512. * @param startValue Start value of the animation curve
  88513. * @param endValue End value of the animation curve
  88514. * @param gradient Scalar amount to interpolate
  88515. * @returns Interpolated scalar value
  88516. */
  88517. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88518. /**
  88519. * Interpolates a Vector3 cubically
  88520. * @param startValue Start value of the animation curve
  88521. * @param outTangent End tangent of the animation
  88522. * @param endValue End value of the animation curve
  88523. * @param inTangent Start tangent of the animation curve
  88524. * @param gradient Scalar amount to interpolate
  88525. * @returns InterpolatedVector3 value
  88526. */
  88527. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88528. /**
  88529. * Interpolates a Vector2 linearly
  88530. * @param startValue Start value of the animation curve
  88531. * @param endValue End value of the animation curve
  88532. * @param gradient Scalar amount to interpolate
  88533. * @returns Interpolated Vector2 value
  88534. */
  88535. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88536. /**
  88537. * Interpolates a Vector2 cubically
  88538. * @param startValue Start value of the animation curve
  88539. * @param outTangent End tangent of the animation
  88540. * @param endValue End value of the animation curve
  88541. * @param inTangent Start tangent of the animation curve
  88542. * @param gradient Scalar amount to interpolate
  88543. * @returns Interpolated Vector2 value
  88544. */
  88545. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88546. /**
  88547. * Interpolates a size linearly
  88548. * @param startValue Start value of the animation curve
  88549. * @param endValue End value of the animation curve
  88550. * @param gradient Scalar amount to interpolate
  88551. * @returns Interpolated Size value
  88552. */
  88553. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88554. /**
  88555. * Interpolates a Color3 linearly
  88556. * @param startValue Start value of the animation curve
  88557. * @param endValue End value of the animation curve
  88558. * @param gradient Scalar amount to interpolate
  88559. * @returns Interpolated Color3 value
  88560. */
  88561. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88562. /**
  88563. * @hidden Internal use only
  88564. */
  88565. _getKeyValue(value: any): any;
  88566. /**
  88567. * @hidden Internal use only
  88568. */
  88569. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88570. /**
  88571. * Defines the function to use to interpolate matrices
  88572. * @param startValue defines the start matrix
  88573. * @param endValue defines the end matrix
  88574. * @param gradient defines the gradient between both matrices
  88575. * @param result defines an optional target matrix where to store the interpolation
  88576. * @returns the interpolated matrix
  88577. */
  88578. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88579. /**
  88580. * Makes a copy of the animation
  88581. * @returns Cloned animation
  88582. */
  88583. clone(): Animation;
  88584. /**
  88585. * Sets the key frames of the animation
  88586. * @param values The animation key frames to set
  88587. */
  88588. setKeys(values: Array<IAnimationKey>): void;
  88589. /**
  88590. * Serializes the animation to an object
  88591. * @returns Serialized object
  88592. */
  88593. serialize(): any;
  88594. /**
  88595. * Float animation type
  88596. */
  88597. private static _ANIMATIONTYPE_FLOAT;
  88598. /**
  88599. * Vector3 animation type
  88600. */
  88601. private static _ANIMATIONTYPE_VECTOR3;
  88602. /**
  88603. * Quaternion animation type
  88604. */
  88605. private static _ANIMATIONTYPE_QUATERNION;
  88606. /**
  88607. * Matrix animation type
  88608. */
  88609. private static _ANIMATIONTYPE_MATRIX;
  88610. /**
  88611. * Color3 animation type
  88612. */
  88613. private static _ANIMATIONTYPE_COLOR3;
  88614. /**
  88615. * Vector2 animation type
  88616. */
  88617. private static _ANIMATIONTYPE_VECTOR2;
  88618. /**
  88619. * Size animation type
  88620. */
  88621. private static _ANIMATIONTYPE_SIZE;
  88622. /**
  88623. * Relative Loop Mode
  88624. */
  88625. private static _ANIMATIONLOOPMODE_RELATIVE;
  88626. /**
  88627. * Cycle Loop Mode
  88628. */
  88629. private static _ANIMATIONLOOPMODE_CYCLE;
  88630. /**
  88631. * Constant Loop Mode
  88632. */
  88633. private static _ANIMATIONLOOPMODE_CONSTANT;
  88634. /**
  88635. * Get the float animation type
  88636. */
  88637. static readonly ANIMATIONTYPE_FLOAT: number;
  88638. /**
  88639. * Get the Vector3 animation type
  88640. */
  88641. static readonly ANIMATIONTYPE_VECTOR3: number;
  88642. /**
  88643. * Get the Vector2 animation type
  88644. */
  88645. static readonly ANIMATIONTYPE_VECTOR2: number;
  88646. /**
  88647. * Get the Size animation type
  88648. */
  88649. static readonly ANIMATIONTYPE_SIZE: number;
  88650. /**
  88651. * Get the Quaternion animation type
  88652. */
  88653. static readonly ANIMATIONTYPE_QUATERNION: number;
  88654. /**
  88655. * Get the Matrix animation type
  88656. */
  88657. static readonly ANIMATIONTYPE_MATRIX: number;
  88658. /**
  88659. * Get the Color3 animation type
  88660. */
  88661. static readonly ANIMATIONTYPE_COLOR3: number;
  88662. /**
  88663. * Get the Relative Loop Mode
  88664. */
  88665. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88666. /**
  88667. * Get the Cycle Loop Mode
  88668. */
  88669. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88670. /**
  88671. * Get the Constant Loop Mode
  88672. */
  88673. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88674. /** @hidden */
  88675. static _UniversalLerp(left: any, right: any, amount: number): any;
  88676. /**
  88677. * Parses an animation object and creates an animation
  88678. * @param parsedAnimation Parsed animation object
  88679. * @returns Animation object
  88680. */
  88681. static Parse(parsedAnimation: any): Animation;
  88682. /**
  88683. * Appends the serialized animations from the source animations
  88684. * @param source Source containing the animations
  88685. * @param destination Target to store the animations
  88686. */
  88687. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88688. }
  88689. }
  88690. declare module BABYLON {
  88691. /**
  88692. * Base class of all the textures in babylon.
  88693. * It groups all the common properties the materials, post process, lights... might need
  88694. * in order to make a correct use of the texture.
  88695. */
  88696. export class BaseTexture implements IAnimatable {
  88697. /**
  88698. * Default anisotropic filtering level for the application.
  88699. * It is set to 4 as a good tradeoff between perf and quality.
  88700. */
  88701. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88702. /**
  88703. * Gets or sets the unique id of the texture
  88704. */
  88705. uniqueId: number;
  88706. /**
  88707. * Define the name of the texture.
  88708. */
  88709. name: string;
  88710. /**
  88711. * Gets or sets an object used to store user defined information.
  88712. */
  88713. metadata: any;
  88714. /**
  88715. * For internal use only. Please do not use.
  88716. */
  88717. reservedDataStore: any;
  88718. private _hasAlpha;
  88719. /**
  88720. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88721. */
  88722. hasAlpha: boolean;
  88723. /**
  88724. * Defines if the alpha value should be determined via the rgb values.
  88725. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88726. */
  88727. getAlphaFromRGB: boolean;
  88728. /**
  88729. * Intensity or strength of the texture.
  88730. * It is commonly used by materials to fine tune the intensity of the texture
  88731. */
  88732. level: number;
  88733. /**
  88734. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88735. * This is part of the texture as textures usually maps to one uv set.
  88736. */
  88737. coordinatesIndex: number;
  88738. private _coordinatesMode;
  88739. /**
  88740. * How a texture is mapped.
  88741. *
  88742. * | Value | Type | Description |
  88743. * | ----- | ----------------------------------- | ----------- |
  88744. * | 0 | EXPLICIT_MODE | |
  88745. * | 1 | SPHERICAL_MODE | |
  88746. * | 2 | PLANAR_MODE | |
  88747. * | 3 | CUBIC_MODE | |
  88748. * | 4 | PROJECTION_MODE | |
  88749. * | 5 | SKYBOX_MODE | |
  88750. * | 6 | INVCUBIC_MODE | |
  88751. * | 7 | EQUIRECTANGULAR_MODE | |
  88752. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88753. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88754. */
  88755. coordinatesMode: number;
  88756. /**
  88757. * | Value | Type | Description |
  88758. * | ----- | ------------------ | ----------- |
  88759. * | 0 | CLAMP_ADDRESSMODE | |
  88760. * | 1 | WRAP_ADDRESSMODE | |
  88761. * | 2 | MIRROR_ADDRESSMODE | |
  88762. */
  88763. wrapU: number;
  88764. /**
  88765. * | Value | Type | Description |
  88766. * | ----- | ------------------ | ----------- |
  88767. * | 0 | CLAMP_ADDRESSMODE | |
  88768. * | 1 | WRAP_ADDRESSMODE | |
  88769. * | 2 | MIRROR_ADDRESSMODE | |
  88770. */
  88771. wrapV: number;
  88772. /**
  88773. * | Value | Type | Description |
  88774. * | ----- | ------------------ | ----------- |
  88775. * | 0 | CLAMP_ADDRESSMODE | |
  88776. * | 1 | WRAP_ADDRESSMODE | |
  88777. * | 2 | MIRROR_ADDRESSMODE | |
  88778. */
  88779. wrapR: number;
  88780. /**
  88781. * With compliant hardware and browser (supporting anisotropic filtering)
  88782. * this defines the level of anisotropic filtering in the texture.
  88783. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88784. */
  88785. anisotropicFilteringLevel: number;
  88786. /**
  88787. * Define if the texture is a cube texture or if false a 2d texture.
  88788. */
  88789. isCube: boolean;
  88790. /**
  88791. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88792. */
  88793. is3D: boolean;
  88794. /**
  88795. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88796. * HDR texture are usually stored in linear space.
  88797. * This only impacts the PBR and Background materials
  88798. */
  88799. gammaSpace: boolean;
  88800. /**
  88801. * Gets whether or not the texture contains RGBD data.
  88802. */
  88803. readonly isRGBD: boolean;
  88804. /**
  88805. * Is Z inverted in the texture (useful in a cube texture).
  88806. */
  88807. invertZ: boolean;
  88808. /**
  88809. * Are mip maps generated for this texture or not.
  88810. */
  88811. readonly noMipmap: boolean;
  88812. /**
  88813. * @hidden
  88814. */
  88815. lodLevelInAlpha: boolean;
  88816. /**
  88817. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88818. */
  88819. lodGenerationOffset: number;
  88820. /**
  88821. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88822. */
  88823. lodGenerationScale: number;
  88824. /**
  88825. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  88826. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  88827. * average roughness values.
  88828. */
  88829. linearSpecularLOD: boolean;
  88830. /**
  88831. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  88832. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  88833. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  88834. */
  88835. irradianceTexture: Nullable<BaseTexture>;
  88836. /**
  88837. * Define if the texture is a render target.
  88838. */
  88839. isRenderTarget: boolean;
  88840. /**
  88841. * Define the unique id of the texture in the scene.
  88842. */
  88843. readonly uid: string;
  88844. /**
  88845. * Return a string representation of the texture.
  88846. * @returns the texture as a string
  88847. */
  88848. toString(): string;
  88849. /**
  88850. * Get the class name of the texture.
  88851. * @returns "BaseTexture"
  88852. */
  88853. getClassName(): string;
  88854. /**
  88855. * Define the list of animation attached to the texture.
  88856. */
  88857. animations: Animation[];
  88858. /**
  88859. * An event triggered when the texture is disposed.
  88860. */
  88861. onDisposeObservable: Observable<BaseTexture>;
  88862. private _onDisposeObserver;
  88863. /**
  88864. * Callback triggered when the texture has been disposed.
  88865. * Kept for back compatibility, you can use the onDisposeObservable instead.
  88866. */
  88867. onDispose: () => void;
  88868. /**
  88869. * Define the current state of the loading sequence when in delayed load mode.
  88870. */
  88871. delayLoadState: number;
  88872. private _scene;
  88873. /** @hidden */
  88874. _texture: Nullable<InternalTexture>;
  88875. private _uid;
  88876. /**
  88877. * Define if the texture is preventinga material to render or not.
  88878. * If not and the texture is not ready, the engine will use a default black texture instead.
  88879. */
  88880. readonly isBlocking: boolean;
  88881. /**
  88882. * Instantiates a new BaseTexture.
  88883. * Base class of all the textures in babylon.
  88884. * It groups all the common properties the materials, post process, lights... might need
  88885. * in order to make a correct use of the texture.
  88886. * @param scene Define the scene the texture blongs to
  88887. */
  88888. constructor(scene: Nullable<Scene>);
  88889. /**
  88890. * Get the scene the texture belongs to.
  88891. * @returns the scene or null if undefined
  88892. */
  88893. getScene(): Nullable<Scene>;
  88894. /**
  88895. * Get the texture transform matrix used to offset tile the texture for istance.
  88896. * @returns the transformation matrix
  88897. */
  88898. getTextureMatrix(): Matrix;
  88899. /**
  88900. * Get the texture reflection matrix used to rotate/transform the reflection.
  88901. * @returns the reflection matrix
  88902. */
  88903. getReflectionTextureMatrix(): Matrix;
  88904. /**
  88905. * Get the underlying lower level texture from Babylon.
  88906. * @returns the insternal texture
  88907. */
  88908. getInternalTexture(): Nullable<InternalTexture>;
  88909. /**
  88910. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  88911. * @returns true if ready or not blocking
  88912. */
  88913. isReadyOrNotBlocking(): boolean;
  88914. /**
  88915. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  88916. * @returns true if fully ready
  88917. */
  88918. isReady(): boolean;
  88919. private _cachedSize;
  88920. /**
  88921. * Get the size of the texture.
  88922. * @returns the texture size.
  88923. */
  88924. getSize(): ISize;
  88925. /**
  88926. * Get the base size of the texture.
  88927. * It can be different from the size if the texture has been resized for POT for instance
  88928. * @returns the base size
  88929. */
  88930. getBaseSize(): ISize;
  88931. /**
  88932. * Update the sampling mode of the texture.
  88933. * Default is Trilinear mode.
  88934. *
  88935. * | Value | Type | Description |
  88936. * | ----- | ------------------ | ----------- |
  88937. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  88938. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  88939. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  88940. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  88941. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  88942. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  88943. * | 7 | NEAREST_LINEAR | |
  88944. * | 8 | NEAREST_NEAREST | |
  88945. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  88946. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  88947. * | 11 | LINEAR_LINEAR | |
  88948. * | 12 | LINEAR_NEAREST | |
  88949. *
  88950. * > _mag_: magnification filter (close to the viewer)
  88951. * > _min_: minification filter (far from the viewer)
  88952. * > _mip_: filter used between mip map levels
  88953. *@param samplingMode Define the new sampling mode of the texture
  88954. */
  88955. updateSamplingMode(samplingMode: number): void;
  88956. /**
  88957. * Scales the texture if is `canRescale()`
  88958. * @param ratio the resize factor we want to use to rescale
  88959. */
  88960. scale(ratio: number): void;
  88961. /**
  88962. * Get if the texture can rescale.
  88963. */
  88964. readonly canRescale: boolean;
  88965. /** @hidden */
  88966. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  88967. /** @hidden */
  88968. _rebuild(): void;
  88969. /**
  88970. * Triggers the load sequence in delayed load mode.
  88971. */
  88972. delayLoad(): void;
  88973. /**
  88974. * Clones the texture.
  88975. * @returns the cloned texture
  88976. */
  88977. clone(): Nullable<BaseTexture>;
  88978. /**
  88979. * Get the texture underlying type (INT, FLOAT...)
  88980. */
  88981. readonly textureType: number;
  88982. /**
  88983. * Get the texture underlying format (RGB, RGBA...)
  88984. */
  88985. readonly textureFormat: number;
  88986. /**
  88987. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  88988. * This will returns an RGBA array buffer containing either in values (0-255) or
  88989. * float values (0-1) depending of the underlying buffer type.
  88990. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  88991. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  88992. * @param buffer defines a user defined buffer to fill with data (can be null)
  88993. * @returns The Array buffer containing the pixels data.
  88994. */
  88995. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  88996. /**
  88997. * Release and destroy the underlying lower level texture aka internalTexture.
  88998. */
  88999. releaseInternalTexture(): void;
  89000. /**
  89001. * Get the polynomial representation of the texture data.
  89002. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89003. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89004. */
  89005. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89006. /** @hidden */
  89007. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89008. /** @hidden */
  89009. readonly _lodTextureMid: Nullable<BaseTexture>;
  89010. /** @hidden */
  89011. readonly _lodTextureLow: Nullable<BaseTexture>;
  89012. /**
  89013. * Dispose the texture and release its associated resources.
  89014. */
  89015. dispose(): void;
  89016. /**
  89017. * Serialize the texture into a JSON representation that can be parsed later on.
  89018. * @returns the JSON representation of the texture
  89019. */
  89020. serialize(): any;
  89021. /**
  89022. * Helper function to be called back once a list of texture contains only ready textures.
  89023. * @param textures Define the list of textures to wait for
  89024. * @param callback Define the callback triggered once the entire list will be ready
  89025. */
  89026. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89027. }
  89028. }
  89029. declare module BABYLON {
  89030. /**
  89031. * Uniform buffer objects.
  89032. *
  89033. * Handles blocks of uniform on the GPU.
  89034. *
  89035. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89036. *
  89037. * For more information, please refer to :
  89038. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89039. */
  89040. export class UniformBuffer {
  89041. private _engine;
  89042. private _buffer;
  89043. private _data;
  89044. private _bufferData;
  89045. private _dynamic?;
  89046. private _uniformLocations;
  89047. private _uniformSizes;
  89048. private _uniformLocationPointer;
  89049. private _needSync;
  89050. private _noUBO;
  89051. private _currentEffect;
  89052. private static _MAX_UNIFORM_SIZE;
  89053. private static _tempBuffer;
  89054. /**
  89055. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89056. * This is dynamic to allow compat with webgl 1 and 2.
  89057. * You will need to pass the name of the uniform as well as the value.
  89058. */
  89059. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89060. /**
  89061. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89062. * This is dynamic to allow compat with webgl 1 and 2.
  89063. * You will need to pass the name of the uniform as well as the value.
  89064. */
  89065. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89066. /**
  89067. * Lambda to Update a single float in a uniform buffer.
  89068. * This is dynamic to allow compat with webgl 1 and 2.
  89069. * You will need to pass the name of the uniform as well as the value.
  89070. */
  89071. updateFloat: (name: string, x: number) => void;
  89072. /**
  89073. * Lambda to Update a vec2 of float in a uniform buffer.
  89074. * This is dynamic to allow compat with webgl 1 and 2.
  89075. * You will need to pass the name of the uniform as well as the value.
  89076. */
  89077. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89078. /**
  89079. * Lambda to Update a vec3 of float in a uniform buffer.
  89080. * This is dynamic to allow compat with webgl 1 and 2.
  89081. * You will need to pass the name of the uniform as well as the value.
  89082. */
  89083. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89084. /**
  89085. * Lambda to Update a vec4 of float in a uniform buffer.
  89086. * This is dynamic to allow compat with webgl 1 and 2.
  89087. * You will need to pass the name of the uniform as well as the value.
  89088. */
  89089. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89090. /**
  89091. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89092. * This is dynamic to allow compat with webgl 1 and 2.
  89093. * You will need to pass the name of the uniform as well as the value.
  89094. */
  89095. updateMatrix: (name: string, mat: Matrix) => void;
  89096. /**
  89097. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89098. * This is dynamic to allow compat with webgl 1 and 2.
  89099. * You will need to pass the name of the uniform as well as the value.
  89100. */
  89101. updateVector3: (name: string, vector: Vector3) => void;
  89102. /**
  89103. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89104. * This is dynamic to allow compat with webgl 1 and 2.
  89105. * You will need to pass the name of the uniform as well as the value.
  89106. */
  89107. updateVector4: (name: string, vector: Vector4) => void;
  89108. /**
  89109. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89110. * This is dynamic to allow compat with webgl 1 and 2.
  89111. * You will need to pass the name of the uniform as well as the value.
  89112. */
  89113. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89114. /**
  89115. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89116. * This is dynamic to allow compat with webgl 1 and 2.
  89117. * You will need to pass the name of the uniform as well as the value.
  89118. */
  89119. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89120. /**
  89121. * Instantiates a new Uniform buffer objects.
  89122. *
  89123. * Handles blocks of uniform on the GPU.
  89124. *
  89125. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89126. *
  89127. * For more information, please refer to :
  89128. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89129. * @param engine Define the engine the buffer is associated with
  89130. * @param data Define the data contained in the buffer
  89131. * @param dynamic Define if the buffer is updatable
  89132. */
  89133. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89134. /**
  89135. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89136. * or just falling back on setUniformXXX calls.
  89137. */
  89138. readonly useUbo: boolean;
  89139. /**
  89140. * Indicates if the WebGL underlying uniform buffer is in sync
  89141. * with the javascript cache data.
  89142. */
  89143. readonly isSync: boolean;
  89144. /**
  89145. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89146. * Also, a dynamic UniformBuffer will disable cache verification and always
  89147. * update the underlying WebGL uniform buffer to the GPU.
  89148. * @returns if Dynamic, otherwise false
  89149. */
  89150. isDynamic(): boolean;
  89151. /**
  89152. * The data cache on JS side.
  89153. * @returns the underlying data as a float array
  89154. */
  89155. getData(): Float32Array;
  89156. /**
  89157. * The underlying WebGL Uniform buffer.
  89158. * @returns the webgl buffer
  89159. */
  89160. getBuffer(): Nullable<DataBuffer>;
  89161. /**
  89162. * std140 layout specifies how to align data within an UBO structure.
  89163. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89164. * for specs.
  89165. */
  89166. private _fillAlignment;
  89167. /**
  89168. * Adds an uniform in the buffer.
  89169. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89170. * for the layout to be correct !
  89171. * @param name Name of the uniform, as used in the uniform block in the shader.
  89172. * @param size Data size, or data directly.
  89173. */
  89174. addUniform(name: string, size: number | number[]): void;
  89175. /**
  89176. * Adds a Matrix 4x4 to the uniform buffer.
  89177. * @param name Name of the uniform, as used in the uniform block in the shader.
  89178. * @param mat A 4x4 matrix.
  89179. */
  89180. addMatrix(name: string, mat: Matrix): void;
  89181. /**
  89182. * Adds a vec2 to the uniform buffer.
  89183. * @param name Name of the uniform, as used in the uniform block in the shader.
  89184. * @param x Define the x component value of the vec2
  89185. * @param y Define the y component value of the vec2
  89186. */
  89187. addFloat2(name: string, x: number, y: number): void;
  89188. /**
  89189. * Adds a vec3 to the uniform buffer.
  89190. * @param name Name of the uniform, as used in the uniform block in the shader.
  89191. * @param x Define the x component value of the vec3
  89192. * @param y Define the y component value of the vec3
  89193. * @param z Define the z component value of the vec3
  89194. */
  89195. addFloat3(name: string, x: number, y: number, z: number): void;
  89196. /**
  89197. * Adds a vec3 to the uniform buffer.
  89198. * @param name Name of the uniform, as used in the uniform block in the shader.
  89199. * @param color Define the vec3 from a Color
  89200. */
  89201. addColor3(name: string, color: Color3): void;
  89202. /**
  89203. * Adds a vec4 to the uniform buffer.
  89204. * @param name Name of the uniform, as used in the uniform block in the shader.
  89205. * @param color Define the rgb components from a Color
  89206. * @param alpha Define the a component of the vec4
  89207. */
  89208. addColor4(name: string, color: Color3, alpha: number): void;
  89209. /**
  89210. * Adds a vec3 to the uniform buffer.
  89211. * @param name Name of the uniform, as used in the uniform block in the shader.
  89212. * @param vector Define the vec3 components from a Vector
  89213. */
  89214. addVector3(name: string, vector: Vector3): void;
  89215. /**
  89216. * Adds a Matrix 3x3 to the uniform buffer.
  89217. * @param name Name of the uniform, as used in the uniform block in the shader.
  89218. */
  89219. addMatrix3x3(name: string): void;
  89220. /**
  89221. * Adds a Matrix 2x2 to the uniform buffer.
  89222. * @param name Name of the uniform, as used in the uniform block in the shader.
  89223. */
  89224. addMatrix2x2(name: string): void;
  89225. /**
  89226. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89227. */
  89228. create(): void;
  89229. /** @hidden */
  89230. _rebuild(): void;
  89231. /**
  89232. * Updates the WebGL Uniform Buffer on the GPU.
  89233. * If the `dynamic` flag is set to true, no cache comparison is done.
  89234. * Otherwise, the buffer will be updated only if the cache differs.
  89235. */
  89236. update(): void;
  89237. /**
  89238. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89239. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89240. * @param data Define the flattened data
  89241. * @param size Define the size of the data.
  89242. */
  89243. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89244. private _updateMatrix3x3ForUniform;
  89245. private _updateMatrix3x3ForEffect;
  89246. private _updateMatrix2x2ForEffect;
  89247. private _updateMatrix2x2ForUniform;
  89248. private _updateFloatForEffect;
  89249. private _updateFloatForUniform;
  89250. private _updateFloat2ForEffect;
  89251. private _updateFloat2ForUniform;
  89252. private _updateFloat3ForEffect;
  89253. private _updateFloat3ForUniform;
  89254. private _updateFloat4ForEffect;
  89255. private _updateFloat4ForUniform;
  89256. private _updateMatrixForEffect;
  89257. private _updateMatrixForUniform;
  89258. private _updateVector3ForEffect;
  89259. private _updateVector3ForUniform;
  89260. private _updateVector4ForEffect;
  89261. private _updateVector4ForUniform;
  89262. private _updateColor3ForEffect;
  89263. private _updateColor3ForUniform;
  89264. private _updateColor4ForEffect;
  89265. private _updateColor4ForUniform;
  89266. /**
  89267. * Sets a sampler uniform on the effect.
  89268. * @param name Define the name of the sampler.
  89269. * @param texture Define the texture to set in the sampler
  89270. */
  89271. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89272. /**
  89273. * Directly updates the value of the uniform in the cache AND on the GPU.
  89274. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89275. * @param data Define the flattened data
  89276. */
  89277. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89278. /**
  89279. * Binds this uniform buffer to an effect.
  89280. * @param effect Define the effect to bind the buffer to
  89281. * @param name Name of the uniform block in the shader.
  89282. */
  89283. bindToEffect(effect: Effect, name: string): void;
  89284. /**
  89285. * Disposes the uniform buffer.
  89286. */
  89287. dispose(): void;
  89288. }
  89289. }
  89290. declare module BABYLON {
  89291. /**
  89292. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89294. */
  89295. export class Analyser {
  89296. /**
  89297. * Gets or sets the smoothing
  89298. * @ignorenaming
  89299. */
  89300. SMOOTHING: number;
  89301. /**
  89302. * Gets or sets the FFT table size
  89303. * @ignorenaming
  89304. */
  89305. FFT_SIZE: number;
  89306. /**
  89307. * Gets or sets the bar graph amplitude
  89308. * @ignorenaming
  89309. */
  89310. BARGRAPHAMPLITUDE: number;
  89311. /**
  89312. * Gets or sets the position of the debug canvas
  89313. * @ignorenaming
  89314. */
  89315. DEBUGCANVASPOS: {
  89316. x: number;
  89317. y: number;
  89318. };
  89319. /**
  89320. * Gets or sets the debug canvas size
  89321. * @ignorenaming
  89322. */
  89323. DEBUGCANVASSIZE: {
  89324. width: number;
  89325. height: number;
  89326. };
  89327. private _byteFreqs;
  89328. private _byteTime;
  89329. private _floatFreqs;
  89330. private _webAudioAnalyser;
  89331. private _debugCanvas;
  89332. private _debugCanvasContext;
  89333. private _scene;
  89334. private _registerFunc;
  89335. private _audioEngine;
  89336. /**
  89337. * Creates a new analyser
  89338. * @param scene defines hosting scene
  89339. */
  89340. constructor(scene: Scene);
  89341. /**
  89342. * Get the number of data values you will have to play with for the visualization
  89343. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89344. * @returns a number
  89345. */
  89346. getFrequencyBinCount(): number;
  89347. /**
  89348. * Gets the current frequency data as a byte array
  89349. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89350. * @returns a Uint8Array
  89351. */
  89352. getByteFrequencyData(): Uint8Array;
  89353. /**
  89354. * Gets the current waveform as a byte array
  89355. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89356. * @returns a Uint8Array
  89357. */
  89358. getByteTimeDomainData(): Uint8Array;
  89359. /**
  89360. * Gets the current frequency data as a float array
  89361. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89362. * @returns a Float32Array
  89363. */
  89364. getFloatFrequencyData(): Float32Array;
  89365. /**
  89366. * Renders the debug canvas
  89367. */
  89368. drawDebugCanvas(): void;
  89369. /**
  89370. * Stops rendering the debug canvas and removes it
  89371. */
  89372. stopDebugCanvas(): void;
  89373. /**
  89374. * Connects two audio nodes
  89375. * @param inputAudioNode defines first node to connect
  89376. * @param outputAudioNode defines second node to connect
  89377. */
  89378. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89379. /**
  89380. * Releases all associated resources
  89381. */
  89382. dispose(): void;
  89383. }
  89384. }
  89385. declare module BABYLON {
  89386. /**
  89387. * This represents an audio engine and it is responsible
  89388. * to play, synchronize and analyse sounds throughout the application.
  89389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89390. */
  89391. export interface IAudioEngine extends IDisposable {
  89392. /**
  89393. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89394. */
  89395. readonly canUseWebAudio: boolean;
  89396. /**
  89397. * Gets the current AudioContext if available.
  89398. */
  89399. readonly audioContext: Nullable<AudioContext>;
  89400. /**
  89401. * The master gain node defines the global audio volume of your audio engine.
  89402. */
  89403. readonly masterGain: GainNode;
  89404. /**
  89405. * Gets whether or not mp3 are supported by your browser.
  89406. */
  89407. readonly isMP3supported: boolean;
  89408. /**
  89409. * Gets whether or not ogg are supported by your browser.
  89410. */
  89411. readonly isOGGsupported: boolean;
  89412. /**
  89413. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89414. * @ignoreNaming
  89415. */
  89416. WarnedWebAudioUnsupported: boolean;
  89417. /**
  89418. * Defines if the audio engine relies on a custom unlocked button.
  89419. * In this case, the embedded button will not be displayed.
  89420. */
  89421. useCustomUnlockedButton: boolean;
  89422. /**
  89423. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89424. */
  89425. readonly unlocked: boolean;
  89426. /**
  89427. * Event raised when audio has been unlocked on the browser.
  89428. */
  89429. onAudioUnlockedObservable: Observable<AudioEngine>;
  89430. /**
  89431. * Event raised when audio has been locked on the browser.
  89432. */
  89433. onAudioLockedObservable: Observable<AudioEngine>;
  89434. /**
  89435. * Flags the audio engine in Locked state.
  89436. * This happens due to new browser policies preventing audio to autoplay.
  89437. */
  89438. lock(): void;
  89439. /**
  89440. * Unlocks the audio engine once a user action has been done on the dom.
  89441. * This is helpful to resume play once browser policies have been satisfied.
  89442. */
  89443. unlock(): void;
  89444. }
  89445. /**
  89446. * This represents the default audio engine used in babylon.
  89447. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89449. */
  89450. export class AudioEngine implements IAudioEngine {
  89451. private _audioContext;
  89452. private _audioContextInitialized;
  89453. private _muteButton;
  89454. private _hostElement;
  89455. /**
  89456. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89457. */
  89458. canUseWebAudio: boolean;
  89459. /**
  89460. * The master gain node defines the global audio volume of your audio engine.
  89461. */
  89462. masterGain: GainNode;
  89463. /**
  89464. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89465. * @ignoreNaming
  89466. */
  89467. WarnedWebAudioUnsupported: boolean;
  89468. /**
  89469. * Gets whether or not mp3 are supported by your browser.
  89470. */
  89471. isMP3supported: boolean;
  89472. /**
  89473. * Gets whether or not ogg are supported by your browser.
  89474. */
  89475. isOGGsupported: boolean;
  89476. /**
  89477. * Gets whether audio has been unlocked on the device.
  89478. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89479. * a user interaction has happened.
  89480. */
  89481. unlocked: boolean;
  89482. /**
  89483. * Defines if the audio engine relies on a custom unlocked button.
  89484. * In this case, the embedded button will not be displayed.
  89485. */
  89486. useCustomUnlockedButton: boolean;
  89487. /**
  89488. * Event raised when audio has been unlocked on the browser.
  89489. */
  89490. onAudioUnlockedObservable: Observable<AudioEngine>;
  89491. /**
  89492. * Event raised when audio has been locked on the browser.
  89493. */
  89494. onAudioLockedObservable: Observable<AudioEngine>;
  89495. /**
  89496. * Gets the current AudioContext if available.
  89497. */
  89498. readonly audioContext: Nullable<AudioContext>;
  89499. private _connectedAnalyser;
  89500. /**
  89501. * Instantiates a new audio engine.
  89502. *
  89503. * There should be only one per page as some browsers restrict the number
  89504. * of audio contexts you can create.
  89505. * @param hostElement defines the host element where to display the mute icon if necessary
  89506. */
  89507. constructor(hostElement?: Nullable<HTMLElement>);
  89508. /**
  89509. * Flags the audio engine in Locked state.
  89510. * This happens due to new browser policies preventing audio to autoplay.
  89511. */
  89512. lock(): void;
  89513. /**
  89514. * Unlocks the audio engine once a user action has been done on the dom.
  89515. * This is helpful to resume play once browser policies have been satisfied.
  89516. */
  89517. unlock(): void;
  89518. private _resumeAudioContext;
  89519. private _initializeAudioContext;
  89520. private _tryToRun;
  89521. private _triggerRunningState;
  89522. private _triggerSuspendedState;
  89523. private _displayMuteButton;
  89524. private _moveButtonToTopLeft;
  89525. private _onResize;
  89526. private _hideMuteButton;
  89527. /**
  89528. * Destroy and release the resources associated with the audio ccontext.
  89529. */
  89530. dispose(): void;
  89531. /**
  89532. * Gets the global volume sets on the master gain.
  89533. * @returns the global volume if set or -1 otherwise
  89534. */
  89535. getGlobalVolume(): number;
  89536. /**
  89537. * Sets the global volume of your experience (sets on the master gain).
  89538. * @param newVolume Defines the new global volume of the application
  89539. */
  89540. setGlobalVolume(newVolume: number): void;
  89541. /**
  89542. * Connect the audio engine to an audio analyser allowing some amazing
  89543. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89545. * @param analyser The analyser to connect to the engine
  89546. */
  89547. connectToAnalyser(analyser: Analyser): void;
  89548. }
  89549. }
  89550. declare module BABYLON {
  89551. /**
  89552. * Interface used to present a loading screen while loading a scene
  89553. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89554. */
  89555. export interface ILoadingScreen {
  89556. /**
  89557. * Function called to display the loading screen
  89558. */
  89559. displayLoadingUI: () => void;
  89560. /**
  89561. * Function called to hide the loading screen
  89562. */
  89563. hideLoadingUI: () => void;
  89564. /**
  89565. * Gets or sets the color to use for the background
  89566. */
  89567. loadingUIBackgroundColor: string;
  89568. /**
  89569. * Gets or sets the text to display while loading
  89570. */
  89571. loadingUIText: string;
  89572. }
  89573. /**
  89574. * Class used for the default loading screen
  89575. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89576. */
  89577. export class DefaultLoadingScreen implements ILoadingScreen {
  89578. private _renderingCanvas;
  89579. private _loadingText;
  89580. private _loadingDivBackgroundColor;
  89581. private _loadingDiv;
  89582. private _loadingTextDiv;
  89583. /** Gets or sets the logo url to use for the default loading screen */
  89584. static DefaultLogoUrl: string;
  89585. /** Gets or sets the spinner url to use for the default loading screen */
  89586. static DefaultSpinnerUrl: string;
  89587. /**
  89588. * Creates a new default loading screen
  89589. * @param _renderingCanvas defines the canvas used to render the scene
  89590. * @param _loadingText defines the default text to display
  89591. * @param _loadingDivBackgroundColor defines the default background color
  89592. */
  89593. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  89594. /**
  89595. * Function called to display the loading screen
  89596. */
  89597. displayLoadingUI(): void;
  89598. /**
  89599. * Function called to hide the loading screen
  89600. */
  89601. hideLoadingUI(): void;
  89602. /**
  89603. * Gets or sets the text to display while loading
  89604. */
  89605. loadingUIText: string;
  89606. /**
  89607. * Gets or sets the color to use for the background
  89608. */
  89609. loadingUIBackgroundColor: string;
  89610. private _resizeLoadingUI;
  89611. }
  89612. }
  89613. declare module BABYLON {
  89614. /** @hidden */
  89615. export class WebGLPipelineContext implements IPipelineContext {
  89616. engine: Engine;
  89617. program: Nullable<WebGLProgram>;
  89618. context?: WebGLRenderingContext;
  89619. vertexShader?: WebGLShader;
  89620. fragmentShader?: WebGLShader;
  89621. isParallelCompiled: boolean;
  89622. onCompiled?: () => void;
  89623. transformFeedback?: WebGLTransformFeedback | null;
  89624. readonly isAsync: boolean;
  89625. readonly isReady: boolean;
  89626. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89627. }
  89628. }
  89629. declare module BABYLON {
  89630. /** @hidden */
  89631. export class WebGLDataBuffer extends DataBuffer {
  89632. private _buffer;
  89633. constructor(resource: WebGLBuffer);
  89634. readonly underlyingResource: any;
  89635. }
  89636. }
  89637. declare module BABYLON {
  89638. /** @hidden */
  89639. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89640. attributeProcessor(attribute: string): string;
  89641. varyingProcessor(varying: string, isFragment: boolean): string;
  89642. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89643. }
  89644. }
  89645. declare module BABYLON {
  89646. /**
  89647. * Settings for finer control over video usage
  89648. */
  89649. export interface VideoTextureSettings {
  89650. /**
  89651. * Applies `autoplay` to video, if specified
  89652. */
  89653. autoPlay?: boolean;
  89654. /**
  89655. * Applies `loop` to video, if specified
  89656. */
  89657. loop?: boolean;
  89658. /**
  89659. * Automatically updates internal texture from video at every frame in the render loop
  89660. */
  89661. autoUpdateTexture: boolean;
  89662. /**
  89663. * Image src displayed during the video loading or until the user interacts with the video.
  89664. */
  89665. poster?: string;
  89666. }
  89667. /**
  89668. * If you want to display a video in your scene, this is the special texture for that.
  89669. * This special texture works similar to other textures, with the exception of a few parameters.
  89670. * @see https://doc.babylonjs.com/how_to/video_texture
  89671. */
  89672. export class VideoTexture extends Texture {
  89673. /**
  89674. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89675. */
  89676. readonly autoUpdateTexture: boolean;
  89677. /**
  89678. * The video instance used by the texture internally
  89679. */
  89680. readonly video: HTMLVideoElement;
  89681. private _onUserActionRequestedObservable;
  89682. /**
  89683. * Event triggerd when a dom action is required by the user to play the video.
  89684. * This happens due to recent changes in browser policies preventing video to auto start.
  89685. */
  89686. readonly onUserActionRequestedObservable: Observable<Texture>;
  89687. private _generateMipMaps;
  89688. private _engine;
  89689. private _stillImageCaptured;
  89690. private _displayingPosterTexture;
  89691. private _settings;
  89692. private _createInternalTextureOnEvent;
  89693. /**
  89694. * Creates a video texture.
  89695. * If you want to display a video in your scene, this is the special texture for that.
  89696. * This special texture works similar to other textures, with the exception of a few parameters.
  89697. * @see https://doc.babylonjs.com/how_to/video_texture
  89698. * @param name optional name, will detect from video source, if not defined
  89699. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89700. * @param scene is obviously the current scene.
  89701. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89702. * @param invertY is false by default but can be used to invert video on Y axis
  89703. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89704. * @param settings allows finer control over video usage
  89705. */
  89706. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89707. private _getName;
  89708. private _getVideo;
  89709. private _createInternalTexture;
  89710. private reset;
  89711. /**
  89712. * @hidden Internal method to initiate `update`.
  89713. */
  89714. _rebuild(): void;
  89715. /**
  89716. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89717. */
  89718. update(): void;
  89719. /**
  89720. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89721. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89722. */
  89723. updateTexture(isVisible: boolean): void;
  89724. protected _updateInternalTexture: () => void;
  89725. /**
  89726. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89727. * @param url New url.
  89728. */
  89729. updateURL(url: string): void;
  89730. /**
  89731. * Dispose the texture and release its associated resources.
  89732. */
  89733. dispose(): void;
  89734. /**
  89735. * Creates a video texture straight from a stream.
  89736. * @param scene Define the scene the texture should be created in
  89737. * @param stream Define the stream the texture should be created from
  89738. * @returns The created video texture as a promise
  89739. */
  89740. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89741. /**
  89742. * Creates a video texture straight from your WebCam video feed.
  89743. * @param scene Define the scene the texture should be created in
  89744. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89745. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89746. * @returns The created video texture as a promise
  89747. */
  89748. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89749. minWidth: number;
  89750. maxWidth: number;
  89751. minHeight: number;
  89752. maxHeight: number;
  89753. deviceId: string;
  89754. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89755. /**
  89756. * Creates a video texture straight from your WebCam video feed.
  89757. * @param scene Define the scene the texture should be created in
  89758. * @param onReady Define a callback to triggered once the texture will be ready
  89759. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89760. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89761. */
  89762. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89763. minWidth: number;
  89764. maxWidth: number;
  89765. minHeight: number;
  89766. maxHeight: number;
  89767. deviceId: string;
  89768. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89769. }
  89770. }
  89771. declare module BABYLON {
  89772. /**
  89773. * Interface for attribute information associated with buffer instanciation
  89774. */
  89775. export class InstancingAttributeInfo {
  89776. /**
  89777. * Index/offset of the attribute in the vertex shader
  89778. */
  89779. index: number;
  89780. /**
  89781. * size of the attribute, 1, 2, 3 or 4
  89782. */
  89783. attributeSize: number;
  89784. /**
  89785. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89786. * default is FLOAT
  89787. */
  89788. attribyteType: number;
  89789. /**
  89790. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89791. */
  89792. normalized: boolean;
  89793. /**
  89794. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89795. */
  89796. offset: number;
  89797. /**
  89798. * Name of the GLSL attribute, for debugging purpose only
  89799. */
  89800. attributeName: string;
  89801. }
  89802. /**
  89803. * Define options used to create a depth texture
  89804. */
  89805. export class DepthTextureCreationOptions {
  89806. /** Specifies whether or not a stencil should be allocated in the texture */
  89807. generateStencil?: boolean;
  89808. /** Specifies whether or not bilinear filtering is enable on the texture */
  89809. bilinearFiltering?: boolean;
  89810. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89811. comparisonFunction?: number;
  89812. /** Specifies if the created texture is a cube texture */
  89813. isCube?: boolean;
  89814. }
  89815. /**
  89816. * Class used to describe the capabilities of the engine relatively to the current browser
  89817. */
  89818. export class EngineCapabilities {
  89819. /** Maximum textures units per fragment shader */
  89820. maxTexturesImageUnits: number;
  89821. /** Maximum texture units per vertex shader */
  89822. maxVertexTextureImageUnits: number;
  89823. /** Maximum textures units in the entire pipeline */
  89824. maxCombinedTexturesImageUnits: number;
  89825. /** Maximum texture size */
  89826. maxTextureSize: number;
  89827. /** Maximum cube texture size */
  89828. maxCubemapTextureSize: number;
  89829. /** Maximum render texture size */
  89830. maxRenderTextureSize: number;
  89831. /** Maximum number of vertex attributes */
  89832. maxVertexAttribs: number;
  89833. /** Maximum number of varyings */
  89834. maxVaryingVectors: number;
  89835. /** Maximum number of uniforms per vertex shader */
  89836. maxVertexUniformVectors: number;
  89837. /** Maximum number of uniforms per fragment shader */
  89838. maxFragmentUniformVectors: number;
  89839. /** Defines if standard derivates (dx/dy) are supported */
  89840. standardDerivatives: boolean;
  89841. /** Defines if s3tc texture compression is supported */
  89842. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89843. /** Defines if pvrtc texture compression is supported */
  89844. pvrtc: any;
  89845. /** Defines if etc1 texture compression is supported */
  89846. etc1: any;
  89847. /** Defines if etc2 texture compression is supported */
  89848. etc2: any;
  89849. /** Defines if astc texture compression is supported */
  89850. astc: any;
  89851. /** Defines if float textures are supported */
  89852. textureFloat: boolean;
  89853. /** Defines if vertex array objects are supported */
  89854. vertexArrayObject: boolean;
  89855. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  89856. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  89857. /** Gets the maximum level of anisotropy supported */
  89858. maxAnisotropy: number;
  89859. /** Defines if instancing is supported */
  89860. instancedArrays: boolean;
  89861. /** Defines if 32 bits indices are supported */
  89862. uintIndices: boolean;
  89863. /** Defines if high precision shaders are supported */
  89864. highPrecisionShaderSupported: boolean;
  89865. /** Defines if depth reading in the fragment shader is supported */
  89866. fragmentDepthSupported: boolean;
  89867. /** Defines if float texture linear filtering is supported*/
  89868. textureFloatLinearFiltering: boolean;
  89869. /** Defines if rendering to float textures is supported */
  89870. textureFloatRender: boolean;
  89871. /** Defines if half float textures are supported*/
  89872. textureHalfFloat: boolean;
  89873. /** Defines if half float texture linear filtering is supported*/
  89874. textureHalfFloatLinearFiltering: boolean;
  89875. /** Defines if rendering to half float textures is supported */
  89876. textureHalfFloatRender: boolean;
  89877. /** Defines if textureLOD shader command is supported */
  89878. textureLOD: boolean;
  89879. /** Defines if draw buffers extension is supported */
  89880. drawBuffersExtension: boolean;
  89881. /** Defines if depth textures are supported */
  89882. depthTextureExtension: boolean;
  89883. /** Defines if float color buffer are supported */
  89884. colorBufferFloat: boolean;
  89885. /** Gets disjoint timer query extension (null if not supported) */
  89886. timerQuery: EXT_disjoint_timer_query;
  89887. /** Defines if timestamp can be used with timer query */
  89888. canUseTimestampForTimerQuery: boolean;
  89889. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  89890. multiview: any;
  89891. /** Function used to let the system compiles shaders in background */
  89892. parallelShaderCompile: {
  89893. COMPLETION_STATUS_KHR: number;
  89894. };
  89895. }
  89896. /** Interface defining initialization parameters for Engine class */
  89897. export interface EngineOptions extends WebGLContextAttributes {
  89898. /**
  89899. * Defines if the engine should no exceed a specified device ratio
  89900. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  89901. */
  89902. limitDeviceRatio?: number;
  89903. /**
  89904. * Defines if webvr should be enabled automatically
  89905. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89906. */
  89907. autoEnableWebVR?: boolean;
  89908. /**
  89909. * Defines if webgl2 should be turned off even if supported
  89910. * @see http://doc.babylonjs.com/features/webgl2
  89911. */
  89912. disableWebGL2Support?: boolean;
  89913. /**
  89914. * Defines if webaudio should be initialized as well
  89915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89916. */
  89917. audioEngine?: boolean;
  89918. /**
  89919. * Defines if animations should run using a deterministic lock step
  89920. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89921. */
  89922. deterministicLockstep?: boolean;
  89923. /** Defines the maximum steps to use with deterministic lock step mode */
  89924. lockstepMaxSteps?: number;
  89925. /**
  89926. * Defines that engine should ignore context lost events
  89927. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  89928. */
  89929. doNotHandleContextLost?: boolean;
  89930. /**
  89931. * Defines that engine should ignore modifying touch action attribute and style
  89932. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  89933. */
  89934. doNotHandleTouchAction?: boolean;
  89935. /**
  89936. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  89937. */
  89938. useHighPrecisionFloats?: boolean;
  89939. }
  89940. /**
  89941. * Defines the interface used by display changed events
  89942. */
  89943. export interface IDisplayChangedEventArgs {
  89944. /** Gets the vrDisplay object (if any) */
  89945. vrDisplay: Nullable<any>;
  89946. /** Gets a boolean indicating if webVR is supported */
  89947. vrSupported: boolean;
  89948. }
  89949. /**
  89950. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  89951. */
  89952. export class Engine {
  89953. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  89954. static ExceptionList: ({
  89955. key: string;
  89956. capture: string;
  89957. captureConstraint: number;
  89958. targets: string[];
  89959. } | {
  89960. key: string;
  89961. capture: null;
  89962. captureConstraint: null;
  89963. targets: string[];
  89964. })[];
  89965. /** Gets the list of created engines */
  89966. static readonly Instances: Engine[];
  89967. /**
  89968. * Gets the latest created engine
  89969. */
  89970. static readonly LastCreatedEngine: Nullable<Engine>;
  89971. /**
  89972. * Gets the latest created scene
  89973. */
  89974. static readonly LastCreatedScene: Nullable<Scene>;
  89975. /**
  89976. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  89977. * @param flag defines which part of the materials must be marked as dirty
  89978. * @param predicate defines a predicate used to filter which materials should be affected
  89979. */
  89980. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89981. /** @hidden */
  89982. static _TextureLoaders: IInternalTextureLoader[];
  89983. /** Defines that alpha blending is disabled */
  89984. static readonly ALPHA_DISABLE: number;
  89985. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  89986. static readonly ALPHA_ADD: number;
  89987. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  89988. static readonly ALPHA_COMBINE: number;
  89989. /** Defines that alpha blending to DEST - SRC * DEST */
  89990. static readonly ALPHA_SUBTRACT: number;
  89991. /** Defines that alpha blending to SRC * DEST */
  89992. static readonly ALPHA_MULTIPLY: number;
  89993. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  89994. static readonly ALPHA_MAXIMIZED: number;
  89995. /** Defines that alpha blending to SRC + DEST */
  89996. static readonly ALPHA_ONEONE: number;
  89997. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  89998. static readonly ALPHA_PREMULTIPLIED: number;
  89999. /**
  90000. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90001. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90002. */
  90003. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90004. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90005. static readonly ALPHA_INTERPOLATE: number;
  90006. /**
  90007. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90008. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90009. */
  90010. static readonly ALPHA_SCREENMODE: number;
  90011. /** Defines that the ressource is not delayed*/
  90012. static readonly DELAYLOADSTATE_NONE: number;
  90013. /** Defines that the ressource was successfully delay loaded */
  90014. static readonly DELAYLOADSTATE_LOADED: number;
  90015. /** Defines that the ressource is currently delay loading */
  90016. static readonly DELAYLOADSTATE_LOADING: number;
  90017. /** Defines that the ressource is delayed and has not started loading */
  90018. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90019. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90020. static readonly NEVER: number;
  90021. /** 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 */
  90022. static readonly ALWAYS: number;
  90023. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90024. static readonly LESS: number;
  90025. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90026. static readonly EQUAL: number;
  90027. /** 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 */
  90028. static readonly LEQUAL: number;
  90029. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90030. static readonly GREATER: number;
  90031. /** 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 */
  90032. static readonly GEQUAL: number;
  90033. /** 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 */
  90034. static readonly NOTEQUAL: number;
  90035. /** Passed to stencilOperation to specify that stencil value must be kept */
  90036. static readonly KEEP: number;
  90037. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90038. static readonly REPLACE: number;
  90039. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90040. static readonly INCR: number;
  90041. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90042. static readonly DECR: number;
  90043. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90044. static readonly INVERT: number;
  90045. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90046. static readonly INCR_WRAP: number;
  90047. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90048. static readonly DECR_WRAP: number;
  90049. /** Texture is not repeating outside of 0..1 UVs */
  90050. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90051. /** Texture is repeating outside of 0..1 UVs */
  90052. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90053. /** Texture is repeating and mirrored */
  90054. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90055. /** ALPHA */
  90056. static readonly TEXTUREFORMAT_ALPHA: number;
  90057. /** LUMINANCE */
  90058. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90059. /** LUMINANCE_ALPHA */
  90060. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90061. /** RGB */
  90062. static readonly TEXTUREFORMAT_RGB: number;
  90063. /** RGBA */
  90064. static readonly TEXTUREFORMAT_RGBA: number;
  90065. /** RED */
  90066. static readonly TEXTUREFORMAT_RED: number;
  90067. /** RED (2nd reference) */
  90068. static readonly TEXTUREFORMAT_R: number;
  90069. /** RG */
  90070. static readonly TEXTUREFORMAT_RG: number;
  90071. /** RED_INTEGER */
  90072. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90073. /** RED_INTEGER (2nd reference) */
  90074. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90075. /** RG_INTEGER */
  90076. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90077. /** RGB_INTEGER */
  90078. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90079. /** RGBA_INTEGER */
  90080. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90081. /** UNSIGNED_BYTE */
  90082. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90083. /** UNSIGNED_BYTE (2nd reference) */
  90084. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90085. /** FLOAT */
  90086. static readonly TEXTURETYPE_FLOAT: number;
  90087. /** HALF_FLOAT */
  90088. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90089. /** BYTE */
  90090. static readonly TEXTURETYPE_BYTE: number;
  90091. /** SHORT */
  90092. static readonly TEXTURETYPE_SHORT: number;
  90093. /** UNSIGNED_SHORT */
  90094. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90095. /** INT */
  90096. static readonly TEXTURETYPE_INT: number;
  90097. /** UNSIGNED_INT */
  90098. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90099. /** UNSIGNED_SHORT_4_4_4_4 */
  90100. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90101. /** UNSIGNED_SHORT_5_5_5_1 */
  90102. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90103. /** UNSIGNED_SHORT_5_6_5 */
  90104. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90105. /** UNSIGNED_INT_2_10_10_10_REV */
  90106. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90107. /** UNSIGNED_INT_24_8 */
  90108. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90109. /** UNSIGNED_INT_10F_11F_11F_REV */
  90110. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90111. /** UNSIGNED_INT_5_9_9_9_REV */
  90112. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90113. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90114. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90115. /** nearest is mag = nearest and min = nearest and mip = linear */
  90116. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90117. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90118. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90119. /** Trilinear is mag = linear and min = linear and mip = linear */
  90120. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90121. /** nearest is mag = nearest and min = nearest and mip = linear */
  90122. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90123. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90124. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90125. /** Trilinear is mag = linear and min = linear and mip = linear */
  90126. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90127. /** mag = nearest and min = nearest and mip = nearest */
  90128. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90129. /** mag = nearest and min = linear and mip = nearest */
  90130. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90131. /** mag = nearest and min = linear and mip = linear */
  90132. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90133. /** mag = nearest and min = linear and mip = none */
  90134. static readonly TEXTURE_NEAREST_LINEAR: number;
  90135. /** mag = nearest and min = nearest and mip = none */
  90136. static readonly TEXTURE_NEAREST_NEAREST: number;
  90137. /** mag = linear and min = nearest and mip = nearest */
  90138. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90139. /** mag = linear and min = nearest and mip = linear */
  90140. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90141. /** mag = linear and min = linear and mip = none */
  90142. static readonly TEXTURE_LINEAR_LINEAR: number;
  90143. /** mag = linear and min = nearest and mip = none */
  90144. static readonly TEXTURE_LINEAR_NEAREST: number;
  90145. /** Explicit coordinates mode */
  90146. static readonly TEXTURE_EXPLICIT_MODE: number;
  90147. /** Spherical coordinates mode */
  90148. static readonly TEXTURE_SPHERICAL_MODE: number;
  90149. /** Planar coordinates mode */
  90150. static readonly TEXTURE_PLANAR_MODE: number;
  90151. /** Cubic coordinates mode */
  90152. static readonly TEXTURE_CUBIC_MODE: number;
  90153. /** Projection coordinates mode */
  90154. static readonly TEXTURE_PROJECTION_MODE: number;
  90155. /** Skybox coordinates mode */
  90156. static readonly TEXTURE_SKYBOX_MODE: number;
  90157. /** Inverse Cubic coordinates mode */
  90158. static readonly TEXTURE_INVCUBIC_MODE: number;
  90159. /** Equirectangular coordinates mode */
  90160. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90161. /** Equirectangular Fixed coordinates mode */
  90162. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90163. /** Equirectangular Fixed Mirrored coordinates mode */
  90164. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90165. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90166. static readonly SCALEMODE_FLOOR: number;
  90167. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90168. static readonly SCALEMODE_NEAREST: number;
  90169. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90170. static readonly SCALEMODE_CEILING: number;
  90171. /**
  90172. * Returns the current npm package of the sdk
  90173. */
  90174. static readonly NpmPackage: string;
  90175. /**
  90176. * Returns the current version of the framework
  90177. */
  90178. static readonly Version: string;
  90179. /**
  90180. * Returns a string describing the current engine
  90181. */
  90182. readonly description: string;
  90183. /**
  90184. * Gets or sets the epsilon value used by collision engine
  90185. */
  90186. static CollisionsEpsilon: number;
  90187. /**
  90188. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90189. */
  90190. static ShadersRepository: string;
  90191. /**
  90192. * Method called to create the default loading screen.
  90193. * This can be overriden in your own app.
  90194. * @param canvas The rendering canvas element
  90195. * @returns The loading screen
  90196. */
  90197. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90198. /**
  90199. * Method called to create the default rescale post process on each engine.
  90200. */
  90201. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90202. /** @hidden */
  90203. _shaderProcessor: IShaderProcessor;
  90204. /**
  90205. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90206. */
  90207. forcePOTTextures: boolean;
  90208. /**
  90209. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90210. */
  90211. isFullscreen: boolean;
  90212. /**
  90213. * Gets a boolean indicating if the pointer is currently locked
  90214. */
  90215. isPointerLock: boolean;
  90216. /**
  90217. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90218. */
  90219. cullBackFaces: boolean;
  90220. /**
  90221. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90222. */
  90223. renderEvenInBackground: boolean;
  90224. /**
  90225. * Gets or sets a boolean indicating that cache can be kept between frames
  90226. */
  90227. preventCacheWipeBetweenFrames: boolean;
  90228. /**
  90229. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90230. **/
  90231. enableOfflineSupport: boolean;
  90232. /**
  90233. * 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)
  90234. **/
  90235. disableManifestCheck: boolean;
  90236. /**
  90237. * Gets the list of created scenes
  90238. */
  90239. scenes: Scene[];
  90240. /**
  90241. * Event raised when a new scene is created
  90242. */
  90243. onNewSceneAddedObservable: Observable<Scene>;
  90244. /**
  90245. * Gets the list of created postprocesses
  90246. */
  90247. postProcesses: PostProcess[];
  90248. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90249. validateShaderPrograms: boolean;
  90250. /**
  90251. * Observable event triggered each time the rendering canvas is resized
  90252. */
  90253. onResizeObservable: Observable<Engine>;
  90254. /**
  90255. * Observable event triggered each time the canvas loses focus
  90256. */
  90257. onCanvasBlurObservable: Observable<Engine>;
  90258. /**
  90259. * Observable event triggered each time the canvas gains focus
  90260. */
  90261. onCanvasFocusObservable: Observable<Engine>;
  90262. /**
  90263. * Observable event triggered each time the canvas receives pointerout event
  90264. */
  90265. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90266. /**
  90267. * Observable event triggered before each texture is initialized
  90268. */
  90269. onBeforeTextureInitObservable: Observable<Texture>;
  90270. /**
  90271. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90272. */
  90273. disableUniformBuffers: boolean;
  90274. /** @hidden */
  90275. _uniformBuffers: UniformBuffer[];
  90276. /**
  90277. * Gets a boolean indicating that the engine supports uniform buffers
  90278. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90279. */
  90280. readonly supportsUniformBuffers: boolean;
  90281. /**
  90282. * Observable raised when the engine begins a new frame
  90283. */
  90284. onBeginFrameObservable: Observable<Engine>;
  90285. /**
  90286. * If set, will be used to request the next animation frame for the render loop
  90287. */
  90288. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90289. /**
  90290. * Observable raised when the engine ends the current frame
  90291. */
  90292. onEndFrameObservable: Observable<Engine>;
  90293. /**
  90294. * Observable raised when the engine is about to compile a shader
  90295. */
  90296. onBeforeShaderCompilationObservable: Observable<Engine>;
  90297. /**
  90298. * Observable raised when the engine has jsut compiled a shader
  90299. */
  90300. onAfterShaderCompilationObservable: Observable<Engine>;
  90301. /** @hidden */
  90302. _gl: WebGLRenderingContext;
  90303. private _renderingCanvas;
  90304. private _windowIsBackground;
  90305. private _webGLVersion;
  90306. protected _highPrecisionShadersAllowed: boolean;
  90307. /** @hidden */
  90308. readonly _shouldUseHighPrecisionShader: boolean;
  90309. /**
  90310. * Gets a boolean indicating that only power of 2 textures are supported
  90311. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90312. */
  90313. readonly needPOTTextures: boolean;
  90314. /** @hidden */
  90315. _badOS: boolean;
  90316. /** @hidden */
  90317. _badDesktopOS: boolean;
  90318. /**
  90319. * Gets the audio engine
  90320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90321. * @ignorenaming
  90322. */
  90323. static audioEngine: IAudioEngine;
  90324. /**
  90325. * Default AudioEngine factory responsible of creating the Audio Engine.
  90326. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90327. */
  90328. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90329. /**
  90330. * Default offline support factory responsible of creating a tool used to store data locally.
  90331. * By default, this will create a Database object if the workload has been embedded.
  90332. */
  90333. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90334. private _onFocus;
  90335. private _onBlur;
  90336. private _onCanvasPointerOut;
  90337. private _onCanvasBlur;
  90338. private _onCanvasFocus;
  90339. private _onFullscreenChange;
  90340. private _onPointerLockChange;
  90341. private _hardwareScalingLevel;
  90342. /** @hidden */
  90343. _caps: EngineCapabilities;
  90344. private _pointerLockRequested;
  90345. private _isStencilEnable;
  90346. private _colorWrite;
  90347. private _loadingScreen;
  90348. /** @hidden */
  90349. _drawCalls: PerfCounter;
  90350. private _glVersion;
  90351. private _glRenderer;
  90352. private _glVendor;
  90353. private _videoTextureSupported;
  90354. private _renderingQueueLaunched;
  90355. private _activeRenderLoops;
  90356. private _deterministicLockstep;
  90357. private _lockstepMaxSteps;
  90358. /**
  90359. * Observable signaled when a context lost event is raised
  90360. */
  90361. onContextLostObservable: Observable<Engine>;
  90362. /**
  90363. * Observable signaled when a context restored event is raised
  90364. */
  90365. onContextRestoredObservable: Observable<Engine>;
  90366. private _onContextLost;
  90367. private _onContextRestored;
  90368. private _contextWasLost;
  90369. /** @hidden */
  90370. _doNotHandleContextLost: boolean;
  90371. /**
  90372. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90374. */
  90375. doNotHandleContextLost: boolean;
  90376. private _performanceMonitor;
  90377. private _fps;
  90378. private _deltaTime;
  90379. /**
  90380. * Turn this value on if you want to pause FPS computation when in background
  90381. */
  90382. disablePerformanceMonitorInBackground: boolean;
  90383. /**
  90384. * Gets the performance monitor attached to this engine
  90385. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90386. */
  90387. readonly performanceMonitor: PerformanceMonitor;
  90388. /**
  90389. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90390. */
  90391. disableVertexArrayObjects: boolean;
  90392. /** @hidden */
  90393. protected _depthCullingState: _DepthCullingState;
  90394. /** @hidden */
  90395. protected _stencilState: _StencilState;
  90396. /** @hidden */
  90397. protected _alphaState: _AlphaState;
  90398. /** @hidden */
  90399. protected _alphaMode: number;
  90400. /** @hidden */
  90401. _internalTexturesCache: InternalTexture[];
  90402. /** @hidden */
  90403. protected _activeChannel: number;
  90404. private _currentTextureChannel;
  90405. /** @hidden */
  90406. protected _boundTexturesCache: {
  90407. [key: string]: Nullable<InternalTexture>;
  90408. };
  90409. /** @hidden */
  90410. protected _currentEffect: Nullable<Effect>;
  90411. /** @hidden */
  90412. protected _currentProgram: Nullable<WebGLProgram>;
  90413. private _compiledEffects;
  90414. private _vertexAttribArraysEnabled;
  90415. /** @hidden */
  90416. protected _cachedViewport: Nullable<Viewport>;
  90417. private _cachedVertexArrayObject;
  90418. /** @hidden */
  90419. protected _cachedVertexBuffers: any;
  90420. /** @hidden */
  90421. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90422. /** @hidden */
  90423. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90424. /** @hidden */
  90425. _currentRenderTarget: Nullable<InternalTexture>;
  90426. private _uintIndicesCurrentlySet;
  90427. private _currentBoundBuffer;
  90428. /** @hidden */
  90429. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90430. private _currentBufferPointers;
  90431. private _currentInstanceLocations;
  90432. private _currentInstanceBuffers;
  90433. private _textureUnits;
  90434. /** @hidden */
  90435. _workingCanvas: Nullable<HTMLCanvasElement>;
  90436. /** @hidden */
  90437. _workingContext: Nullable<CanvasRenderingContext2D>;
  90438. private _rescalePostProcess;
  90439. private _dummyFramebuffer;
  90440. private _externalData;
  90441. /** @hidden */
  90442. _bindedRenderFunction: any;
  90443. private _vaoRecordInProgress;
  90444. private _mustWipeVertexAttributes;
  90445. private _emptyTexture;
  90446. private _emptyCubeTexture;
  90447. private _emptyTexture3D;
  90448. /** @hidden */
  90449. _frameHandler: number;
  90450. private _nextFreeTextureSlots;
  90451. private _maxSimultaneousTextures;
  90452. private _activeRequests;
  90453. private _texturesSupported;
  90454. /** @hidden */
  90455. _textureFormatInUse: Nullable<string>;
  90456. /**
  90457. * Gets the list of texture formats supported
  90458. */
  90459. readonly texturesSupported: Array<string>;
  90460. /**
  90461. * Gets the list of texture formats in use
  90462. */
  90463. readonly textureFormatInUse: Nullable<string>;
  90464. /**
  90465. * Gets the current viewport
  90466. */
  90467. readonly currentViewport: Nullable<Viewport>;
  90468. /**
  90469. * Gets the default empty texture
  90470. */
  90471. readonly emptyTexture: InternalTexture;
  90472. /**
  90473. * Gets the default empty 3D texture
  90474. */
  90475. readonly emptyTexture3D: InternalTexture;
  90476. /**
  90477. * Gets the default empty cube texture
  90478. */
  90479. readonly emptyCubeTexture: InternalTexture;
  90480. /**
  90481. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90482. */
  90483. readonly premultipliedAlpha: boolean;
  90484. /**
  90485. * Creates a new engine
  90486. * @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
  90487. * @param antialias defines enable antialiasing (default: false)
  90488. * @param options defines further options to be sent to the getContext() function
  90489. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90490. */
  90491. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90492. /**
  90493. * Initializes a webVR display and starts listening to display change events
  90494. * The onVRDisplayChangedObservable will be notified upon these changes
  90495. * @returns The onVRDisplayChangedObservable
  90496. */
  90497. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90498. /** @hidden */
  90499. _prepareVRComponent(): void;
  90500. /** @hidden */
  90501. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90502. /** @hidden */
  90503. _submitVRFrame(): void;
  90504. /**
  90505. * Call this function to leave webVR mode
  90506. * Will do nothing if webVR is not supported or if there is no webVR device
  90507. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90508. */
  90509. disableVR(): void;
  90510. /**
  90511. * Gets a boolean indicating that the system is in VR mode and is presenting
  90512. * @returns true if VR mode is engaged
  90513. */
  90514. isVRPresenting(): boolean;
  90515. /** @hidden */
  90516. _requestVRFrame(): void;
  90517. private _disableTouchAction;
  90518. private _rebuildInternalTextures;
  90519. private _rebuildEffects;
  90520. /**
  90521. * Gets a boolean indicating if all created effects are ready
  90522. * @returns true if all effects are ready
  90523. */
  90524. areAllEffectsReady(): boolean;
  90525. private _rebuildBuffers;
  90526. private _initGLContext;
  90527. /**
  90528. * Gets version of the current webGL context
  90529. */
  90530. readonly webGLVersion: number;
  90531. /**
  90532. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90533. */
  90534. readonly isStencilEnable: boolean;
  90535. /** @hidden */
  90536. _prepareWorkingCanvas(): void;
  90537. /**
  90538. * Reset the texture cache to empty state
  90539. */
  90540. resetTextureCache(): void;
  90541. /**
  90542. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90543. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90544. * @returns true if engine is in deterministic lock step mode
  90545. */
  90546. isDeterministicLockStep(): boolean;
  90547. /**
  90548. * Gets the max steps when engine is running in deterministic lock step
  90549. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90550. * @returns the max steps
  90551. */
  90552. getLockstepMaxSteps(): number;
  90553. /**
  90554. * Gets an object containing information about the current webGL context
  90555. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90556. */
  90557. getGlInfo(): {
  90558. vendor: string;
  90559. renderer: string;
  90560. version: string;
  90561. };
  90562. /**
  90563. * Gets current aspect ratio
  90564. * @param camera defines the camera to use to get the aspect ratio
  90565. * @param useScreen defines if screen size must be used (or the current render target if any)
  90566. * @returns a number defining the aspect ratio
  90567. */
  90568. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90569. /**
  90570. * Gets current screen aspect ratio
  90571. * @returns a number defining the aspect ratio
  90572. */
  90573. getScreenAspectRatio(): number;
  90574. /**
  90575. * Gets the current render width
  90576. * @param useScreen defines if screen size must be used (or the current render target if any)
  90577. * @returns a number defining the current render width
  90578. */
  90579. getRenderWidth(useScreen?: boolean): number;
  90580. /**
  90581. * Gets the current render height
  90582. * @param useScreen defines if screen size must be used (or the current render target if any)
  90583. * @returns a number defining the current render height
  90584. */
  90585. getRenderHeight(useScreen?: boolean): number;
  90586. /**
  90587. * Gets the HTML canvas attached with the current webGL context
  90588. * @returns a HTML canvas
  90589. */
  90590. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90591. /**
  90592. * Gets the client rect of the HTML canvas attached with the current webGL context
  90593. * @returns a client rectanglee
  90594. */
  90595. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90596. /**
  90597. * Defines the hardware scaling level.
  90598. * By default the hardware scaling level is computed from the window device ratio.
  90599. * 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.
  90600. * @param level defines the level to use
  90601. */
  90602. setHardwareScalingLevel(level: number): void;
  90603. /**
  90604. * Gets the current hardware scaling level.
  90605. * By default the hardware scaling level is computed from the window device ratio.
  90606. * 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.
  90607. * @returns a number indicating the current hardware scaling level
  90608. */
  90609. getHardwareScalingLevel(): number;
  90610. /**
  90611. * Gets the list of loaded textures
  90612. * @returns an array containing all loaded textures
  90613. */
  90614. getLoadedTexturesCache(): InternalTexture[];
  90615. /**
  90616. * Gets the object containing all engine capabilities
  90617. * @returns the EngineCapabilities object
  90618. */
  90619. getCaps(): EngineCapabilities;
  90620. /**
  90621. * Gets the current depth function
  90622. * @returns a number defining the depth function
  90623. */
  90624. getDepthFunction(): Nullable<number>;
  90625. /**
  90626. * Sets the current depth function
  90627. * @param depthFunc defines the function to use
  90628. */
  90629. setDepthFunction(depthFunc: number): void;
  90630. /**
  90631. * Sets the current depth function to GREATER
  90632. */
  90633. setDepthFunctionToGreater(): void;
  90634. /**
  90635. * Sets the current depth function to GEQUAL
  90636. */
  90637. setDepthFunctionToGreaterOrEqual(): void;
  90638. /**
  90639. * Sets the current depth function to LESS
  90640. */
  90641. setDepthFunctionToLess(): void;
  90642. private _cachedStencilBuffer;
  90643. private _cachedStencilFunction;
  90644. private _cachedStencilMask;
  90645. private _cachedStencilOperationPass;
  90646. private _cachedStencilOperationFail;
  90647. private _cachedStencilOperationDepthFail;
  90648. private _cachedStencilReference;
  90649. /**
  90650. * Caches the the state of the stencil buffer
  90651. */
  90652. cacheStencilState(): void;
  90653. /**
  90654. * Restores the state of the stencil buffer
  90655. */
  90656. restoreStencilState(): void;
  90657. /**
  90658. * Sets the current depth function to LEQUAL
  90659. */
  90660. setDepthFunctionToLessOrEqual(): void;
  90661. /**
  90662. * Gets a boolean indicating if stencil buffer is enabled
  90663. * @returns the current stencil buffer state
  90664. */
  90665. getStencilBuffer(): boolean;
  90666. /**
  90667. * Enable or disable the stencil buffer
  90668. * @param enable defines if the stencil buffer must be enabled or disabled
  90669. */
  90670. setStencilBuffer(enable: boolean): void;
  90671. /**
  90672. * Gets the current stencil mask
  90673. * @returns a number defining the new stencil mask to use
  90674. */
  90675. getStencilMask(): number;
  90676. /**
  90677. * Sets the current stencil mask
  90678. * @param mask defines the new stencil mask to use
  90679. */
  90680. setStencilMask(mask: number): void;
  90681. /**
  90682. * Gets the current stencil function
  90683. * @returns a number defining the stencil function to use
  90684. */
  90685. getStencilFunction(): number;
  90686. /**
  90687. * Gets the current stencil reference value
  90688. * @returns a number defining the stencil reference value to use
  90689. */
  90690. getStencilFunctionReference(): number;
  90691. /**
  90692. * Gets the current stencil mask
  90693. * @returns a number defining the stencil mask to use
  90694. */
  90695. getStencilFunctionMask(): number;
  90696. /**
  90697. * Sets the current stencil function
  90698. * @param stencilFunc defines the new stencil function to use
  90699. */
  90700. setStencilFunction(stencilFunc: number): void;
  90701. /**
  90702. * Sets the current stencil reference
  90703. * @param reference defines the new stencil reference to use
  90704. */
  90705. setStencilFunctionReference(reference: number): void;
  90706. /**
  90707. * Sets the current stencil mask
  90708. * @param mask defines the new stencil mask to use
  90709. */
  90710. setStencilFunctionMask(mask: number): void;
  90711. /**
  90712. * Gets the current stencil operation when stencil fails
  90713. * @returns a number defining stencil operation to use when stencil fails
  90714. */
  90715. getStencilOperationFail(): number;
  90716. /**
  90717. * Gets the current stencil operation when depth fails
  90718. * @returns a number defining stencil operation to use when depth fails
  90719. */
  90720. getStencilOperationDepthFail(): number;
  90721. /**
  90722. * Gets the current stencil operation when stencil passes
  90723. * @returns a number defining stencil operation to use when stencil passes
  90724. */
  90725. getStencilOperationPass(): number;
  90726. /**
  90727. * Sets the stencil operation to use when stencil fails
  90728. * @param operation defines the stencil operation to use when stencil fails
  90729. */
  90730. setStencilOperationFail(operation: number): void;
  90731. /**
  90732. * Sets the stencil operation to use when depth fails
  90733. * @param operation defines the stencil operation to use when depth fails
  90734. */
  90735. setStencilOperationDepthFail(operation: number): void;
  90736. /**
  90737. * Sets the stencil operation to use when stencil passes
  90738. * @param operation defines the stencil operation to use when stencil passes
  90739. */
  90740. setStencilOperationPass(operation: number): void;
  90741. /**
  90742. * Sets a boolean indicating if the dithering state is enabled or disabled
  90743. * @param value defines the dithering state
  90744. */
  90745. setDitheringState(value: boolean): void;
  90746. /**
  90747. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90748. * @param value defines the rasterizer state
  90749. */
  90750. setRasterizerState(value: boolean): void;
  90751. /**
  90752. * stop executing a render loop function and remove it from the execution array
  90753. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90754. */
  90755. stopRenderLoop(renderFunction?: () => void): void;
  90756. /** @hidden */
  90757. _renderLoop(): void;
  90758. /**
  90759. * Register and execute a render loop. The engine can have more than one render function
  90760. * @param renderFunction defines the function to continuously execute
  90761. */
  90762. runRenderLoop(renderFunction: () => void): void;
  90763. /**
  90764. * Toggle full screen mode
  90765. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90766. */
  90767. switchFullscreen(requestPointerLock: boolean): void;
  90768. /**
  90769. * Enters full screen mode
  90770. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90771. */
  90772. enterFullscreen(requestPointerLock: boolean): void;
  90773. /**
  90774. * Exits full screen mode
  90775. */
  90776. exitFullscreen(): void;
  90777. /**
  90778. * Enters Pointerlock mode
  90779. */
  90780. enterPointerlock(): void;
  90781. /**
  90782. * Exits Pointerlock mode
  90783. */
  90784. exitPointerlock(): void;
  90785. /**
  90786. * Clear the current render buffer or the current render target (if any is set up)
  90787. * @param color defines the color to use
  90788. * @param backBuffer defines if the back buffer must be cleared
  90789. * @param depth defines if the depth buffer must be cleared
  90790. * @param stencil defines if the stencil buffer must be cleared
  90791. */
  90792. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90793. /**
  90794. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90795. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90796. * @param y defines the y-coordinate of the corner of the clear rectangle
  90797. * @param width defines the width of the clear rectangle
  90798. * @param height defines the height of the clear rectangle
  90799. * @param clearColor defines the clear color
  90800. */
  90801. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90802. /**
  90803. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90804. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90805. * @param y defines the y-coordinate of the corner of the clear rectangle
  90806. * @param width defines the width of the clear rectangle
  90807. * @param height defines the height of the clear rectangle
  90808. */
  90809. enableScissor(x: number, y: number, width: number, height: number): void;
  90810. /**
  90811. * Disable previously set scissor test rectangle
  90812. */
  90813. disableScissor(): void;
  90814. private _viewportCached;
  90815. /** @hidden */
  90816. _viewport(x: number, y: number, width: number, height: number): void;
  90817. /**
  90818. * Set the WebGL's viewport
  90819. * @param viewport defines the viewport element to be used
  90820. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90821. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90822. */
  90823. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90824. /**
  90825. * Directly set the WebGL Viewport
  90826. * @param x defines the x coordinate of the viewport (in screen space)
  90827. * @param y defines the y coordinate of the viewport (in screen space)
  90828. * @param width defines the width of the viewport (in screen space)
  90829. * @param height defines the height of the viewport (in screen space)
  90830. * @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
  90831. */
  90832. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90833. /**
  90834. * Begin a new frame
  90835. */
  90836. beginFrame(): void;
  90837. /**
  90838. * Enf the current frame
  90839. */
  90840. endFrame(): void;
  90841. /**
  90842. * Resize the view according to the canvas' size
  90843. */
  90844. resize(): void;
  90845. /**
  90846. * Force a specific size of the canvas
  90847. * @param width defines the new canvas' width
  90848. * @param height defines the new canvas' height
  90849. */
  90850. setSize(width: number, height: number): void;
  90851. /**
  90852. * Binds the frame buffer to the specified texture.
  90853. * @param texture The texture to render to or null for the default canvas
  90854. * @param faceIndex The face of the texture to render to in case of cube texture
  90855. * @param requiredWidth The width of the target to render to
  90856. * @param requiredHeight The height of the target to render to
  90857. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  90858. * @param depthStencilTexture The depth stencil texture to use to render
  90859. * @param lodLevel defines le lod level to bind to the frame buffer
  90860. */
  90861. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  90862. /** @hidden */
  90863. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  90864. /**
  90865. * Unbind the current render target texture from the webGL context
  90866. * @param texture defines the render target texture to unbind
  90867. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  90868. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  90869. */
  90870. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  90871. /**
  90872. * Force the mipmap generation for the given render target texture
  90873. * @param texture defines the render target texture to use
  90874. */
  90875. generateMipMapsForCubemap(texture: InternalTexture): void;
  90876. /**
  90877. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  90878. */
  90879. flushFramebuffer(): void;
  90880. /**
  90881. * Unbind the current render target and bind the default framebuffer
  90882. */
  90883. restoreDefaultFramebuffer(): void;
  90884. /**
  90885. * Create an uniform buffer
  90886. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90887. * @param elements defines the content of the uniform buffer
  90888. * @returns the webGL uniform buffer
  90889. */
  90890. createUniformBuffer(elements: FloatArray): DataBuffer;
  90891. /**
  90892. * Create a dynamic uniform buffer
  90893. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90894. * @param elements defines the content of the uniform buffer
  90895. * @returns the webGL uniform buffer
  90896. */
  90897. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  90898. /**
  90899. * Update an existing uniform buffer
  90900. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90901. * @param uniformBuffer defines the target uniform buffer
  90902. * @param elements defines the content to update
  90903. * @param offset defines the offset in the uniform buffer where update should start
  90904. * @param count defines the size of the data to update
  90905. */
  90906. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  90907. private _resetVertexBufferBinding;
  90908. /**
  90909. * Creates a vertex buffer
  90910. * @param data the data for the vertex buffer
  90911. * @returns the new WebGL static buffer
  90912. */
  90913. createVertexBuffer(data: DataArray): DataBuffer;
  90914. /**
  90915. * Creates a dynamic vertex buffer
  90916. * @param data the data for the dynamic vertex buffer
  90917. * @returns the new WebGL dynamic buffer
  90918. */
  90919. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  90920. /**
  90921. * Update a dynamic index buffer
  90922. * @param indexBuffer defines the target index buffer
  90923. * @param indices defines the data to update
  90924. * @param offset defines the offset in the target index buffer where update should start
  90925. */
  90926. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  90927. /**
  90928. * Updates a dynamic vertex buffer.
  90929. * @param vertexBuffer the vertex buffer to update
  90930. * @param data the data used to update the vertex buffer
  90931. * @param byteOffset the byte offset of the data
  90932. * @param byteLength the byte length of the data
  90933. */
  90934. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  90935. private _resetIndexBufferBinding;
  90936. /**
  90937. * Creates a new index buffer
  90938. * @param indices defines the content of the index buffer
  90939. * @param updatable defines if the index buffer must be updatable
  90940. * @returns a new webGL buffer
  90941. */
  90942. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  90943. /**
  90944. * Bind a webGL buffer to the webGL context
  90945. * @param buffer defines the buffer to bind
  90946. */
  90947. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  90948. /**
  90949. * Bind an uniform buffer to the current webGL context
  90950. * @param buffer defines the buffer to bind
  90951. */
  90952. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  90953. /**
  90954. * Bind a buffer to the current webGL context at a given location
  90955. * @param buffer defines the buffer to bind
  90956. * @param location defines the index where to bind the buffer
  90957. */
  90958. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  90959. /**
  90960. * Bind a specific block at a given index in a specific shader program
  90961. * @param pipelineContext defines the pipeline context to use
  90962. * @param blockName defines the block name
  90963. * @param index defines the index where to bind the block
  90964. */
  90965. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  90966. private bindIndexBuffer;
  90967. private bindBuffer;
  90968. /**
  90969. * update the bound buffer with the given data
  90970. * @param data defines the data to update
  90971. */
  90972. updateArrayBuffer(data: Float32Array): void;
  90973. private _vertexAttribPointer;
  90974. private _bindIndexBufferWithCache;
  90975. private _bindVertexBuffersAttributes;
  90976. /**
  90977. * Records a vertex array object
  90978. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90979. * @param vertexBuffers defines the list of vertex buffers to store
  90980. * @param indexBuffer defines the index buffer to store
  90981. * @param effect defines the effect to store
  90982. * @returns the new vertex array object
  90983. */
  90984. recordVertexArrayObject(vertexBuffers: {
  90985. [key: string]: VertexBuffer;
  90986. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  90987. /**
  90988. * Bind a specific vertex array object
  90989. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90990. * @param vertexArrayObject defines the vertex array object to bind
  90991. * @param indexBuffer defines the index buffer to bind
  90992. */
  90993. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  90994. /**
  90995. * Bind webGl buffers directly to the webGL context
  90996. * @param vertexBuffer defines the vertex buffer to bind
  90997. * @param indexBuffer defines the index buffer to bind
  90998. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  90999. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91000. * @param effect defines the effect associated with the vertex buffer
  91001. */
  91002. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91003. private _unbindVertexArrayObject;
  91004. /**
  91005. * Bind a list of vertex buffers to the webGL context
  91006. * @param vertexBuffers defines the list of vertex buffers to bind
  91007. * @param indexBuffer defines the index buffer to bind
  91008. * @param effect defines the effect associated with the vertex buffers
  91009. */
  91010. bindBuffers(vertexBuffers: {
  91011. [key: string]: Nullable<VertexBuffer>;
  91012. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91013. /**
  91014. * Unbind all instance attributes
  91015. */
  91016. unbindInstanceAttributes(): void;
  91017. /**
  91018. * Release and free the memory of a vertex array object
  91019. * @param vao defines the vertex array object to delete
  91020. */
  91021. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91022. /** @hidden */
  91023. _releaseBuffer(buffer: DataBuffer): boolean;
  91024. /**
  91025. * Creates a webGL buffer to use with instanciation
  91026. * @param capacity defines the size of the buffer
  91027. * @returns the webGL buffer
  91028. */
  91029. createInstancesBuffer(capacity: number): DataBuffer;
  91030. /**
  91031. * Delete a webGL buffer used with instanciation
  91032. * @param buffer defines the webGL buffer to delete
  91033. */
  91034. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91035. /**
  91036. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91037. * @param instancesBuffer defines the webGL buffer to update and bind
  91038. * @param data defines the data to store in the buffer
  91039. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91040. */
  91041. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91042. /**
  91043. * Apply all cached states (depth, culling, stencil and alpha)
  91044. */
  91045. applyStates(): void;
  91046. /**
  91047. * Send a draw order
  91048. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91049. * @param indexStart defines the starting index
  91050. * @param indexCount defines the number of index to draw
  91051. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91052. */
  91053. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91054. /**
  91055. * Draw a list of points
  91056. * @param verticesStart defines the index of first vertex to draw
  91057. * @param verticesCount defines the count of vertices to draw
  91058. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91059. */
  91060. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91061. /**
  91062. * Draw a list of unindexed primitives
  91063. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91064. * @param verticesStart defines the index of first vertex to draw
  91065. * @param verticesCount defines the count of vertices to draw
  91066. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91067. */
  91068. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91069. /**
  91070. * Draw a list of indexed primitives
  91071. * @param fillMode defines the primitive to use
  91072. * @param indexStart defines the starting index
  91073. * @param indexCount defines the number of index to draw
  91074. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91075. */
  91076. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91077. /**
  91078. * Draw a list of unindexed primitives
  91079. * @param fillMode defines the primitive to use
  91080. * @param verticesStart defines the index of first vertex to draw
  91081. * @param verticesCount defines the count of vertices to draw
  91082. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91083. */
  91084. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91085. private _drawMode;
  91086. /** @hidden */
  91087. _releaseEffect(effect: Effect): void;
  91088. /** @hidden */
  91089. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91090. /**
  91091. * Create a new effect (used to store vertex/fragment shaders)
  91092. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91093. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91094. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91095. * @param samplers defines an array of string used to represent textures
  91096. * @param defines defines the string containing the defines to use to compile the shaders
  91097. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91098. * @param onCompiled defines a function to call when the effect creation is successful
  91099. * @param onError defines a function to call when the effect creation has failed
  91100. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91101. * @returns the new Effect
  91102. */
  91103. 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;
  91104. private _compileShader;
  91105. private _compileRawShader;
  91106. /**
  91107. * Directly creates a webGL program
  91108. * @param pipelineContext defines the pipeline context to attach to
  91109. * @param vertexCode defines the vertex shader code to use
  91110. * @param fragmentCode defines the fragment shader code to use
  91111. * @param context defines the webGL context to use (if not set, the current one will be used)
  91112. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91113. * @returns the new webGL program
  91114. */
  91115. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91116. /**
  91117. * Creates a webGL program
  91118. * @param pipelineContext defines the pipeline context to attach to
  91119. * @param vertexCode defines the vertex shader code to use
  91120. * @param fragmentCode defines the fragment shader code to use
  91121. * @param defines defines the string containing the defines to use to compile the shaders
  91122. * @param context defines the webGL context to use (if not set, the current one will be used)
  91123. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91124. * @returns the new webGL program
  91125. */
  91126. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91127. /**
  91128. * Creates a new pipeline context
  91129. * @returns the new pipeline
  91130. */
  91131. createPipelineContext(): WebGLPipelineContext;
  91132. private _createShaderProgram;
  91133. private _finalizePipelineContext;
  91134. /** @hidden */
  91135. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91136. /** @hidden */
  91137. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91138. /** @hidden */
  91139. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91140. /**
  91141. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91142. * @param pipelineContext defines the pipeline context to use
  91143. * @param uniformsNames defines the list of uniform names
  91144. * @returns an array of webGL uniform locations
  91145. */
  91146. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91147. /**
  91148. * Gets the lsit of active attributes for a given webGL program
  91149. * @param pipelineContext defines the pipeline context to use
  91150. * @param attributesNames defines the list of attribute names to get
  91151. * @returns an array of indices indicating the offset of each attribute
  91152. */
  91153. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91154. /**
  91155. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91156. * @param effect defines the effect to activate
  91157. */
  91158. enableEffect(effect: Nullable<Effect>): void;
  91159. /**
  91160. * Set the value of an uniform to an array of int32
  91161. * @param uniform defines the webGL uniform location where to store the value
  91162. * @param array defines the array of int32 to store
  91163. */
  91164. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91165. /**
  91166. * Set the value of an uniform to an array of int32 (stored as vec2)
  91167. * @param uniform defines the webGL uniform location where to store the value
  91168. * @param array defines the array of int32 to store
  91169. */
  91170. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91171. /**
  91172. * Set the value of an uniform to an array of int32 (stored as vec3)
  91173. * @param uniform defines the webGL uniform location where to store the value
  91174. * @param array defines the array of int32 to store
  91175. */
  91176. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91177. /**
  91178. * Set the value of an uniform to an array of int32 (stored as vec4)
  91179. * @param uniform defines the webGL uniform location where to store the value
  91180. * @param array defines the array of int32 to store
  91181. */
  91182. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91183. /**
  91184. * Set the value of an uniform to an array of float32
  91185. * @param uniform defines the webGL uniform location where to store the value
  91186. * @param array defines the array of float32 to store
  91187. */
  91188. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91189. /**
  91190. * Set the value of an uniform to an array of float32 (stored as vec2)
  91191. * @param uniform defines the webGL uniform location where to store the value
  91192. * @param array defines the array of float32 to store
  91193. */
  91194. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91195. /**
  91196. * Set the value of an uniform to an array of float32 (stored as vec3)
  91197. * @param uniform defines the webGL uniform location where to store the value
  91198. * @param array defines the array of float32 to store
  91199. */
  91200. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91201. /**
  91202. * Set the value of an uniform to an array of float32 (stored as vec4)
  91203. * @param uniform defines the webGL uniform location where to store the value
  91204. * @param array defines the array of float32 to store
  91205. */
  91206. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91207. /**
  91208. * Set the value of an uniform to an array of number
  91209. * @param uniform defines the webGL uniform location where to store the value
  91210. * @param array defines the array of number to store
  91211. */
  91212. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91213. /**
  91214. * Set the value of an uniform to an array of number (stored as vec2)
  91215. * @param uniform defines the webGL uniform location where to store the value
  91216. * @param array defines the array of number to store
  91217. */
  91218. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91219. /**
  91220. * Set the value of an uniform to an array of number (stored as vec3)
  91221. * @param uniform defines the webGL uniform location where to store the value
  91222. * @param array defines the array of number to store
  91223. */
  91224. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91225. /**
  91226. * Set the value of an uniform to an array of number (stored as vec4)
  91227. * @param uniform defines the webGL uniform location where to store the value
  91228. * @param array defines the array of number to store
  91229. */
  91230. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91231. /**
  91232. * Set the value of an uniform to an array of float32 (stored as matrices)
  91233. * @param uniform defines the webGL uniform location where to store the value
  91234. * @param matrices defines the array of float32 to store
  91235. */
  91236. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91237. /**
  91238. * Set the value of an uniform to a matrix
  91239. * @param uniform defines the webGL uniform location where to store the value
  91240. * @param matrix defines the matrix to store
  91241. */
  91242. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91243. /**
  91244. * Set the value of an uniform to a matrix (3x3)
  91245. * @param uniform defines the webGL uniform location where to store the value
  91246. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91247. */
  91248. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91249. /**
  91250. * Set the value of an uniform to a matrix (2x2)
  91251. * @param uniform defines the webGL uniform location where to store the value
  91252. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91253. */
  91254. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91255. /**
  91256. * Set the value of an uniform to a number (int)
  91257. * @param uniform defines the webGL uniform location where to store the value
  91258. * @param value defines the int number to store
  91259. */
  91260. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91261. /**
  91262. * Set the value of an uniform to a number (float)
  91263. * @param uniform defines the webGL uniform location where to store the value
  91264. * @param value defines the float number to store
  91265. */
  91266. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91267. /**
  91268. * Set the value of an uniform to a vec2
  91269. * @param uniform defines the webGL uniform location where to store the value
  91270. * @param x defines the 1st component of the value
  91271. * @param y defines the 2nd component of the value
  91272. */
  91273. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91274. /**
  91275. * Set the value of an uniform to a vec3
  91276. * @param uniform defines the webGL uniform location where to store the value
  91277. * @param x defines the 1st component of the value
  91278. * @param y defines the 2nd component of the value
  91279. * @param z defines the 3rd component of the value
  91280. */
  91281. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91282. /**
  91283. * Set the value of an uniform to a boolean
  91284. * @param uniform defines the webGL uniform location where to store the value
  91285. * @param bool defines the boolean to store
  91286. */
  91287. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91288. /**
  91289. * Set the value of an uniform to a vec4
  91290. * @param uniform defines the webGL uniform location where to store the value
  91291. * @param x defines the 1st component of the value
  91292. * @param y defines the 2nd component of the value
  91293. * @param z defines the 3rd component of the value
  91294. * @param w defines the 4th component of the value
  91295. */
  91296. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91297. /**
  91298. * Set the value of an uniform to a Color3
  91299. * @param uniform defines the webGL uniform location where to store the value
  91300. * @param color3 defines the color to store
  91301. */
  91302. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91303. /**
  91304. * Set the value of an uniform to a Color3 and an alpha value
  91305. * @param uniform defines the webGL uniform location where to store the value
  91306. * @param color3 defines the color to store
  91307. * @param alpha defines the alpha component to store
  91308. */
  91309. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91310. /**
  91311. * Sets a Color4 on a uniform variable
  91312. * @param uniform defines the uniform location
  91313. * @param color4 defines the value to be set
  91314. */
  91315. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91316. /**
  91317. * Set various states to the webGL context
  91318. * @param culling defines backface culling state
  91319. * @param zOffset defines the value to apply to zOffset (0 by default)
  91320. * @param force defines if states must be applied even if cache is up to date
  91321. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91322. */
  91323. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91324. /**
  91325. * Set the z offset to apply to current rendering
  91326. * @param value defines the offset to apply
  91327. */
  91328. setZOffset(value: number): void;
  91329. /**
  91330. * Gets the current value of the zOffset
  91331. * @returns the current zOffset state
  91332. */
  91333. getZOffset(): number;
  91334. /**
  91335. * Enable or disable depth buffering
  91336. * @param enable defines the state to set
  91337. */
  91338. setDepthBuffer(enable: boolean): void;
  91339. /**
  91340. * Gets a boolean indicating if depth writing is enabled
  91341. * @returns the current depth writing state
  91342. */
  91343. getDepthWrite(): boolean;
  91344. /**
  91345. * Enable or disable depth writing
  91346. * @param enable defines the state to set
  91347. */
  91348. setDepthWrite(enable: boolean): void;
  91349. /**
  91350. * Enable or disable color writing
  91351. * @param enable defines the state to set
  91352. */
  91353. setColorWrite(enable: boolean): void;
  91354. /**
  91355. * Gets a boolean indicating if color writing is enabled
  91356. * @returns the current color writing state
  91357. */
  91358. getColorWrite(): boolean;
  91359. /**
  91360. * Sets alpha constants used by some alpha blending modes
  91361. * @param r defines the red component
  91362. * @param g defines the green component
  91363. * @param b defines the blue component
  91364. * @param a defines the alpha component
  91365. */
  91366. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91367. /**
  91368. * Sets the current alpha mode
  91369. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91370. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91371. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91372. */
  91373. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91374. /**
  91375. * Gets the current alpha mode
  91376. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91377. * @returns the current alpha mode
  91378. */
  91379. getAlphaMode(): number;
  91380. /**
  91381. * Clears the list of texture accessible through engine.
  91382. * This can help preventing texture load conflict due to name collision.
  91383. */
  91384. clearInternalTexturesCache(): void;
  91385. /**
  91386. * Force the entire cache to be cleared
  91387. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91388. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91389. */
  91390. wipeCaches(bruteForce?: boolean): void;
  91391. /**
  91392. * Set the compressed texture format to use, based on the formats you have, and the formats
  91393. * supported by the hardware / browser.
  91394. *
  91395. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91396. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91397. * to API arguments needed to compressed textures. This puts the burden on the container
  91398. * generator to house the arcane code for determining these for current & future formats.
  91399. *
  91400. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91401. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91402. *
  91403. * Note: The result of this call is not taken into account when a texture is base64.
  91404. *
  91405. * @param formatsAvailable defines the list of those format families you have created
  91406. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91407. *
  91408. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91409. * @returns The extension selected.
  91410. */
  91411. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91412. /** @hidden */
  91413. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91414. min: number;
  91415. mag: number;
  91416. };
  91417. /** @hidden */
  91418. _createTexture(): WebGLTexture;
  91419. /**
  91420. * Usually called from Texture.ts.
  91421. * Passed information to create a WebGLTexture
  91422. * @param urlArg defines a value which contains one of the following:
  91423. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91424. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91425. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91426. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91427. * @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)
  91428. * @param scene needed for loading to the correct scene
  91429. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91430. * @param onLoad optional callback to be called upon successful completion
  91431. * @param onError optional callback to be called upon failure
  91432. * @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
  91433. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91434. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91435. * @param forcedExtension defines the extension to use to pick the right loader
  91436. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91437. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91438. */
  91439. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  91440. /**
  91441. * @hidden
  91442. * Rescales a texture
  91443. * @param source input texutre
  91444. * @param destination destination texture
  91445. * @param scene scene to use to render the resize
  91446. * @param internalFormat format to use when resizing
  91447. * @param onComplete callback to be called when resize has completed
  91448. */
  91449. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91450. private _unpackFlipYCached;
  91451. /**
  91452. * In case you are sharing the context with other applications, it might
  91453. * be interested to not cache the unpack flip y state to ensure a consistent
  91454. * value would be set.
  91455. */
  91456. enableUnpackFlipYCached: boolean;
  91457. /** @hidden */
  91458. _unpackFlipY(value: boolean): void;
  91459. /** @hidden */
  91460. _getUnpackAlignement(): number;
  91461. /**
  91462. * Creates a dynamic texture
  91463. * @param width defines the width of the texture
  91464. * @param height defines the height of the texture
  91465. * @param generateMipMaps defines if the engine should generate the mip levels
  91466. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91467. * @returns the dynamic texture inside an InternalTexture
  91468. */
  91469. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91470. /**
  91471. * Update the sampling mode of a given texture
  91472. * @param samplingMode defines the required sampling mode
  91473. * @param texture defines the texture to update
  91474. */
  91475. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91476. /**
  91477. * Update the content of a dynamic texture
  91478. * @param texture defines the texture to update
  91479. * @param canvas defines the canvas containing the source
  91480. * @param invertY defines if data must be stored with Y axis inverted
  91481. * @param premulAlpha defines if alpha is stored as premultiplied
  91482. * @param format defines the format of the data
  91483. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91484. */
  91485. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91486. /**
  91487. * Update a video texture
  91488. * @param texture defines the texture to update
  91489. * @param video defines the video element to use
  91490. * @param invertY defines if data must be stored with Y axis inverted
  91491. */
  91492. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91493. /**
  91494. * Updates a depth texture Comparison Mode and Function.
  91495. * If the comparison Function is equal to 0, the mode will be set to none.
  91496. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91497. * @param texture The texture to set the comparison function for
  91498. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91499. */
  91500. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91501. /** @hidden */
  91502. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91503. width: number;
  91504. height: number;
  91505. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91506. /**
  91507. * Creates a depth stencil texture.
  91508. * This is only available in WebGL 2 or with the depth texture extension available.
  91509. * @param size The size of face edge in the texture.
  91510. * @param options The options defining the texture.
  91511. * @returns The texture
  91512. */
  91513. createDepthStencilTexture(size: number | {
  91514. width: number;
  91515. height: number;
  91516. }, options: DepthTextureCreationOptions): InternalTexture;
  91517. /**
  91518. * Creates a depth stencil texture.
  91519. * This is only available in WebGL 2 or with the depth texture extension available.
  91520. * @param size The size of face edge in the texture.
  91521. * @param options The options defining the texture.
  91522. * @returns The texture
  91523. */
  91524. private _createDepthStencilTexture;
  91525. /**
  91526. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91527. * @param renderTarget The render target to set the frame buffer for
  91528. */
  91529. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91530. /**
  91531. * Creates a new render target texture
  91532. * @param size defines the size of the texture
  91533. * @param options defines the options used to create the texture
  91534. * @returns a new render target texture stored in an InternalTexture
  91535. */
  91536. createRenderTargetTexture(size: number | {
  91537. width: number;
  91538. height: number;
  91539. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91540. /** @hidden */
  91541. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91542. /**
  91543. * Updates the sample count of a render target texture
  91544. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91545. * @param texture defines the texture to update
  91546. * @param samples defines the sample count to set
  91547. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91548. */
  91549. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91550. /** @hidden */
  91551. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91552. /** @hidden */
  91553. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  91554. /** @hidden */
  91555. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91556. /** @hidden */
  91557. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91558. /**
  91559. * @hidden
  91560. */
  91561. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91562. private _prepareWebGLTextureContinuation;
  91563. private _prepareWebGLTexture;
  91564. /** @hidden */
  91565. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91566. /** @hidden */
  91567. _releaseFramebufferObjects(texture: InternalTexture): void;
  91568. /** @hidden */
  91569. _releaseTexture(texture: InternalTexture): void;
  91570. private setProgram;
  91571. private _boundUniforms;
  91572. /**
  91573. * Binds an effect to the webGL context
  91574. * @param effect defines the effect to bind
  91575. */
  91576. bindSamplers(effect: Effect): void;
  91577. private _activateCurrentTexture;
  91578. /** @hidden */
  91579. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91580. /** @hidden */
  91581. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91582. /**
  91583. * Sets a texture to the webGL context from a postprocess
  91584. * @param channel defines the channel to use
  91585. * @param postProcess defines the source postprocess
  91586. */
  91587. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91588. /**
  91589. * Binds the output of the passed in post process to the texture channel specified
  91590. * @param channel The channel the texture should be bound to
  91591. * @param postProcess The post process which's output should be bound
  91592. */
  91593. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91594. /**
  91595. * Unbind all textures from the webGL context
  91596. */
  91597. unbindAllTextures(): void;
  91598. /**
  91599. * Sets a texture to the according uniform.
  91600. * @param channel The texture channel
  91601. * @param uniform The uniform to set
  91602. * @param texture The texture to apply
  91603. */
  91604. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91605. /**
  91606. * Sets a depth stencil texture from a render target to the according uniform.
  91607. * @param channel The texture channel
  91608. * @param uniform The uniform to set
  91609. * @param texture The render target texture containing the depth stencil texture to apply
  91610. */
  91611. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91612. private _bindSamplerUniformToChannel;
  91613. private _getTextureWrapMode;
  91614. private _setTexture;
  91615. /**
  91616. * Sets an array of texture to the webGL context
  91617. * @param channel defines the channel where the texture array must be set
  91618. * @param uniform defines the associated uniform location
  91619. * @param textures defines the array of textures to bind
  91620. */
  91621. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91622. /** @hidden */
  91623. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91624. private _setTextureParameterFloat;
  91625. private _setTextureParameterInteger;
  91626. /**
  91627. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91628. * @param x defines the x coordinate of the rectangle where pixels must be read
  91629. * @param y defines the y coordinate of the rectangle where pixels must be read
  91630. * @param width defines the width of the rectangle where pixels must be read
  91631. * @param height defines the height of the rectangle where pixels must be read
  91632. * @returns a Uint8Array containing RGBA colors
  91633. */
  91634. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91635. /**
  91636. * Add an externaly attached data from its key.
  91637. * This method call will fail and return false, if such key already exists.
  91638. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91639. * @param key the unique key that identifies the data
  91640. * @param data the data object to associate to the key for this Engine instance
  91641. * @return true if no such key were already present and the data was added successfully, false otherwise
  91642. */
  91643. addExternalData<T>(key: string, data: T): boolean;
  91644. /**
  91645. * Get an externaly attached data from its key
  91646. * @param key the unique key that identifies the data
  91647. * @return the associated data, if present (can be null), or undefined if not present
  91648. */
  91649. getExternalData<T>(key: string): T;
  91650. /**
  91651. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91652. * @param key the unique key that identifies the data
  91653. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91654. * @return the associated data, can be null if the factory returned null.
  91655. */
  91656. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91657. /**
  91658. * Remove an externaly attached data from the Engine instance
  91659. * @param key the unique key that identifies the data
  91660. * @return true if the data was successfully removed, false if it doesn't exist
  91661. */
  91662. removeExternalData(key: string): boolean;
  91663. /**
  91664. * Unbind all vertex attributes from the webGL context
  91665. */
  91666. unbindAllAttributes(): void;
  91667. /**
  91668. * 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
  91669. */
  91670. releaseEffects(): void;
  91671. /**
  91672. * Dispose and release all associated resources
  91673. */
  91674. dispose(): void;
  91675. /**
  91676. * Display the loading screen
  91677. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91678. */
  91679. displayLoadingUI(): void;
  91680. /**
  91681. * Hide the loading screen
  91682. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91683. */
  91684. hideLoadingUI(): void;
  91685. /**
  91686. * Gets the current loading screen object
  91687. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91688. */
  91689. /**
  91690. * Sets the current loading screen object
  91691. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91692. */
  91693. loadingScreen: ILoadingScreen;
  91694. /**
  91695. * Sets the current loading screen text
  91696. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91697. */
  91698. loadingUIText: string;
  91699. /**
  91700. * Sets the current loading screen background color
  91701. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91702. */
  91703. loadingUIBackgroundColor: string;
  91704. /**
  91705. * Attach a new callback raised when context lost event is fired
  91706. * @param callback defines the callback to call
  91707. */
  91708. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91709. /**
  91710. * Attach a new callback raised when context restored event is fired
  91711. * @param callback defines the callback to call
  91712. */
  91713. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91714. /**
  91715. * Gets the source code of the vertex shader associated with a specific webGL program
  91716. * @param program defines the program to use
  91717. * @returns a string containing the source code of the vertex shader associated with the program
  91718. */
  91719. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91720. /**
  91721. * Gets the source code of the fragment shader associated with a specific webGL program
  91722. * @param program defines the program to use
  91723. * @returns a string containing the source code of the fragment shader associated with the program
  91724. */
  91725. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91726. /**
  91727. * Get the current error code of the webGL context
  91728. * @returns the error code
  91729. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91730. */
  91731. getError(): number;
  91732. /**
  91733. * Gets the current framerate
  91734. * @returns a number representing the framerate
  91735. */
  91736. getFps(): number;
  91737. /**
  91738. * Gets the time spent between current and previous frame
  91739. * @returns a number representing the delta time in ms
  91740. */
  91741. getDeltaTime(): number;
  91742. private _measureFps;
  91743. /** @hidden */
  91744. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91745. private _canRenderToFloatFramebuffer;
  91746. private _canRenderToHalfFloatFramebuffer;
  91747. private _canRenderToFramebuffer;
  91748. /** @hidden */
  91749. _getWebGLTextureType(type: number): number;
  91750. /** @hidden */
  91751. _getInternalFormat(format: number): number;
  91752. /** @hidden */
  91753. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91754. /** @hidden */
  91755. _getRGBAMultiSampleBufferFormat(type: number): number;
  91756. /** @hidden */
  91757. _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;
  91758. /** @hidden */
  91759. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91760. /**
  91761. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91762. * @returns true if the engine can be created
  91763. * @ignorenaming
  91764. */
  91765. static isSupported(): boolean;
  91766. }
  91767. }
  91768. declare module BABYLON {
  91769. /**
  91770. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91771. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91772. */
  91773. export class EffectFallbacks {
  91774. private _defines;
  91775. private _currentRank;
  91776. private _maxRank;
  91777. private _mesh;
  91778. /**
  91779. * Removes the fallback from the bound mesh.
  91780. */
  91781. unBindMesh(): void;
  91782. /**
  91783. * Adds a fallback on the specified property.
  91784. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91785. * @param define The name of the define in the shader
  91786. */
  91787. addFallback(rank: number, define: string): void;
  91788. /**
  91789. * Sets the mesh to use CPU skinning when needing to fallback.
  91790. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91791. * @param mesh The mesh to use the fallbacks.
  91792. */
  91793. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91794. /**
  91795. * Checks to see if more fallbacks are still availible.
  91796. */
  91797. readonly isMoreFallbacks: boolean;
  91798. /**
  91799. * Removes the defines that should be removed when falling back.
  91800. * @param currentDefines defines the current define statements for the shader.
  91801. * @param effect defines the current effect we try to compile
  91802. * @returns The resulting defines with defines of the current rank removed.
  91803. */
  91804. reduce(currentDefines: string, effect: Effect): string;
  91805. }
  91806. /**
  91807. * Options to be used when creating an effect.
  91808. */
  91809. export class EffectCreationOptions {
  91810. /**
  91811. * Atrributes that will be used in the shader.
  91812. */
  91813. attributes: string[];
  91814. /**
  91815. * Uniform varible names that will be set in the shader.
  91816. */
  91817. uniformsNames: string[];
  91818. /**
  91819. * Uniform buffer varible names that will be set in the shader.
  91820. */
  91821. uniformBuffersNames: string[];
  91822. /**
  91823. * Sampler texture variable names that will be set in the shader.
  91824. */
  91825. samplers: string[];
  91826. /**
  91827. * Define statements that will be set in the shader.
  91828. */
  91829. defines: any;
  91830. /**
  91831. * Possible fallbacks for this effect to improve performance when needed.
  91832. */
  91833. fallbacks: Nullable<EffectFallbacks>;
  91834. /**
  91835. * Callback that will be called when the shader is compiled.
  91836. */
  91837. onCompiled: Nullable<(effect: Effect) => void>;
  91838. /**
  91839. * Callback that will be called if an error occurs during shader compilation.
  91840. */
  91841. onError: Nullable<(effect: Effect, errors: string) => void>;
  91842. /**
  91843. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91844. */
  91845. indexParameters: any;
  91846. /**
  91847. * Max number of lights that can be used in the shader.
  91848. */
  91849. maxSimultaneousLights: number;
  91850. /**
  91851. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91852. */
  91853. transformFeedbackVaryings: Nullable<string[]>;
  91854. }
  91855. /**
  91856. * Effect containing vertex and fragment shader that can be executed on an object.
  91857. */
  91858. export class Effect implements IDisposable {
  91859. /**
  91860. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91861. */
  91862. static ShadersRepository: string;
  91863. /**
  91864. * Name of the effect.
  91865. */
  91866. name: any;
  91867. /**
  91868. * String container all the define statements that should be set on the shader.
  91869. */
  91870. defines: string;
  91871. /**
  91872. * Callback that will be called when the shader is compiled.
  91873. */
  91874. onCompiled: Nullable<(effect: Effect) => void>;
  91875. /**
  91876. * Callback that will be called if an error occurs during shader compilation.
  91877. */
  91878. onError: Nullable<(effect: Effect, errors: string) => void>;
  91879. /**
  91880. * Callback that will be called when effect is bound.
  91881. */
  91882. onBind: Nullable<(effect: Effect) => void>;
  91883. /**
  91884. * Unique ID of the effect.
  91885. */
  91886. uniqueId: number;
  91887. /**
  91888. * Observable that will be called when the shader is compiled.
  91889. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91890. */
  91891. onCompileObservable: Observable<Effect>;
  91892. /**
  91893. * Observable that will be called if an error occurs during shader compilation.
  91894. */
  91895. onErrorObservable: Observable<Effect>;
  91896. /** @hidden */
  91897. _onBindObservable: Nullable<Observable<Effect>>;
  91898. /**
  91899. * Observable that will be called when effect is bound.
  91900. */
  91901. readonly onBindObservable: Observable<Effect>;
  91902. /** @hidden */
  91903. _bonesComputationForcedToCPU: boolean;
  91904. private static _uniqueIdSeed;
  91905. private _engine;
  91906. private _uniformBuffersNames;
  91907. private _uniformsNames;
  91908. private _samplerList;
  91909. private _samplers;
  91910. private _isReady;
  91911. private _compilationError;
  91912. private _attributesNames;
  91913. private _attributes;
  91914. private _uniforms;
  91915. /**
  91916. * Key for the effect.
  91917. * @hidden
  91918. */
  91919. _key: string;
  91920. private _indexParameters;
  91921. private _fallbacks;
  91922. private _vertexSourceCode;
  91923. private _fragmentSourceCode;
  91924. private _vertexSourceCodeOverride;
  91925. private _fragmentSourceCodeOverride;
  91926. private _transformFeedbackVaryings;
  91927. /**
  91928. * Compiled shader to webGL program.
  91929. * @hidden
  91930. */
  91931. _pipelineContext: Nullable<IPipelineContext>;
  91932. private _valueCache;
  91933. private static _baseCache;
  91934. /**
  91935. * Instantiates an effect.
  91936. * An effect can be used to create/manage/execute vertex and fragment shaders.
  91937. * @param baseName Name of the effect.
  91938. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  91939. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  91940. * @param samplers List of sampler variables that will be passed to the shader.
  91941. * @param engine Engine to be used to render the effect
  91942. * @param defines Define statements to be added to the shader.
  91943. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  91944. * @param onCompiled Callback that will be called when the shader is compiled.
  91945. * @param onError Callback that will be called if an error occurs during shader compilation.
  91946. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91947. */
  91948. 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);
  91949. private _useFinalCode;
  91950. /**
  91951. * Unique key for this effect
  91952. */
  91953. readonly key: string;
  91954. /**
  91955. * If the effect has been compiled and prepared.
  91956. * @returns if the effect is compiled and prepared.
  91957. */
  91958. isReady(): boolean;
  91959. /**
  91960. * The engine the effect was initialized with.
  91961. * @returns the engine.
  91962. */
  91963. getEngine(): Engine;
  91964. /**
  91965. * The pipeline context for this effect
  91966. * @returns the associated pipeline context
  91967. */
  91968. getPipelineContext(): Nullable<IPipelineContext>;
  91969. /**
  91970. * The set of names of attribute variables for the shader.
  91971. * @returns An array of attribute names.
  91972. */
  91973. getAttributesNames(): string[];
  91974. /**
  91975. * Returns the attribute at the given index.
  91976. * @param index The index of the attribute.
  91977. * @returns The location of the attribute.
  91978. */
  91979. getAttributeLocation(index: number): number;
  91980. /**
  91981. * Returns the attribute based on the name of the variable.
  91982. * @param name of the attribute to look up.
  91983. * @returns the attribute location.
  91984. */
  91985. getAttributeLocationByName(name: string): number;
  91986. /**
  91987. * The number of attributes.
  91988. * @returns the numnber of attributes.
  91989. */
  91990. getAttributesCount(): number;
  91991. /**
  91992. * Gets the index of a uniform variable.
  91993. * @param uniformName of the uniform to look up.
  91994. * @returns the index.
  91995. */
  91996. getUniformIndex(uniformName: string): number;
  91997. /**
  91998. * Returns the attribute based on the name of the variable.
  91999. * @param uniformName of the uniform to look up.
  92000. * @returns the location of the uniform.
  92001. */
  92002. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92003. /**
  92004. * Returns an array of sampler variable names
  92005. * @returns The array of sampler variable neames.
  92006. */
  92007. getSamplers(): string[];
  92008. /**
  92009. * The error from the last compilation.
  92010. * @returns the error string.
  92011. */
  92012. getCompilationError(): string;
  92013. /**
  92014. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92015. * @param func The callback to be used.
  92016. */
  92017. executeWhenCompiled(func: (effect: Effect) => void): void;
  92018. private _checkIsReady;
  92019. /** @hidden */
  92020. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92021. /** @hidden */
  92022. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92023. /** @hidden */
  92024. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92025. /**
  92026. * Recompiles the webGL program
  92027. * @param vertexSourceCode The source code for the vertex shader.
  92028. * @param fragmentSourceCode The source code for the fragment shader.
  92029. * @param onCompiled Callback called when completed.
  92030. * @param onError Callback called on error.
  92031. * @hidden
  92032. */
  92033. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92034. /**
  92035. * Prepares the effect
  92036. * @hidden
  92037. */
  92038. _prepareEffect(): void;
  92039. /**
  92040. * Checks if the effect is supported. (Must be called after compilation)
  92041. */
  92042. readonly isSupported: boolean;
  92043. /**
  92044. * Binds a texture to the engine to be used as output of the shader.
  92045. * @param channel Name of the output variable.
  92046. * @param texture Texture to bind.
  92047. * @hidden
  92048. */
  92049. _bindTexture(channel: string, texture: InternalTexture): void;
  92050. /**
  92051. * Sets a texture on the engine to be used in the shader.
  92052. * @param channel Name of the sampler variable.
  92053. * @param texture Texture to set.
  92054. */
  92055. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92056. /**
  92057. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92058. * @param channel Name of the sampler variable.
  92059. * @param texture Texture to set.
  92060. */
  92061. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92062. /**
  92063. * Sets an array of textures on the engine to be used in the shader.
  92064. * @param channel Name of the variable.
  92065. * @param textures Textures to set.
  92066. */
  92067. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92068. /**
  92069. * 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)
  92070. * @param channel Name of the sampler variable.
  92071. * @param postProcess Post process to get the input texture from.
  92072. */
  92073. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92074. /**
  92075. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92076. * 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)
  92077. * @param channel Name of the sampler variable.
  92078. * @param postProcess Post process to get the output texture from.
  92079. */
  92080. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92081. /** @hidden */
  92082. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92083. /** @hidden */
  92084. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92085. /** @hidden */
  92086. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92087. /** @hidden */
  92088. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92089. /**
  92090. * Binds a buffer to a uniform.
  92091. * @param buffer Buffer to bind.
  92092. * @param name Name of the uniform variable to bind to.
  92093. */
  92094. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92095. /**
  92096. * Binds block to a uniform.
  92097. * @param blockName Name of the block to bind.
  92098. * @param index Index to bind.
  92099. */
  92100. bindUniformBlock(blockName: string, index: number): void;
  92101. /**
  92102. * Sets an interger value on a uniform variable.
  92103. * @param uniformName Name of the variable.
  92104. * @param value Value to be set.
  92105. * @returns this effect.
  92106. */
  92107. setInt(uniformName: string, value: number): Effect;
  92108. /**
  92109. * Sets an int array on a uniform variable.
  92110. * @param uniformName Name of the variable.
  92111. * @param array array to be set.
  92112. * @returns this effect.
  92113. */
  92114. setIntArray(uniformName: string, array: Int32Array): Effect;
  92115. /**
  92116. * 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)
  92117. * @param uniformName Name of the variable.
  92118. * @param array array to be set.
  92119. * @returns this effect.
  92120. */
  92121. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92122. /**
  92123. * 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)
  92124. * @param uniformName Name of the variable.
  92125. * @param array array to be set.
  92126. * @returns this effect.
  92127. */
  92128. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92129. /**
  92130. * 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)
  92131. * @param uniformName Name of the variable.
  92132. * @param array array to be set.
  92133. * @returns this effect.
  92134. */
  92135. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92136. /**
  92137. * Sets an float array on a uniform variable.
  92138. * @param uniformName Name of the variable.
  92139. * @param array array to be set.
  92140. * @returns this effect.
  92141. */
  92142. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92143. /**
  92144. * 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)
  92145. * @param uniformName Name of the variable.
  92146. * @param array array to be set.
  92147. * @returns this effect.
  92148. */
  92149. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92150. /**
  92151. * 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)
  92152. * @param uniformName Name of the variable.
  92153. * @param array array to be set.
  92154. * @returns this effect.
  92155. */
  92156. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92157. /**
  92158. * 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)
  92159. * @param uniformName Name of the variable.
  92160. * @param array array to be set.
  92161. * @returns this effect.
  92162. */
  92163. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92164. /**
  92165. * Sets an array on a uniform variable.
  92166. * @param uniformName Name of the variable.
  92167. * @param array array to be set.
  92168. * @returns this effect.
  92169. */
  92170. setArray(uniformName: string, array: number[]): Effect;
  92171. /**
  92172. * 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)
  92173. * @param uniformName Name of the variable.
  92174. * @param array array to be set.
  92175. * @returns this effect.
  92176. */
  92177. setArray2(uniformName: string, array: number[]): Effect;
  92178. /**
  92179. * 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)
  92180. * @param uniformName Name of the variable.
  92181. * @param array array to be set.
  92182. * @returns this effect.
  92183. */
  92184. setArray3(uniformName: string, array: number[]): Effect;
  92185. /**
  92186. * 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)
  92187. * @param uniformName Name of the variable.
  92188. * @param array array to be set.
  92189. * @returns this effect.
  92190. */
  92191. setArray4(uniformName: string, array: number[]): Effect;
  92192. /**
  92193. * Sets matrices on a uniform variable.
  92194. * @param uniformName Name of the variable.
  92195. * @param matrices matrices to be set.
  92196. * @returns this effect.
  92197. */
  92198. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92199. /**
  92200. * Sets matrix on a uniform variable.
  92201. * @param uniformName Name of the variable.
  92202. * @param matrix matrix to be set.
  92203. * @returns this effect.
  92204. */
  92205. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92206. /**
  92207. * 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)
  92208. * @param uniformName Name of the variable.
  92209. * @param matrix matrix to be set.
  92210. * @returns this effect.
  92211. */
  92212. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92213. /**
  92214. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92215. * @param uniformName Name of the variable.
  92216. * @param matrix matrix to be set.
  92217. * @returns this effect.
  92218. */
  92219. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92220. /**
  92221. * Sets a float on a uniform variable.
  92222. * @param uniformName Name of the variable.
  92223. * @param value value to be set.
  92224. * @returns this effect.
  92225. */
  92226. setFloat(uniformName: string, value: number): Effect;
  92227. /**
  92228. * Sets a boolean on a uniform variable.
  92229. * @param uniformName Name of the variable.
  92230. * @param bool value to be set.
  92231. * @returns this effect.
  92232. */
  92233. setBool(uniformName: string, bool: boolean): Effect;
  92234. /**
  92235. * Sets a Vector2 on a uniform variable.
  92236. * @param uniformName Name of the variable.
  92237. * @param vector2 vector2 to be set.
  92238. * @returns this effect.
  92239. */
  92240. setVector2(uniformName: string, vector2: Vector2): Effect;
  92241. /**
  92242. * Sets a float2 on a uniform variable.
  92243. * @param uniformName Name of the variable.
  92244. * @param x First float in float2.
  92245. * @param y Second float in float2.
  92246. * @returns this effect.
  92247. */
  92248. setFloat2(uniformName: string, x: number, y: number): Effect;
  92249. /**
  92250. * Sets a Vector3 on a uniform variable.
  92251. * @param uniformName Name of the variable.
  92252. * @param vector3 Value to be set.
  92253. * @returns this effect.
  92254. */
  92255. setVector3(uniformName: string, vector3: Vector3): Effect;
  92256. /**
  92257. * Sets a float3 on a uniform variable.
  92258. * @param uniformName Name of the variable.
  92259. * @param x First float in float3.
  92260. * @param y Second float in float3.
  92261. * @param z Third float in float3.
  92262. * @returns this effect.
  92263. */
  92264. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92265. /**
  92266. * Sets a Vector4 on a uniform variable.
  92267. * @param uniformName Name of the variable.
  92268. * @param vector4 Value to be set.
  92269. * @returns this effect.
  92270. */
  92271. setVector4(uniformName: string, vector4: Vector4): Effect;
  92272. /**
  92273. * Sets a float4 on a uniform variable.
  92274. * @param uniformName Name of the variable.
  92275. * @param x First float in float4.
  92276. * @param y Second float in float4.
  92277. * @param z Third float in float4.
  92278. * @param w Fourth float in float4.
  92279. * @returns this effect.
  92280. */
  92281. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92282. /**
  92283. * Sets a Color3 on a uniform variable.
  92284. * @param uniformName Name of the variable.
  92285. * @param color3 Value to be set.
  92286. * @returns this effect.
  92287. */
  92288. setColor3(uniformName: string, color3: Color3): Effect;
  92289. /**
  92290. * Sets a Color4 on a uniform variable.
  92291. * @param uniformName Name of the variable.
  92292. * @param color3 Value to be set.
  92293. * @param alpha Alpha value to be set.
  92294. * @returns this effect.
  92295. */
  92296. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92297. /**
  92298. * Sets a Color4 on a uniform variable
  92299. * @param uniformName defines the name of the variable
  92300. * @param color4 defines the value to be set
  92301. * @returns this effect.
  92302. */
  92303. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92304. /** Release all associated resources */
  92305. dispose(): void;
  92306. /**
  92307. * This function will add a new shader to the shader store
  92308. * @param name the name of the shader
  92309. * @param pixelShader optional pixel shader content
  92310. * @param vertexShader optional vertex shader content
  92311. */
  92312. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92313. /**
  92314. * Store of each shader (The can be looked up using effect.key)
  92315. */
  92316. static ShadersStore: {
  92317. [key: string]: string;
  92318. };
  92319. /**
  92320. * Store of each included file for a shader (The can be looked up using effect.key)
  92321. */
  92322. static IncludesShadersStore: {
  92323. [key: string]: string;
  92324. };
  92325. /**
  92326. * Resets the cache of effects.
  92327. */
  92328. static ResetCache(): void;
  92329. }
  92330. }
  92331. declare module BABYLON {
  92332. /**
  92333. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92334. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92335. * 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;
  92336. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92337. */
  92338. export class ColorCurves {
  92339. private _dirty;
  92340. private _tempColor;
  92341. private _globalCurve;
  92342. private _highlightsCurve;
  92343. private _midtonesCurve;
  92344. private _shadowsCurve;
  92345. private _positiveCurve;
  92346. private _negativeCurve;
  92347. private _globalHue;
  92348. private _globalDensity;
  92349. private _globalSaturation;
  92350. private _globalExposure;
  92351. /**
  92352. * Gets the global Hue value.
  92353. * 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).
  92354. */
  92355. /**
  92356. * Sets the global Hue value.
  92357. * 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).
  92358. */
  92359. globalHue: number;
  92360. /**
  92361. * Gets the global Density value.
  92362. * 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.
  92363. * Values less than zero provide a filter of opposite hue.
  92364. */
  92365. /**
  92366. * Sets the global Density value.
  92367. * 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.
  92368. * Values less than zero provide a filter of opposite hue.
  92369. */
  92370. globalDensity: number;
  92371. /**
  92372. * Gets the global Saturation value.
  92373. * 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.
  92374. */
  92375. /**
  92376. * Sets the global Saturation value.
  92377. * 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.
  92378. */
  92379. globalSaturation: number;
  92380. /**
  92381. * Gets the global Exposure value.
  92382. * 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.
  92383. */
  92384. /**
  92385. * Sets the global Exposure value.
  92386. * 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.
  92387. */
  92388. globalExposure: number;
  92389. private _highlightsHue;
  92390. private _highlightsDensity;
  92391. private _highlightsSaturation;
  92392. private _highlightsExposure;
  92393. /**
  92394. * Gets the highlights Hue value.
  92395. * 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).
  92396. */
  92397. /**
  92398. * Sets the highlights Hue value.
  92399. * 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).
  92400. */
  92401. highlightsHue: number;
  92402. /**
  92403. * Gets the highlights Density value.
  92404. * 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.
  92405. * Values less than zero provide a filter of opposite hue.
  92406. */
  92407. /**
  92408. * Sets the highlights Density value.
  92409. * 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.
  92410. * Values less than zero provide a filter of opposite hue.
  92411. */
  92412. highlightsDensity: number;
  92413. /**
  92414. * Gets the highlights Saturation value.
  92415. * 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.
  92416. */
  92417. /**
  92418. * Sets the highlights Saturation value.
  92419. * 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.
  92420. */
  92421. highlightsSaturation: number;
  92422. /**
  92423. * Gets the highlights Exposure value.
  92424. * 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.
  92425. */
  92426. /**
  92427. * Sets the highlights Exposure value.
  92428. * 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.
  92429. */
  92430. highlightsExposure: number;
  92431. private _midtonesHue;
  92432. private _midtonesDensity;
  92433. private _midtonesSaturation;
  92434. private _midtonesExposure;
  92435. /**
  92436. * Gets the midtones Hue value.
  92437. * 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).
  92438. */
  92439. /**
  92440. * Sets the midtones Hue value.
  92441. * 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).
  92442. */
  92443. midtonesHue: number;
  92444. /**
  92445. * Gets the midtones Density value.
  92446. * 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.
  92447. * Values less than zero provide a filter of opposite hue.
  92448. */
  92449. /**
  92450. * Sets the midtones Density value.
  92451. * 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.
  92452. * Values less than zero provide a filter of opposite hue.
  92453. */
  92454. midtonesDensity: number;
  92455. /**
  92456. * Gets the midtones Saturation value.
  92457. * 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.
  92458. */
  92459. /**
  92460. * Sets the midtones Saturation value.
  92461. * 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.
  92462. */
  92463. midtonesSaturation: number;
  92464. /**
  92465. * Gets the midtones Exposure value.
  92466. * 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.
  92467. */
  92468. /**
  92469. * Sets the midtones Exposure value.
  92470. * 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.
  92471. */
  92472. midtonesExposure: number;
  92473. private _shadowsHue;
  92474. private _shadowsDensity;
  92475. private _shadowsSaturation;
  92476. private _shadowsExposure;
  92477. /**
  92478. * Gets the shadows Hue value.
  92479. * 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).
  92480. */
  92481. /**
  92482. * Sets the shadows Hue value.
  92483. * 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).
  92484. */
  92485. shadowsHue: number;
  92486. /**
  92487. * Gets the shadows Density value.
  92488. * 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.
  92489. * Values less than zero provide a filter of opposite hue.
  92490. */
  92491. /**
  92492. * Sets the shadows Density value.
  92493. * 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.
  92494. * Values less than zero provide a filter of opposite hue.
  92495. */
  92496. shadowsDensity: number;
  92497. /**
  92498. * Gets the shadows Saturation value.
  92499. * 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.
  92500. */
  92501. /**
  92502. * Sets the shadows Saturation value.
  92503. * 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.
  92504. */
  92505. shadowsSaturation: number;
  92506. /**
  92507. * Gets the shadows Exposure value.
  92508. * 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.
  92509. */
  92510. /**
  92511. * Sets the shadows Exposure value.
  92512. * 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.
  92513. */
  92514. shadowsExposure: number;
  92515. /**
  92516. * Returns the class name
  92517. * @returns The class name
  92518. */
  92519. getClassName(): string;
  92520. /**
  92521. * Binds the color curves to the shader.
  92522. * @param colorCurves The color curve to bind
  92523. * @param effect The effect to bind to
  92524. * @param positiveUniform The positive uniform shader parameter
  92525. * @param neutralUniform The neutral uniform shader parameter
  92526. * @param negativeUniform The negative uniform shader parameter
  92527. */
  92528. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92529. /**
  92530. * Prepare the list of uniforms associated with the ColorCurves effects.
  92531. * @param uniformsList The list of uniforms used in the effect
  92532. */
  92533. static PrepareUniforms(uniformsList: string[]): void;
  92534. /**
  92535. * Returns color grading data based on a hue, density, saturation and exposure value.
  92536. * @param filterHue The hue of the color filter.
  92537. * @param filterDensity The density of the color filter.
  92538. * @param saturation The saturation.
  92539. * @param exposure The exposure.
  92540. * @param result The result data container.
  92541. */
  92542. private getColorGradingDataToRef;
  92543. /**
  92544. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92545. * @param value The input slider value in range [-100,100].
  92546. * @returns Adjusted value.
  92547. */
  92548. private static applyColorGradingSliderNonlinear;
  92549. /**
  92550. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92551. * @param hue The hue (H) input.
  92552. * @param saturation The saturation (S) input.
  92553. * @param brightness The brightness (B) input.
  92554. * @result An RGBA color represented as Vector4.
  92555. */
  92556. private static fromHSBToRef;
  92557. /**
  92558. * Returns a value clamped between min and max
  92559. * @param value The value to clamp
  92560. * @param min The minimum of value
  92561. * @param max The maximum of value
  92562. * @returns The clamped value.
  92563. */
  92564. private static clamp;
  92565. /**
  92566. * Clones the current color curve instance.
  92567. * @return The cloned curves
  92568. */
  92569. clone(): ColorCurves;
  92570. /**
  92571. * Serializes the current color curve instance to a json representation.
  92572. * @return a JSON representation
  92573. */
  92574. serialize(): any;
  92575. /**
  92576. * Parses the color curve from a json representation.
  92577. * @param source the JSON source to parse
  92578. * @return The parsed curves
  92579. */
  92580. static Parse(source: any): ColorCurves;
  92581. }
  92582. }
  92583. declare module BABYLON {
  92584. /**
  92585. * Interface to follow in your material defines to integrate easily the
  92586. * Image proccessing functions.
  92587. * @hidden
  92588. */
  92589. export interface IImageProcessingConfigurationDefines {
  92590. IMAGEPROCESSING: boolean;
  92591. VIGNETTE: boolean;
  92592. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92593. VIGNETTEBLENDMODEOPAQUE: boolean;
  92594. TONEMAPPING: boolean;
  92595. TONEMAPPING_ACES: boolean;
  92596. CONTRAST: boolean;
  92597. EXPOSURE: boolean;
  92598. COLORCURVES: boolean;
  92599. COLORGRADING: boolean;
  92600. COLORGRADING3D: boolean;
  92601. SAMPLER3DGREENDEPTH: boolean;
  92602. SAMPLER3DBGRMAP: boolean;
  92603. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92604. }
  92605. /**
  92606. * @hidden
  92607. */
  92608. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92609. IMAGEPROCESSING: boolean;
  92610. VIGNETTE: boolean;
  92611. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92612. VIGNETTEBLENDMODEOPAQUE: boolean;
  92613. TONEMAPPING: boolean;
  92614. TONEMAPPING_ACES: boolean;
  92615. CONTRAST: boolean;
  92616. COLORCURVES: boolean;
  92617. COLORGRADING: boolean;
  92618. COLORGRADING3D: boolean;
  92619. SAMPLER3DGREENDEPTH: boolean;
  92620. SAMPLER3DBGRMAP: boolean;
  92621. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92622. EXPOSURE: boolean;
  92623. constructor();
  92624. }
  92625. /**
  92626. * This groups together the common properties used for image processing either in direct forward pass
  92627. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92628. * or not.
  92629. */
  92630. export class ImageProcessingConfiguration {
  92631. /**
  92632. * Default tone mapping applied in BabylonJS.
  92633. */
  92634. static readonly TONEMAPPING_STANDARD: number;
  92635. /**
  92636. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92637. * to other engines rendering to increase portability.
  92638. */
  92639. static readonly TONEMAPPING_ACES: number;
  92640. /**
  92641. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92642. */
  92643. colorCurves: Nullable<ColorCurves>;
  92644. private _colorCurvesEnabled;
  92645. /**
  92646. * Gets wether the color curves effect is enabled.
  92647. */
  92648. /**
  92649. * Sets wether the color curves effect is enabled.
  92650. */
  92651. colorCurvesEnabled: boolean;
  92652. private _colorGradingTexture;
  92653. /**
  92654. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92655. */
  92656. /**
  92657. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92658. */
  92659. colorGradingTexture: Nullable<BaseTexture>;
  92660. private _colorGradingEnabled;
  92661. /**
  92662. * Gets wether the color grading effect is enabled.
  92663. */
  92664. /**
  92665. * Sets wether the color grading effect is enabled.
  92666. */
  92667. colorGradingEnabled: boolean;
  92668. private _colorGradingWithGreenDepth;
  92669. /**
  92670. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92671. */
  92672. /**
  92673. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92674. */
  92675. colorGradingWithGreenDepth: boolean;
  92676. private _colorGradingBGR;
  92677. /**
  92678. * Gets wether the color grading texture contains BGR values.
  92679. */
  92680. /**
  92681. * Sets wether the color grading texture contains BGR values.
  92682. */
  92683. colorGradingBGR: boolean;
  92684. /** @hidden */
  92685. _exposure: number;
  92686. /**
  92687. * Gets the Exposure used in the effect.
  92688. */
  92689. /**
  92690. * Sets the Exposure used in the effect.
  92691. */
  92692. exposure: number;
  92693. private _toneMappingEnabled;
  92694. /**
  92695. * Gets wether the tone mapping effect is enabled.
  92696. */
  92697. /**
  92698. * Sets wether the tone mapping effect is enabled.
  92699. */
  92700. toneMappingEnabled: boolean;
  92701. private _toneMappingType;
  92702. /**
  92703. * Gets the type of tone mapping effect.
  92704. */
  92705. /**
  92706. * Sets the type of tone mapping effect used in BabylonJS.
  92707. */
  92708. toneMappingType: number;
  92709. protected _contrast: number;
  92710. /**
  92711. * Gets the contrast used in the effect.
  92712. */
  92713. /**
  92714. * Sets the contrast used in the effect.
  92715. */
  92716. contrast: number;
  92717. /**
  92718. * Vignette stretch size.
  92719. */
  92720. vignetteStretch: number;
  92721. /**
  92722. * Vignette centre X Offset.
  92723. */
  92724. vignetteCentreX: number;
  92725. /**
  92726. * Vignette centre Y Offset.
  92727. */
  92728. vignetteCentreY: number;
  92729. /**
  92730. * Vignette weight or intensity of the vignette effect.
  92731. */
  92732. vignetteWeight: number;
  92733. /**
  92734. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92735. * if vignetteEnabled is set to true.
  92736. */
  92737. vignetteColor: Color4;
  92738. /**
  92739. * Camera field of view used by the Vignette effect.
  92740. */
  92741. vignetteCameraFov: number;
  92742. private _vignetteBlendMode;
  92743. /**
  92744. * Gets the vignette blend mode allowing different kind of effect.
  92745. */
  92746. /**
  92747. * Sets the vignette blend mode allowing different kind of effect.
  92748. */
  92749. vignetteBlendMode: number;
  92750. private _vignetteEnabled;
  92751. /**
  92752. * Gets wether the vignette effect is enabled.
  92753. */
  92754. /**
  92755. * Sets wether the vignette effect is enabled.
  92756. */
  92757. vignetteEnabled: boolean;
  92758. private _applyByPostProcess;
  92759. /**
  92760. * Gets wether the image processing is applied through a post process or not.
  92761. */
  92762. /**
  92763. * Sets wether the image processing is applied through a post process or not.
  92764. */
  92765. applyByPostProcess: boolean;
  92766. private _isEnabled;
  92767. /**
  92768. * Gets wether the image processing is enabled or not.
  92769. */
  92770. /**
  92771. * Sets wether the image processing is enabled or not.
  92772. */
  92773. isEnabled: boolean;
  92774. /**
  92775. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92776. */
  92777. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92778. /**
  92779. * Method called each time the image processing information changes requires to recompile the effect.
  92780. */
  92781. protected _updateParameters(): void;
  92782. /**
  92783. * Gets the current class name.
  92784. * @return "ImageProcessingConfiguration"
  92785. */
  92786. getClassName(): string;
  92787. /**
  92788. * Prepare the list of uniforms associated with the Image Processing effects.
  92789. * @param uniforms The list of uniforms used in the effect
  92790. * @param defines the list of defines currently in use
  92791. */
  92792. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92793. /**
  92794. * Prepare the list of samplers associated with the Image Processing effects.
  92795. * @param samplersList The list of uniforms used in the effect
  92796. * @param defines the list of defines currently in use
  92797. */
  92798. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92799. /**
  92800. * Prepare the list of defines associated to the shader.
  92801. * @param defines the list of defines to complete
  92802. * @param forPostProcess Define if we are currently in post process mode or not
  92803. */
  92804. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92805. /**
  92806. * Returns true if all the image processing information are ready.
  92807. * @returns True if ready, otherwise, false
  92808. */
  92809. isReady(): boolean;
  92810. /**
  92811. * Binds the image processing to the shader.
  92812. * @param effect The effect to bind to
  92813. * @param aspectRatio Define the current aspect ratio of the effect
  92814. */
  92815. bind(effect: Effect, aspectRatio?: number): void;
  92816. /**
  92817. * Clones the current image processing instance.
  92818. * @return The cloned image processing
  92819. */
  92820. clone(): ImageProcessingConfiguration;
  92821. /**
  92822. * Serializes the current image processing instance to a json representation.
  92823. * @return a JSON representation
  92824. */
  92825. serialize(): any;
  92826. /**
  92827. * Parses the image processing from a json representation.
  92828. * @param source the JSON source to parse
  92829. * @return The parsed image processing
  92830. */
  92831. static Parse(source: any): ImageProcessingConfiguration;
  92832. private static _VIGNETTEMODE_MULTIPLY;
  92833. private static _VIGNETTEMODE_OPAQUE;
  92834. /**
  92835. * Used to apply the vignette as a mix with the pixel color.
  92836. */
  92837. static readonly VIGNETTEMODE_MULTIPLY: number;
  92838. /**
  92839. * Used to apply the vignette as a replacement of the pixel color.
  92840. */
  92841. static readonly VIGNETTEMODE_OPAQUE: number;
  92842. }
  92843. }
  92844. declare module BABYLON {
  92845. /**
  92846. * This represents all the required information to add a fresnel effect on a material:
  92847. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92848. */
  92849. export class FresnelParameters {
  92850. private _isEnabled;
  92851. /**
  92852. * Define if the fresnel effect is enable or not.
  92853. */
  92854. isEnabled: boolean;
  92855. /**
  92856. * Define the color used on edges (grazing angle)
  92857. */
  92858. leftColor: Color3;
  92859. /**
  92860. * Define the color used on center
  92861. */
  92862. rightColor: Color3;
  92863. /**
  92864. * Define bias applied to computed fresnel term
  92865. */
  92866. bias: number;
  92867. /**
  92868. * Defined the power exponent applied to fresnel term
  92869. */
  92870. power: number;
  92871. /**
  92872. * Clones the current fresnel and its valuues
  92873. * @returns a clone fresnel configuration
  92874. */
  92875. clone(): FresnelParameters;
  92876. /**
  92877. * Serializes the current fresnel parameters to a JSON representation.
  92878. * @return the JSON serialization
  92879. */
  92880. serialize(): any;
  92881. /**
  92882. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92883. * @param parsedFresnelParameters Define the JSON representation
  92884. * @returns the parsed parameters
  92885. */
  92886. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92887. }
  92888. }
  92889. declare module BABYLON {
  92890. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92891. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92892. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92893. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92894. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92895. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92896. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92897. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92898. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92899. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92900. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92901. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92902. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92903. /**
  92904. * Decorator used to define property that can be serialized as reference to a camera
  92905. * @param sourceName defines the name of the property to decorate
  92906. */
  92907. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92908. /**
  92909. * Class used to help serialization objects
  92910. */
  92911. export class SerializationHelper {
  92912. /** @hidden */
  92913. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92914. /** @hidden */
  92915. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92916. /** @hidden */
  92917. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92918. /** @hidden */
  92919. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92920. /**
  92921. * Appends the serialized animations from the source animations
  92922. * @param source Source containing the animations
  92923. * @param destination Target to store the animations
  92924. */
  92925. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92926. /**
  92927. * Static function used to serialized a specific entity
  92928. * @param entity defines the entity to serialize
  92929. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92930. * @returns a JSON compatible object representing the serialization of the entity
  92931. */
  92932. static Serialize<T>(entity: T, serializationObject?: any): any;
  92933. /**
  92934. * Creates a new entity from a serialization data object
  92935. * @param creationFunction defines a function used to instanciated the new entity
  92936. * @param source defines the source serialization data
  92937. * @param scene defines the hosting scene
  92938. * @param rootUrl defines the root url for resources
  92939. * @returns a new entity
  92940. */
  92941. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92942. /**
  92943. * Clones an object
  92944. * @param creationFunction defines the function used to instanciate the new object
  92945. * @param source defines the source object
  92946. * @returns the cloned object
  92947. */
  92948. static Clone<T>(creationFunction: () => T, source: T): T;
  92949. /**
  92950. * Instanciates a new object based on a source one (some data will be shared between both object)
  92951. * @param creationFunction defines the function used to instanciate the new object
  92952. * @param source defines the source object
  92953. * @returns the new object
  92954. */
  92955. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92956. }
  92957. }
  92958. declare module BABYLON {
  92959. /**
  92960. * This is the base class of all the camera used in the application.
  92961. * @see http://doc.babylonjs.com/features/cameras
  92962. */
  92963. export class Camera extends Node {
  92964. /** @hidden */
  92965. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92966. /**
  92967. * This is the default projection mode used by the cameras.
  92968. * It helps recreating a feeling of perspective and better appreciate depth.
  92969. * This is the best way to simulate real life cameras.
  92970. */
  92971. static readonly PERSPECTIVE_CAMERA: number;
  92972. /**
  92973. * This helps creating camera with an orthographic mode.
  92974. * 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.
  92975. */
  92976. static readonly ORTHOGRAPHIC_CAMERA: number;
  92977. /**
  92978. * This is the default FOV mode for perspective cameras.
  92979. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92980. */
  92981. static readonly FOVMODE_VERTICAL_FIXED: number;
  92982. /**
  92983. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92984. */
  92985. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92986. /**
  92987. * This specifies ther is no need for a camera rig.
  92988. * Basically only one eye is rendered corresponding to the camera.
  92989. */
  92990. static readonly RIG_MODE_NONE: number;
  92991. /**
  92992. * Simulates a camera Rig with one blue eye and one red eye.
  92993. * This can be use with 3d blue and red glasses.
  92994. */
  92995. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92996. /**
  92997. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92998. */
  92999. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93000. /**
  93001. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93002. */
  93003. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93004. /**
  93005. * Defines that both eyes of the camera will be rendered over under each other.
  93006. */
  93007. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93008. /**
  93009. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93010. */
  93011. static readonly RIG_MODE_VR: number;
  93012. /**
  93013. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93014. */
  93015. static readonly RIG_MODE_WEBVR: number;
  93016. /**
  93017. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93018. */
  93019. static readonly RIG_MODE_CUSTOM: number;
  93020. /**
  93021. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93022. */
  93023. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93024. /**
  93025. * Define the input manager associated with the camera.
  93026. */
  93027. inputs: CameraInputsManager<Camera>;
  93028. /** @hidden */
  93029. _position: Vector3;
  93030. /**
  93031. * Define the current local position of the camera in the scene
  93032. */
  93033. position: Vector3;
  93034. /**
  93035. * The vector the camera should consider as up.
  93036. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93037. */
  93038. upVector: Vector3;
  93039. /**
  93040. * Define the current limit on the left side for an orthographic camera
  93041. * In scene unit
  93042. */
  93043. orthoLeft: Nullable<number>;
  93044. /**
  93045. * Define the current limit on the right side for an orthographic camera
  93046. * In scene unit
  93047. */
  93048. orthoRight: Nullable<number>;
  93049. /**
  93050. * Define the current limit on the bottom side for an orthographic camera
  93051. * In scene unit
  93052. */
  93053. orthoBottom: Nullable<number>;
  93054. /**
  93055. * Define the current limit on the top side for an orthographic camera
  93056. * In scene unit
  93057. */
  93058. orthoTop: Nullable<number>;
  93059. /**
  93060. * Field Of View is set in Radians. (default is 0.8)
  93061. */
  93062. fov: number;
  93063. /**
  93064. * Define the minimum distance the camera can see from.
  93065. * This is important to note that the depth buffer are not infinite and the closer it starts
  93066. * the more your scene might encounter depth fighting issue.
  93067. */
  93068. minZ: number;
  93069. /**
  93070. * Define the maximum distance the camera can see to.
  93071. * This is important to note that the depth buffer are not infinite and the further it end
  93072. * the more your scene might encounter depth fighting issue.
  93073. */
  93074. maxZ: number;
  93075. /**
  93076. * Define the default inertia of the camera.
  93077. * This helps giving a smooth feeling to the camera movement.
  93078. */
  93079. inertia: number;
  93080. /**
  93081. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  93082. */
  93083. mode: number;
  93084. /**
  93085. * Define wether the camera is intermediate.
  93086. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93087. */
  93088. isIntermediate: boolean;
  93089. /**
  93090. * Define the viewport of the camera.
  93091. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93092. */
  93093. viewport: Viewport;
  93094. /**
  93095. * Restricts the camera to viewing objects with the same layerMask.
  93096. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93097. */
  93098. layerMask: number;
  93099. /**
  93100. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93101. */
  93102. fovMode: number;
  93103. /**
  93104. * Rig mode of the camera.
  93105. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93106. * This is normally controlled byt the camera themselves as internal use.
  93107. */
  93108. cameraRigMode: number;
  93109. /**
  93110. * Defines the distance between both "eyes" in case of a RIG
  93111. */
  93112. interaxialDistance: number;
  93113. /**
  93114. * Defines if stereoscopic rendering is done side by side or over under.
  93115. */
  93116. isStereoscopicSideBySide: boolean;
  93117. /**
  93118. * 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
  93119. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93120. * else in the scene.
  93121. */
  93122. customRenderTargets: RenderTargetTexture[];
  93123. /**
  93124. * When set, the camera will render to this render target instead of the default canvas
  93125. */
  93126. outputRenderTarget: Nullable<RenderTargetTexture>;
  93127. /**
  93128. * Observable triggered when the camera view matrix has changed.
  93129. */
  93130. onViewMatrixChangedObservable: Observable<Camera>;
  93131. /**
  93132. * Observable triggered when the camera Projection matrix has changed.
  93133. */
  93134. onProjectionMatrixChangedObservable: Observable<Camera>;
  93135. /**
  93136. * Observable triggered when the inputs have been processed.
  93137. */
  93138. onAfterCheckInputsObservable: Observable<Camera>;
  93139. /**
  93140. * Observable triggered when reset has been called and applied to the camera.
  93141. */
  93142. onRestoreStateObservable: Observable<Camera>;
  93143. /** @hidden */
  93144. _cameraRigParams: any;
  93145. /** @hidden */
  93146. _rigCameras: Camera[];
  93147. /** @hidden */
  93148. _rigPostProcess: Nullable<PostProcess>;
  93149. protected _webvrViewMatrix: Matrix;
  93150. /** @hidden */
  93151. _skipRendering: boolean;
  93152. /** @hidden */
  93153. _projectionMatrix: Matrix;
  93154. /** @hidden */
  93155. _postProcesses: Nullable<PostProcess>[];
  93156. /** @hidden */
  93157. _activeMeshes: SmartArray<AbstractMesh>;
  93158. protected _globalPosition: Vector3;
  93159. /** @hidden */
  93160. _computedViewMatrix: Matrix;
  93161. private _doNotComputeProjectionMatrix;
  93162. private _transformMatrix;
  93163. private _frustumPlanes;
  93164. private _refreshFrustumPlanes;
  93165. private _storedFov;
  93166. private _stateStored;
  93167. /**
  93168. * Instantiates a new camera object.
  93169. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93170. * @see http://doc.babylonjs.com/features/cameras
  93171. * @param name Defines the name of the camera in the scene
  93172. * @param position Defines the position of the camera
  93173. * @param scene Defines the scene the camera belongs too
  93174. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93175. */
  93176. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93177. /**
  93178. * Store current camera state (fov, position, etc..)
  93179. * @returns the camera
  93180. */
  93181. storeState(): Camera;
  93182. /**
  93183. * Restores the camera state values if it has been stored. You must call storeState() first
  93184. */
  93185. protected _restoreStateValues(): boolean;
  93186. /**
  93187. * Restored camera state. You must call storeState() first.
  93188. * @returns true if restored and false otherwise
  93189. */
  93190. restoreState(): boolean;
  93191. /**
  93192. * Gets the class name of the camera.
  93193. * @returns the class name
  93194. */
  93195. getClassName(): string;
  93196. /** @hidden */
  93197. readonly _isCamera: boolean;
  93198. /**
  93199. * Gets a string representation of the camera useful for debug purpose.
  93200. * @param fullDetails Defines that a more verboe level of logging is required
  93201. * @returns the string representation
  93202. */
  93203. toString(fullDetails?: boolean): string;
  93204. /**
  93205. * Gets the current world space position of the camera.
  93206. */
  93207. readonly globalPosition: Vector3;
  93208. /**
  93209. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93210. * @returns the active meshe list
  93211. */
  93212. getActiveMeshes(): SmartArray<AbstractMesh>;
  93213. /**
  93214. * Check wether a mesh is part of the current active mesh list of the camera
  93215. * @param mesh Defines the mesh to check
  93216. * @returns true if active, false otherwise
  93217. */
  93218. isActiveMesh(mesh: Mesh): boolean;
  93219. /**
  93220. * Is this camera ready to be used/rendered
  93221. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93222. * @return true if the camera is ready
  93223. */
  93224. isReady(completeCheck?: boolean): boolean;
  93225. /** @hidden */
  93226. _initCache(): void;
  93227. /** @hidden */
  93228. _updateCache(ignoreParentClass?: boolean): void;
  93229. /** @hidden */
  93230. _isSynchronized(): boolean;
  93231. /** @hidden */
  93232. _isSynchronizedViewMatrix(): boolean;
  93233. /** @hidden */
  93234. _isSynchronizedProjectionMatrix(): boolean;
  93235. /**
  93236. * Attach the input controls to a specific dom element to get the input from.
  93237. * @param element Defines the element the controls should be listened from
  93238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93239. */
  93240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93241. /**
  93242. * Detach the current controls from the specified dom element.
  93243. * @param element Defines the element to stop listening the inputs from
  93244. */
  93245. detachControl(element: HTMLElement): void;
  93246. /**
  93247. * Update the camera state according to the different inputs gathered during the frame.
  93248. */
  93249. update(): void;
  93250. /** @hidden */
  93251. _checkInputs(): void;
  93252. /** @hidden */
  93253. readonly rigCameras: Camera[];
  93254. /**
  93255. * Gets the post process used by the rig cameras
  93256. */
  93257. readonly rigPostProcess: Nullable<PostProcess>;
  93258. /**
  93259. * Internal, gets the first post proces.
  93260. * @returns the first post process to be run on this camera.
  93261. */
  93262. _getFirstPostProcess(): Nullable<PostProcess>;
  93263. private _cascadePostProcessesToRigCams;
  93264. /**
  93265. * Attach a post process to the camera.
  93266. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93267. * @param postProcess The post process to attach to the camera
  93268. * @param insertAt The position of the post process in case several of them are in use in the scene
  93269. * @returns the position the post process has been inserted at
  93270. */
  93271. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93272. /**
  93273. * Detach a post process to the camera.
  93274. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93275. * @param postProcess The post process to detach from the camera
  93276. */
  93277. detachPostProcess(postProcess: PostProcess): void;
  93278. /**
  93279. * Gets the current world matrix of the camera
  93280. */
  93281. getWorldMatrix(): Matrix;
  93282. /** @hidden */
  93283. _getViewMatrix(): Matrix;
  93284. /**
  93285. * Gets the current view matrix of the camera.
  93286. * @param force forces the camera to recompute the matrix without looking at the cached state
  93287. * @returns the view matrix
  93288. */
  93289. getViewMatrix(force?: boolean): Matrix;
  93290. /**
  93291. * Freeze the projection matrix.
  93292. * It will prevent the cache check of the camera projection compute and can speed up perf
  93293. * if no parameter of the camera are meant to change
  93294. * @param projection Defines manually a projection if necessary
  93295. */
  93296. freezeProjectionMatrix(projection?: Matrix): void;
  93297. /**
  93298. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93299. */
  93300. unfreezeProjectionMatrix(): void;
  93301. /**
  93302. * Gets the current projection matrix of the camera.
  93303. * @param force forces the camera to recompute the matrix without looking at the cached state
  93304. * @returns the projection matrix
  93305. */
  93306. getProjectionMatrix(force?: boolean): Matrix;
  93307. /**
  93308. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93309. * @returns a Matrix
  93310. */
  93311. getTransformationMatrix(): Matrix;
  93312. private _updateFrustumPlanes;
  93313. /**
  93314. * Checks if a cullable object (mesh...) is in the camera frustum
  93315. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93316. * @param target The object to check
  93317. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93318. * @returns true if the object is in frustum otherwise false
  93319. */
  93320. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93321. /**
  93322. * Checks if a cullable object (mesh...) is in the camera frustum
  93323. * Unlike isInFrustum this cheks the full bounding box
  93324. * @param target The object to check
  93325. * @returns true if the object is in frustum otherwise false
  93326. */
  93327. isCompletelyInFrustum(target: ICullable): boolean;
  93328. /**
  93329. * Gets a ray in the forward direction from the camera.
  93330. * @param length Defines the length of the ray to create
  93331. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93332. * @param origin Defines the start point of the ray which defaults to the camera position
  93333. * @returns the forward ray
  93334. */
  93335. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93336. /**
  93337. * Releases resources associated with this node.
  93338. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93339. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93340. */
  93341. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93342. /** @hidden */
  93343. _isLeftCamera: boolean;
  93344. /**
  93345. * Gets the left camera of a rig setup in case of Rigged Camera
  93346. */
  93347. readonly isLeftCamera: boolean;
  93348. /** @hidden */
  93349. _isRightCamera: boolean;
  93350. /**
  93351. * Gets the right camera of a rig setup in case of Rigged Camera
  93352. */
  93353. readonly isRightCamera: boolean;
  93354. /**
  93355. * Gets the left camera of a rig setup in case of Rigged Camera
  93356. */
  93357. readonly leftCamera: Nullable<FreeCamera>;
  93358. /**
  93359. * Gets the right camera of a rig setup in case of Rigged Camera
  93360. */
  93361. readonly rightCamera: Nullable<FreeCamera>;
  93362. /**
  93363. * Gets the left camera target of a rig setup in case of Rigged Camera
  93364. * @returns the target position
  93365. */
  93366. getLeftTarget(): Nullable<Vector3>;
  93367. /**
  93368. * Gets the right camera target of a rig setup in case of Rigged Camera
  93369. * @returns the target position
  93370. */
  93371. getRightTarget(): Nullable<Vector3>;
  93372. /**
  93373. * @hidden
  93374. */
  93375. setCameraRigMode(mode: number, rigParams: any): void;
  93376. /** @hidden */
  93377. static _setStereoscopicRigMode(camera: Camera): void;
  93378. /** @hidden */
  93379. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93380. /** @hidden */
  93381. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93382. /** @hidden */
  93383. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93384. /** @hidden */
  93385. _getVRProjectionMatrix(): Matrix;
  93386. protected _updateCameraRotationMatrix(): void;
  93387. protected _updateWebVRCameraRotationMatrix(): void;
  93388. /**
  93389. * This function MUST be overwritten by the different WebVR cameras available.
  93390. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93391. * @hidden
  93392. */
  93393. _getWebVRProjectionMatrix(): Matrix;
  93394. /**
  93395. * This function MUST be overwritten by the different WebVR cameras available.
  93396. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93397. * @hidden
  93398. */
  93399. _getWebVRViewMatrix(): Matrix;
  93400. /** @hidden */
  93401. setCameraRigParameter(name: string, value: any): void;
  93402. /**
  93403. * needs to be overridden by children so sub has required properties to be copied
  93404. * @hidden
  93405. */
  93406. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93407. /**
  93408. * May need to be overridden by children
  93409. * @hidden
  93410. */
  93411. _updateRigCameras(): void;
  93412. /** @hidden */
  93413. _setupInputs(): void;
  93414. /**
  93415. * Serialiaze the camera setup to a json represention
  93416. * @returns the JSON representation
  93417. */
  93418. serialize(): any;
  93419. /**
  93420. * Clones the current camera.
  93421. * @param name The cloned camera name
  93422. * @returns the cloned camera
  93423. */
  93424. clone(name: string): Camera;
  93425. /**
  93426. * Gets the direction of the camera relative to a given local axis.
  93427. * @param localAxis Defines the reference axis to provide a relative direction.
  93428. * @return the direction
  93429. */
  93430. getDirection(localAxis: Vector3): Vector3;
  93431. /**
  93432. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93433. * @param localAxis Defines the reference axis to provide a relative direction.
  93434. * @param result Defines the vector to store the result in
  93435. */
  93436. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93437. /**
  93438. * Gets a camera constructor for a given camera type
  93439. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93440. * @param name The name of the camera the result will be able to instantiate
  93441. * @param scene The scene the result will construct the camera in
  93442. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93443. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93444. * @returns a factory method to construc the camera
  93445. */
  93446. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93447. /**
  93448. * Compute the world matrix of the camera.
  93449. * @returns the camera workd matrix
  93450. */
  93451. computeWorldMatrix(): Matrix;
  93452. /**
  93453. * Parse a JSON and creates the camera from the parsed information
  93454. * @param parsedCamera The JSON to parse
  93455. * @param scene The scene to instantiate the camera in
  93456. * @returns the newly constructed camera
  93457. */
  93458. static Parse(parsedCamera: any, scene: Scene): Camera;
  93459. }
  93460. }
  93461. declare module BABYLON {
  93462. /**
  93463. * Interface for any object that can request an animation frame
  93464. */
  93465. export interface ICustomAnimationFrameRequester {
  93466. /**
  93467. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93468. */
  93469. renderFunction?: Function;
  93470. /**
  93471. * Called to request the next frame to render to
  93472. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93473. */
  93474. requestAnimationFrame: Function;
  93475. /**
  93476. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93477. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93478. */
  93479. requestID?: number;
  93480. }
  93481. /**
  93482. * Interface containing an array of animations
  93483. */
  93484. export interface IAnimatable {
  93485. /**
  93486. * Array of animations
  93487. */
  93488. animations: Nullable<Array<Animation>>;
  93489. }
  93490. /** Interface used by value gradients (color, factor, ...) */
  93491. export interface IValueGradient {
  93492. /**
  93493. * Gets or sets the gradient value (between 0 and 1)
  93494. */
  93495. gradient: number;
  93496. }
  93497. /** Class used to store color4 gradient */
  93498. export class ColorGradient implements IValueGradient {
  93499. /**
  93500. * Gets or sets the gradient value (between 0 and 1)
  93501. */
  93502. gradient: number;
  93503. /**
  93504. * Gets or sets first associated color
  93505. */
  93506. color1: Color4;
  93507. /**
  93508. * Gets or sets second associated color
  93509. */
  93510. color2?: Color4;
  93511. /**
  93512. * Will get a color picked randomly between color1 and color2.
  93513. * If color2 is undefined then color1 will be used
  93514. * @param result defines the target Color4 to store the result in
  93515. */
  93516. getColorToRef(result: Color4): void;
  93517. }
  93518. /** Class used to store color 3 gradient */
  93519. export class Color3Gradient implements IValueGradient {
  93520. /**
  93521. * Gets or sets the gradient value (between 0 and 1)
  93522. */
  93523. gradient: number;
  93524. /**
  93525. * Gets or sets the associated color
  93526. */
  93527. color: Color3;
  93528. }
  93529. /** Class used to store factor gradient */
  93530. export class FactorGradient implements IValueGradient {
  93531. /**
  93532. * Gets or sets the gradient value (between 0 and 1)
  93533. */
  93534. gradient: number;
  93535. /**
  93536. * Gets or sets first associated factor
  93537. */
  93538. factor1: number;
  93539. /**
  93540. * Gets or sets second associated factor
  93541. */
  93542. factor2?: number;
  93543. /**
  93544. * Will get a number picked randomly between factor1 and factor2.
  93545. * If factor2 is undefined then factor1 will be used
  93546. * @returns the picked number
  93547. */
  93548. getFactor(): number;
  93549. }
  93550. /**
  93551. * @ignore
  93552. * Application error to support additional information when loading a file
  93553. */
  93554. export class LoadFileError extends Error {
  93555. /** defines the optional web request */
  93556. request?: WebRequest | undefined;
  93557. private static _setPrototypeOf;
  93558. /**
  93559. * Creates a new LoadFileError
  93560. * @param message defines the message of the error
  93561. * @param request defines the optional web request
  93562. */
  93563. constructor(message: string,
  93564. /** defines the optional web request */
  93565. request?: WebRequest | undefined);
  93566. }
  93567. /**
  93568. * Class used to define a retry strategy when error happens while loading assets
  93569. */
  93570. export class RetryStrategy {
  93571. /**
  93572. * Function used to defines an exponential back off strategy
  93573. * @param maxRetries defines the maximum number of retries (3 by default)
  93574. * @param baseInterval defines the interval between retries
  93575. * @returns the strategy function to use
  93576. */
  93577. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93578. }
  93579. /**
  93580. * File request interface
  93581. */
  93582. export interface IFileRequest {
  93583. /**
  93584. * Raised when the request is complete (success or error).
  93585. */
  93586. onCompleteObservable: Observable<IFileRequest>;
  93587. /**
  93588. * Aborts the request for a file.
  93589. */
  93590. abort: () => void;
  93591. }
  93592. /**
  93593. * Class containing a set of static utilities functions
  93594. */
  93595. export class Tools {
  93596. /**
  93597. * Gets or sets the base URL to use to load assets
  93598. */
  93599. static BaseUrl: string;
  93600. /**
  93601. * Enable/Disable Custom HTTP Request Headers globally.
  93602. * default = false
  93603. * @see CustomRequestHeaders
  93604. */
  93605. static UseCustomRequestHeaders: boolean;
  93606. /**
  93607. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93608. * i.e. when loading files, where the server/service expects an Authorization header
  93609. */
  93610. static CustomRequestHeaders: {
  93611. [key: string]: string;
  93612. };
  93613. /**
  93614. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93615. */
  93616. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93617. /**
  93618. * Default behaviour for cors in the application.
  93619. * It can be a string if the expected behavior is identical in the entire app.
  93620. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93621. */
  93622. static CorsBehavior: string | ((url: string | string[]) => string);
  93623. /**
  93624. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93625. * @ignorenaming
  93626. */
  93627. static UseFallbackTexture: boolean;
  93628. /**
  93629. * Use this object to register external classes like custom textures or material
  93630. * to allow the laoders to instantiate them
  93631. */
  93632. static RegisteredExternalClasses: {
  93633. [key: string]: Object;
  93634. };
  93635. /**
  93636. * Texture content used if a texture cannot loaded
  93637. * @ignorenaming
  93638. */
  93639. static fallbackTexture: string;
  93640. /**
  93641. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93642. * @param u defines the coordinate on X axis
  93643. * @param v defines the coordinate on Y axis
  93644. * @param width defines the width of the source data
  93645. * @param height defines the height of the source data
  93646. * @param pixels defines the source byte array
  93647. * @param color defines the output color
  93648. */
  93649. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93650. /**
  93651. * Interpolates between a and b via alpha
  93652. * @param a The lower value (returned when alpha = 0)
  93653. * @param b The upper value (returned when alpha = 1)
  93654. * @param alpha The interpolation-factor
  93655. * @return The mixed value
  93656. */
  93657. static Mix(a: number, b: number, alpha: number): number;
  93658. /**
  93659. * Tries to instantiate a new object from a given class name
  93660. * @param className defines the class name to instantiate
  93661. * @returns the new object or null if the system was not able to do the instantiation
  93662. */
  93663. static Instantiate(className: string): any;
  93664. /**
  93665. * Provides a slice function that will work even on IE
  93666. * @param data defines the array to slice
  93667. * @param start defines the start of the data (optional)
  93668. * @param end defines the end of the data (optional)
  93669. * @returns the new sliced array
  93670. */
  93671. static Slice<T>(data: T, start?: number, end?: number): T;
  93672. /**
  93673. * Polyfill for setImmediate
  93674. * @param action defines the action to execute after the current execution block
  93675. */
  93676. static SetImmediate(action: () => void): void;
  93677. /**
  93678. * Function indicating if a number is an exponent of 2
  93679. * @param value defines the value to test
  93680. * @returns true if the value is an exponent of 2
  93681. */
  93682. static IsExponentOfTwo(value: number): boolean;
  93683. private static _tmpFloatArray;
  93684. /**
  93685. * Returns the nearest 32-bit single precision float representation of a Number
  93686. * @param value A Number. If the parameter is of a different type, it will get converted
  93687. * to a number or to NaN if it cannot be converted
  93688. * @returns number
  93689. */
  93690. static FloatRound(value: number): number;
  93691. /**
  93692. * Find the next highest power of two.
  93693. * @param x Number to start search from.
  93694. * @return Next highest power of two.
  93695. */
  93696. static CeilingPOT(x: number): number;
  93697. /**
  93698. * Find the next lowest power of two.
  93699. * @param x Number to start search from.
  93700. * @return Next lowest power of two.
  93701. */
  93702. static FloorPOT(x: number): number;
  93703. /**
  93704. * Find the nearest power of two.
  93705. * @param x Number to start search from.
  93706. * @return Next nearest power of two.
  93707. */
  93708. static NearestPOT(x: number): number;
  93709. /**
  93710. * Get the closest exponent of two
  93711. * @param value defines the value to approximate
  93712. * @param max defines the maximum value to return
  93713. * @param mode defines how to define the closest value
  93714. * @returns closest exponent of two of the given value
  93715. */
  93716. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93717. /**
  93718. * Extracts the filename from a path
  93719. * @param path defines the path to use
  93720. * @returns the filename
  93721. */
  93722. static GetFilename(path: string): string;
  93723. /**
  93724. * Extracts the "folder" part of a path (everything before the filename).
  93725. * @param uri The URI to extract the info from
  93726. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93727. * @returns The "folder" part of the path
  93728. */
  93729. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93730. /**
  93731. * Extracts text content from a DOM element hierarchy
  93732. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93733. */
  93734. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93735. /**
  93736. * Convert an angle in radians to degrees
  93737. * @param angle defines the angle to convert
  93738. * @returns the angle in degrees
  93739. */
  93740. static ToDegrees(angle: number): number;
  93741. /**
  93742. * Convert an angle in degrees to radians
  93743. * @param angle defines the angle to convert
  93744. * @returns the angle in radians
  93745. */
  93746. static ToRadians(angle: number): number;
  93747. /**
  93748. * Encode a buffer to a base64 string
  93749. * @param buffer defines the buffer to encode
  93750. * @returns the encoded string
  93751. */
  93752. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93753. /**
  93754. * Extracts minimum and maximum values from a list of indexed positions
  93755. * @param positions defines the positions to use
  93756. * @param indices defines the indices to the positions
  93757. * @param indexStart defines the start index
  93758. * @param indexCount defines the end index
  93759. * @param bias defines bias value to add to the result
  93760. * @return minimum and maximum values
  93761. */
  93762. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93763. minimum: Vector3;
  93764. maximum: Vector3;
  93765. };
  93766. /**
  93767. * Extracts minimum and maximum values from a list of positions
  93768. * @param positions defines the positions to use
  93769. * @param start defines the start index in the positions array
  93770. * @param count defines the number of positions to handle
  93771. * @param bias defines bias value to add to the result
  93772. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93773. * @return minimum and maximum values
  93774. */
  93775. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93776. minimum: Vector3;
  93777. maximum: Vector3;
  93778. };
  93779. /**
  93780. * Returns an array if obj is not an array
  93781. * @param obj defines the object to evaluate as an array
  93782. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93783. * @returns either obj directly if obj is an array or a new array containing obj
  93784. */
  93785. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93786. /**
  93787. * Gets the pointer prefix to use
  93788. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93789. */
  93790. static GetPointerPrefix(): string;
  93791. /**
  93792. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93793. * @param func - the function to be called
  93794. * @param requester - the object that will request the next frame. Falls back to window.
  93795. * @returns frame number
  93796. */
  93797. static QueueNewFrame(func: () => void, requester?: any): number;
  93798. /**
  93799. * Ask the browser to promote the current element to fullscreen rendering mode
  93800. * @param element defines the DOM element to promote
  93801. */
  93802. static RequestFullscreen(element: HTMLElement): void;
  93803. /**
  93804. * Asks the browser to exit fullscreen mode
  93805. */
  93806. static ExitFullscreen(): void;
  93807. /**
  93808. * Ask the browser to promote the current element to pointerlock mode
  93809. * @param element defines the DOM element to promote
  93810. */
  93811. static RequestPointerlock(element: HTMLElement): void;
  93812. /**
  93813. * Asks the browser to exit pointerlock mode
  93814. */
  93815. static ExitPointerlock(): void;
  93816. /**
  93817. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93818. * @param url define the url we are trying
  93819. * @param element define the dom element where to configure the cors policy
  93820. */
  93821. static SetCorsBehavior(url: string | string[], element: {
  93822. crossOrigin: string | null;
  93823. }): void;
  93824. /**
  93825. * Removes unwanted characters from an url
  93826. * @param url defines the url to clean
  93827. * @returns the cleaned url
  93828. */
  93829. static CleanUrl(url: string): string;
  93830. /**
  93831. * Gets or sets a function used to pre-process url before using them to load assets
  93832. */
  93833. static PreprocessUrl: (url: string) => string;
  93834. /**
  93835. * Loads an image as an HTMLImageElement.
  93836. * @param input url string, ArrayBuffer, or Blob to load
  93837. * @param onLoad callback called when the image successfully loads
  93838. * @param onError callback called when the image fails to load
  93839. * @param offlineProvider offline provider for caching
  93840. * @returns the HTMLImageElement of the loaded image
  93841. */
  93842. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93843. /**
  93844. * Loads a file
  93845. * @param url url string, ArrayBuffer, or Blob to load
  93846. * @param onSuccess callback called when the file successfully loads
  93847. * @param onProgress callback called while file is loading (if the server supports this mode)
  93848. * @param offlineProvider defines the offline provider for caching
  93849. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  93850. * @param onError callback called when the file fails to load
  93851. * @returns a file request object
  93852. */
  93853. 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;
  93854. /**
  93855. * Load a script (identified by an url). When the url returns, the
  93856. * content of this file is added into a new script element, attached to the DOM (body element)
  93857. * @param scriptUrl defines the url of the script to laod
  93858. * @param onSuccess defines the callback called when the script is loaded
  93859. * @param onError defines the callback to call if an error occurs
  93860. * @param scriptId defines the id of the script element
  93861. */
  93862. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  93863. /**
  93864. * Load an asynchronous script (identified by an url). When the url returns, the
  93865. * content of this file is added into a new script element, attached to the DOM (body element)
  93866. * @param scriptUrl defines the url of the script to laod
  93867. * @param scriptId defines the id of the script element
  93868. * @returns a promise request object
  93869. */
  93870. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  93871. /**
  93872. * Loads a file from a blob
  93873. * @param fileToLoad defines the blob to use
  93874. * @param callback defines the callback to call when data is loaded
  93875. * @param progressCallback defines the callback to call during loading process
  93876. * @returns a file request object
  93877. */
  93878. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  93879. /**
  93880. * Loads a file
  93881. * @param fileToLoad defines the file to load
  93882. * @param callback defines the callback to call when data is loaded
  93883. * @param progressCallBack defines the callback to call during loading process
  93884. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  93885. * @returns a file request object
  93886. */
  93887. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  93888. /**
  93889. * Creates a data url from a given string content
  93890. * @param content defines the content to convert
  93891. * @returns the new data url link
  93892. */
  93893. static FileAsURL(content: string): string;
  93894. /**
  93895. * Format the given number to a specific decimal format
  93896. * @param value defines the number to format
  93897. * @param decimals defines the number of decimals to use
  93898. * @returns the formatted string
  93899. */
  93900. static Format(value: number, decimals?: number): string;
  93901. /**
  93902. * Checks if a given vector is inside a specific range
  93903. * @param v defines the vector to test
  93904. * @param min defines the minimum range
  93905. * @param max defines the maximum range
  93906. */
  93907. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  93908. /**
  93909. * Tries to copy an object by duplicating every property
  93910. * @param source defines the source object
  93911. * @param destination defines the target object
  93912. * @param doNotCopyList defines a list of properties to avoid
  93913. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93914. */
  93915. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  93916. /**
  93917. * Gets a boolean indicating if the given object has no own property
  93918. * @param obj defines the object to test
  93919. * @returns true if object has no own property
  93920. */
  93921. static IsEmpty(obj: any): boolean;
  93922. /**
  93923. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  93924. * @param str Source string
  93925. * @param suffix Suffix to search for in the source string
  93926. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  93927. */
  93928. static EndsWith(str: string, suffix: string): boolean;
  93929. /**
  93930. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  93931. * @param str Source string
  93932. * @param suffix Suffix to search for in the source string
  93933. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  93934. */
  93935. static StartsWith(str: string, suffix: string): boolean;
  93936. /**
  93937. * Function used to register events at window level
  93938. * @param events defines the events to register
  93939. */
  93940. static RegisterTopRootEvents(events: {
  93941. name: string;
  93942. handler: Nullable<(e: FocusEvent) => any>;
  93943. }[]): void;
  93944. /**
  93945. * Function used to unregister events from window level
  93946. * @param events defines the events to unregister
  93947. */
  93948. static UnregisterTopRootEvents(events: {
  93949. name: string;
  93950. handler: Nullable<(e: FocusEvent) => any>;
  93951. }[]): void;
  93952. /**
  93953. * @ignore
  93954. */
  93955. static _ScreenshotCanvas: HTMLCanvasElement;
  93956. /**
  93957. * Dumps the current bound framebuffer
  93958. * @param width defines the rendering width
  93959. * @param height defines the rendering height
  93960. * @param engine defines the hosting engine
  93961. * @param successCallback defines the callback triggered once the data are available
  93962. * @param mimeType defines the mime type of the result
  93963. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  93964. */
  93965. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93966. /**
  93967. * Converts the canvas data to blob.
  93968. * This acts as a polyfill for browsers not supporting the to blob function.
  93969. * @param canvas Defines the canvas to extract the data from
  93970. * @param successCallback Defines the callback triggered once the data are available
  93971. * @param mimeType Defines the mime type of the result
  93972. */
  93973. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  93974. /**
  93975. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  93976. * @param successCallback defines the callback triggered once the data are available
  93977. * @param mimeType defines the mime type of the result
  93978. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  93979. */
  93980. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93981. /**
  93982. * Downloads a blob in the browser
  93983. * @param blob defines the blob to download
  93984. * @param fileName defines the name of the downloaded file
  93985. */
  93986. static Download(blob: Blob, fileName: string): void;
  93987. /**
  93988. * Captures a screenshot of the current rendering
  93989. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93990. * @param engine defines the rendering engine
  93991. * @param camera defines the source camera
  93992. * @param size This parameter can be set to a single number or to an object with the
  93993. * following (optional) properties: precision, width, height. If a single number is passed,
  93994. * it will be used for both width and height. If an object is passed, the screenshot size
  93995. * will be derived from the parameters. The precision property is a multiplier allowing
  93996. * rendering at a higher or lower resolution
  93997. * @param successCallback defines the callback receives a single parameter which contains the
  93998. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93999. * src parameter of an <img> to display it
  94000. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94001. * Check your browser for supported MIME types
  94002. */
  94003. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94004. /**
  94005. * Generates an image screenshot from the specified camera.
  94006. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94007. * @param engine The engine to use for rendering
  94008. * @param camera The camera to use for rendering
  94009. * @param size This parameter can be set to a single number or to an object with the
  94010. * following (optional) properties: precision, width, height. If a single number is passed,
  94011. * it will be used for both width and height. If an object is passed, the screenshot size
  94012. * will be derived from the parameters. The precision property is a multiplier allowing
  94013. * rendering at a higher or lower resolution
  94014. * @param successCallback The callback receives a single parameter which contains the
  94015. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94016. * src parameter of an <img> to display it
  94017. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94018. * Check your browser for supported MIME types
  94019. * @param samples Texture samples (default: 1)
  94020. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94021. * @param fileName A name for for the downloaded file.
  94022. */
  94023. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94024. /**
  94025. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94026. * Be aware Math.random() could cause collisions, but:
  94027. * "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"
  94028. * @returns a pseudo random id
  94029. */
  94030. static RandomId(): string;
  94031. /**
  94032. * Test if the given uri is a base64 string
  94033. * @param uri The uri to test
  94034. * @return True if the uri is a base64 string or false otherwise
  94035. */
  94036. static IsBase64(uri: string): boolean;
  94037. /**
  94038. * Decode the given base64 uri.
  94039. * @param uri The uri to decode
  94040. * @return The decoded base64 data.
  94041. */
  94042. static DecodeBase64(uri: string): ArrayBuffer;
  94043. /**
  94044. * Gets the absolute url.
  94045. * @param url the input url
  94046. * @return the absolute url
  94047. */
  94048. static GetAbsoluteUrl(url: string): string;
  94049. /**
  94050. * No log
  94051. */
  94052. static readonly NoneLogLevel: number;
  94053. /**
  94054. * Only message logs
  94055. */
  94056. static readonly MessageLogLevel: number;
  94057. /**
  94058. * Only warning logs
  94059. */
  94060. static readonly WarningLogLevel: number;
  94061. /**
  94062. * Only error logs
  94063. */
  94064. static readonly ErrorLogLevel: number;
  94065. /**
  94066. * All logs
  94067. */
  94068. static readonly AllLogLevel: number;
  94069. /**
  94070. * Gets a value indicating the number of loading errors
  94071. * @ignorenaming
  94072. */
  94073. static readonly errorsCount: number;
  94074. /**
  94075. * Callback called when a new log is added
  94076. */
  94077. static OnNewCacheEntry: (entry: string) => void;
  94078. /**
  94079. * Log a message to the console
  94080. * @param message defines the message to log
  94081. */
  94082. static Log(message: string): void;
  94083. /**
  94084. * Write a warning message to the console
  94085. * @param message defines the message to log
  94086. */
  94087. static Warn(message: string): void;
  94088. /**
  94089. * Write an error message to the console
  94090. * @param message defines the message to log
  94091. */
  94092. static Error(message: string): void;
  94093. /**
  94094. * Gets current log cache (list of logs)
  94095. */
  94096. static readonly LogCache: string;
  94097. /**
  94098. * Clears the log cache
  94099. */
  94100. static ClearLogCache(): void;
  94101. /**
  94102. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94103. */
  94104. static LogLevels: number;
  94105. /**
  94106. * Checks if the loaded document was accessed via `file:`-Protocol.
  94107. * @returns boolean
  94108. */
  94109. static IsFileURL(): boolean;
  94110. /**
  94111. * Checks if the window object exists
  94112. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94113. */
  94114. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94115. /**
  94116. * No performance log
  94117. */
  94118. static readonly PerformanceNoneLogLevel: number;
  94119. /**
  94120. * Use user marks to log performance
  94121. */
  94122. static readonly PerformanceUserMarkLogLevel: number;
  94123. /**
  94124. * Log performance to the console
  94125. */
  94126. static readonly PerformanceConsoleLogLevel: number;
  94127. private static _performance;
  94128. /**
  94129. * Sets the current performance log level
  94130. */
  94131. static PerformanceLogLevel: number;
  94132. private static _StartPerformanceCounterDisabled;
  94133. private static _EndPerformanceCounterDisabled;
  94134. private static _StartUserMark;
  94135. private static _EndUserMark;
  94136. private static _StartPerformanceConsole;
  94137. private static _EndPerformanceConsole;
  94138. /**
  94139. * Starts a performance counter
  94140. */
  94141. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94142. /**
  94143. * Ends a specific performance coutner
  94144. */
  94145. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94146. /**
  94147. * Gets either window.performance.now() if supported or Date.now() else
  94148. */
  94149. static readonly Now: number;
  94150. /**
  94151. * This method will return the name of the class used to create the instance of the given object.
  94152. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94153. * @param object the object to get the class name from
  94154. * @param isType defines if the object is actually a type
  94155. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94156. */
  94157. static GetClassName(object: any, isType?: boolean): string;
  94158. /**
  94159. * Gets the first element of an array satisfying a given predicate
  94160. * @param array defines the array to browse
  94161. * @param predicate defines the predicate to use
  94162. * @returns null if not found or the element
  94163. */
  94164. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94165. /**
  94166. * This method will return the name of the full name of the class, including its owning module (if any).
  94167. * 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).
  94168. * @param object the object to get the class name from
  94169. * @param isType defines if the object is actually a type
  94170. * @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.
  94171. * @ignorenaming
  94172. */
  94173. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94174. /**
  94175. * Returns a promise that resolves after the given amount of time.
  94176. * @param delay Number of milliseconds to delay
  94177. * @returns Promise that resolves after the given amount of time
  94178. */
  94179. static DelayAsync(delay: number): Promise<void>;
  94180. /**
  94181. * Gets the current gradient from an array of IValueGradient
  94182. * @param ratio defines the current ratio to get
  94183. * @param gradients defines the array of IValueGradient
  94184. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94185. */
  94186. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94187. }
  94188. /**
  94189. * This class is used to track a performance counter which is number based.
  94190. * The user has access to many properties which give statistics of different nature.
  94191. *
  94192. * The implementer can track two kinds of Performance Counter: time and count.
  94193. * 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.
  94194. * 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.
  94195. */
  94196. export class PerfCounter {
  94197. /**
  94198. * Gets or sets a global boolean to turn on and off all the counters
  94199. */
  94200. static Enabled: boolean;
  94201. /**
  94202. * Returns the smallest value ever
  94203. */
  94204. readonly min: number;
  94205. /**
  94206. * Returns the biggest value ever
  94207. */
  94208. readonly max: number;
  94209. /**
  94210. * Returns the average value since the performance counter is running
  94211. */
  94212. readonly average: number;
  94213. /**
  94214. * Returns the average value of the last second the counter was monitored
  94215. */
  94216. readonly lastSecAverage: number;
  94217. /**
  94218. * Returns the current value
  94219. */
  94220. readonly current: number;
  94221. /**
  94222. * Gets the accumulated total
  94223. */
  94224. readonly total: number;
  94225. /**
  94226. * Gets the total value count
  94227. */
  94228. readonly count: number;
  94229. /**
  94230. * Creates a new counter
  94231. */
  94232. constructor();
  94233. /**
  94234. * Call this method to start monitoring a new frame.
  94235. * 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.
  94236. */
  94237. fetchNewFrame(): void;
  94238. /**
  94239. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94240. * @param newCount the count value to add to the monitored count
  94241. * @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.
  94242. */
  94243. addCount(newCount: number, fetchResult: boolean): void;
  94244. /**
  94245. * Start monitoring this performance counter
  94246. */
  94247. beginMonitoring(): void;
  94248. /**
  94249. * Compute the time lapsed since the previous beginMonitoring() call.
  94250. * @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
  94251. */
  94252. endMonitoring(newFrame?: boolean): void;
  94253. private _fetchResult;
  94254. private _startMonitoringTime;
  94255. private _min;
  94256. private _max;
  94257. private _average;
  94258. private _current;
  94259. private _totalValueCount;
  94260. private _totalAccumulated;
  94261. private _lastSecAverage;
  94262. private _lastSecAccumulated;
  94263. private _lastSecTime;
  94264. private _lastSecValueCount;
  94265. }
  94266. /**
  94267. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94268. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94269. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94270. * @param name The name of the class, case should be preserved
  94271. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94272. */
  94273. export function className(name: string, module?: string): (target: Object) => void;
  94274. /**
  94275. * An implementation of a loop for asynchronous functions.
  94276. */
  94277. export class AsyncLoop {
  94278. /**
  94279. * Defines the number of iterations for the loop
  94280. */
  94281. iterations: number;
  94282. /**
  94283. * Defines the current index of the loop.
  94284. */
  94285. index: number;
  94286. private _done;
  94287. private _fn;
  94288. private _successCallback;
  94289. /**
  94290. * Constructor.
  94291. * @param iterations the number of iterations.
  94292. * @param func the function to run each iteration
  94293. * @param successCallback the callback that will be called upon succesful execution
  94294. * @param offset starting offset.
  94295. */
  94296. constructor(
  94297. /**
  94298. * Defines the number of iterations for the loop
  94299. */
  94300. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94301. /**
  94302. * Execute the next iteration. Must be called after the last iteration was finished.
  94303. */
  94304. executeNext(): void;
  94305. /**
  94306. * Break the loop and run the success callback.
  94307. */
  94308. breakLoop(): void;
  94309. /**
  94310. * Create and run an async loop.
  94311. * @param iterations the number of iterations.
  94312. * @param fn the function to run each iteration
  94313. * @param successCallback the callback that will be called upon succesful execution
  94314. * @param offset starting offset.
  94315. * @returns the created async loop object
  94316. */
  94317. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94318. /**
  94319. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94320. * @param iterations total number of iterations
  94321. * @param syncedIterations number of synchronous iterations in each async iteration.
  94322. * @param fn the function to call each iteration.
  94323. * @param callback a success call back that will be called when iterating stops.
  94324. * @param breakFunction a break condition (optional)
  94325. * @param timeout timeout settings for the setTimeout function. default - 0.
  94326. * @returns the created async loop object
  94327. */
  94328. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94329. }
  94330. }
  94331. declare module BABYLON {
  94332. /** @hidden */
  94333. export interface ICollisionCoordinator {
  94334. createCollider(): Collider;
  94335. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94336. init(scene: Scene): void;
  94337. }
  94338. /** @hidden */
  94339. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94340. private _scene;
  94341. private _scaledPosition;
  94342. private _scaledVelocity;
  94343. private _finalPosition;
  94344. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94345. createCollider(): Collider;
  94346. init(scene: Scene): void;
  94347. private _collideWithWorld;
  94348. }
  94349. }
  94350. declare module BABYLON {
  94351. /**
  94352. * Class used to manage all inputs for the scene.
  94353. */
  94354. export class InputManager {
  94355. /** The distance in pixel that you have to move to prevent some events */
  94356. static DragMovementThreshold: number;
  94357. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94358. static LongPressDelay: number;
  94359. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94360. static DoubleClickDelay: number;
  94361. /** If you need to check double click without raising a single click at first click, enable this flag */
  94362. static ExclusiveDoubleClickMode: boolean;
  94363. private _wheelEventName;
  94364. private _onPointerMove;
  94365. private _onPointerDown;
  94366. private _onPointerUp;
  94367. private _initClickEvent;
  94368. private _initActionManager;
  94369. private _delayedSimpleClick;
  94370. private _delayedSimpleClickTimeout;
  94371. private _previousDelayedSimpleClickTimeout;
  94372. private _meshPickProceed;
  94373. private _previousButtonPressed;
  94374. private _currentPickResult;
  94375. private _previousPickResult;
  94376. private _totalPointersPressed;
  94377. private _doubleClickOccured;
  94378. private _pointerOverMesh;
  94379. private _pickedDownMesh;
  94380. private _pickedUpMesh;
  94381. private _pointerX;
  94382. private _pointerY;
  94383. private _unTranslatedPointerX;
  94384. private _unTranslatedPointerY;
  94385. private _startingPointerPosition;
  94386. private _previousStartingPointerPosition;
  94387. private _startingPointerTime;
  94388. private _previousStartingPointerTime;
  94389. private _pointerCaptures;
  94390. private _onKeyDown;
  94391. private _onKeyUp;
  94392. private _onCanvasFocusObserver;
  94393. private _onCanvasBlurObserver;
  94394. private _scene;
  94395. /**
  94396. * Creates a new InputManager
  94397. * @param scene defines the hosting scene
  94398. */
  94399. constructor(scene: Scene);
  94400. /**
  94401. * Gets the mesh that is currently under the pointer
  94402. */
  94403. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94404. /**
  94405. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94406. */
  94407. readonly unTranslatedPointer: Vector2;
  94408. /**
  94409. * Gets or sets the current on-screen X position of the pointer
  94410. */
  94411. pointerX: number;
  94412. /**
  94413. * Gets or sets the current on-screen Y position of the pointer
  94414. */
  94415. pointerY: number;
  94416. private _updatePointerPosition;
  94417. private _processPointerMove;
  94418. private _setRayOnPointerInfo;
  94419. private _checkPrePointerObservable;
  94420. /**
  94421. * Use this method to simulate a pointer move on a mesh
  94422. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94423. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94424. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94425. */
  94426. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94427. /**
  94428. * Use this method to simulate a pointer down on a mesh
  94429. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94430. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94431. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94432. */
  94433. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94434. private _processPointerDown;
  94435. /** @hidden */
  94436. _isPointerSwiping(): boolean;
  94437. /**
  94438. * Use this method to simulate a pointer up on a mesh
  94439. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94440. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94441. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94442. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94443. */
  94444. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94445. private _processPointerUp;
  94446. /**
  94447. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94448. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94449. * @returns true if the pointer was captured
  94450. */
  94451. isPointerCaptured(pointerId?: number): boolean;
  94452. /**
  94453. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94454. * @param attachUp defines if you want to attach events to pointerup
  94455. * @param attachDown defines if you want to attach events to pointerdown
  94456. * @param attachMove defines if you want to attach events to pointermove
  94457. */
  94458. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94459. /**
  94460. * Detaches all event handlers
  94461. */
  94462. detachControl(): void;
  94463. /**
  94464. * Force the value of meshUnderPointer
  94465. * @param mesh defines the mesh to use
  94466. */
  94467. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94468. /**
  94469. * Gets the mesh under the pointer
  94470. * @returns a Mesh or null if no mesh is under the pointer
  94471. */
  94472. getPointerOverMesh(): Nullable<AbstractMesh>;
  94473. }
  94474. }
  94475. declare module BABYLON {
  94476. /**
  94477. * This class defines the direct association between an animation and a target
  94478. */
  94479. export class TargetedAnimation {
  94480. /**
  94481. * Animation to perform
  94482. */
  94483. animation: Animation;
  94484. /**
  94485. * Target to animate
  94486. */
  94487. target: any;
  94488. /**
  94489. * Serialize the object
  94490. * @returns the JSON object representing the current entity
  94491. */
  94492. serialize(): any;
  94493. }
  94494. /**
  94495. * Use this class to create coordinated animations on multiple targets
  94496. */
  94497. export class AnimationGroup implements IDisposable {
  94498. /** The name of the animation group */
  94499. name: string;
  94500. private _scene;
  94501. private _targetedAnimations;
  94502. private _animatables;
  94503. private _from;
  94504. private _to;
  94505. private _isStarted;
  94506. private _isPaused;
  94507. private _speedRatio;
  94508. private _loopAnimation;
  94509. /**
  94510. * Gets or sets the unique id of the node
  94511. */
  94512. uniqueId: number;
  94513. /**
  94514. * This observable will notify when one animation have ended
  94515. */
  94516. onAnimationEndObservable: Observable<TargetedAnimation>;
  94517. /**
  94518. * Observer raised when one animation loops
  94519. */
  94520. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94521. /**
  94522. * This observable will notify when all animations have ended.
  94523. */
  94524. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94525. /**
  94526. * This observable will notify when all animations have paused.
  94527. */
  94528. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94529. /**
  94530. * This observable will notify when all animations are playing.
  94531. */
  94532. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94533. /**
  94534. * Gets the first frame
  94535. */
  94536. readonly from: number;
  94537. /**
  94538. * Gets the last frame
  94539. */
  94540. readonly to: number;
  94541. /**
  94542. * Define if the animations are started
  94543. */
  94544. readonly isStarted: boolean;
  94545. /**
  94546. * Gets a value indicating that the current group is playing
  94547. */
  94548. readonly isPlaying: boolean;
  94549. /**
  94550. * Gets or sets the speed ratio to use for all animations
  94551. */
  94552. /**
  94553. * Gets or sets the speed ratio to use for all animations
  94554. */
  94555. speedRatio: number;
  94556. /**
  94557. * Gets or sets if all animations should loop or not
  94558. */
  94559. loopAnimation: boolean;
  94560. /**
  94561. * Gets the targeted animations for this animation group
  94562. */
  94563. readonly targetedAnimations: Array<TargetedAnimation>;
  94564. /**
  94565. * returning the list of animatables controlled by this animation group.
  94566. */
  94567. readonly animatables: Array<Animatable>;
  94568. /**
  94569. * Instantiates a new Animation Group.
  94570. * This helps managing several animations at once.
  94571. * @see http://doc.babylonjs.com/how_to/group
  94572. * @param name Defines the name of the group
  94573. * @param scene Defines the scene the group belongs to
  94574. */
  94575. constructor(
  94576. /** The name of the animation group */
  94577. name: string, scene?: Nullable<Scene>);
  94578. /**
  94579. * Add an animation (with its target) in the group
  94580. * @param animation defines the animation we want to add
  94581. * @param target defines the target of the animation
  94582. * @returns the TargetedAnimation object
  94583. */
  94584. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94585. /**
  94586. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94587. * It can add constant keys at begin or end
  94588. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94589. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94590. * @returns the animation group
  94591. */
  94592. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94593. /**
  94594. * Start all animations on given targets
  94595. * @param loop defines if animations must loop
  94596. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94597. * @param from defines the from key (optional)
  94598. * @param to defines the to key (optional)
  94599. * @returns the current animation group
  94600. */
  94601. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94602. /**
  94603. * Pause all animations
  94604. * @returns the animation group
  94605. */
  94606. pause(): AnimationGroup;
  94607. /**
  94608. * Play all animations to initial state
  94609. * This function will start() the animations if they were not started or will restart() them if they were paused
  94610. * @param loop defines if animations must loop
  94611. * @returns the animation group
  94612. */
  94613. play(loop?: boolean): AnimationGroup;
  94614. /**
  94615. * Reset all animations to initial state
  94616. * @returns the animation group
  94617. */
  94618. reset(): AnimationGroup;
  94619. /**
  94620. * Restart animations from key 0
  94621. * @returns the animation group
  94622. */
  94623. restart(): AnimationGroup;
  94624. /**
  94625. * Stop all animations
  94626. * @returns the animation group
  94627. */
  94628. stop(): AnimationGroup;
  94629. /**
  94630. * Set animation weight for all animatables
  94631. * @param weight defines the weight to use
  94632. * @return the animationGroup
  94633. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94634. */
  94635. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94636. /**
  94637. * Synchronize and normalize all animatables with a source animatable
  94638. * @param root defines the root animatable to synchronize with
  94639. * @return the animationGroup
  94640. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94641. */
  94642. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94643. /**
  94644. * Goes to a specific frame in this animation group
  94645. * @param frame the frame number to go to
  94646. * @return the animationGroup
  94647. */
  94648. goToFrame(frame: number): AnimationGroup;
  94649. /**
  94650. * Dispose all associated resources
  94651. */
  94652. dispose(): void;
  94653. private _checkAnimationGroupEnded;
  94654. /**
  94655. * Clone the current animation group and returns a copy
  94656. * @param newName defines the name of the new group
  94657. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94658. * @returns the new aniamtion group
  94659. */
  94660. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94661. /**
  94662. * Serializes the animationGroup to an object
  94663. * @returns Serialized object
  94664. */
  94665. serialize(): any;
  94666. /**
  94667. * Returns a new AnimationGroup object parsed from the source provided.
  94668. * @param parsedAnimationGroup defines the source
  94669. * @param scene defines the scene that will receive the animationGroup
  94670. * @returns a new AnimationGroup
  94671. */
  94672. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94673. /**
  94674. * Returns the string "AnimationGroup"
  94675. * @returns "AnimationGroup"
  94676. */
  94677. getClassName(): string;
  94678. /**
  94679. * Creates a detailled string about the object
  94680. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94681. * @returns a string representing the object
  94682. */
  94683. toString(fullDetails?: boolean): string;
  94684. }
  94685. }
  94686. declare module BABYLON {
  94687. /**
  94688. * Define an interface for all classes that will hold resources
  94689. */
  94690. export interface IDisposable {
  94691. /**
  94692. * Releases all held resources
  94693. */
  94694. dispose(): void;
  94695. }
  94696. /** Interface defining initialization parameters for Scene class */
  94697. export interface SceneOptions {
  94698. /**
  94699. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94700. * It will improve performance when the number of geometries becomes important.
  94701. */
  94702. useGeometryUniqueIdsMap?: boolean;
  94703. /**
  94704. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94705. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94706. */
  94707. useMaterialMeshMap?: boolean;
  94708. /**
  94709. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94710. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94711. */
  94712. useClonedMeshhMap?: boolean;
  94713. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94714. virtual?: boolean;
  94715. }
  94716. /**
  94717. * Represents a scene to be rendered by the engine.
  94718. * @see http://doc.babylonjs.com/features/scene
  94719. */
  94720. export class Scene extends AbstractScene implements IAnimatable {
  94721. private static _uniqueIdCounter;
  94722. /** The fog is deactivated */
  94723. static readonly FOGMODE_NONE: number;
  94724. /** The fog density is following an exponential function */
  94725. static readonly FOGMODE_EXP: number;
  94726. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94727. static readonly FOGMODE_EXP2: number;
  94728. /** The fog density is following a linear function. */
  94729. static readonly FOGMODE_LINEAR: number;
  94730. /**
  94731. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94732. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94733. */
  94734. static MinDeltaTime: number;
  94735. /**
  94736. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94737. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94738. */
  94739. static MaxDeltaTime: number;
  94740. /**
  94741. * Factory used to create the default material.
  94742. * @param name The name of the material to create
  94743. * @param scene The scene to create the material for
  94744. * @returns The default material
  94745. */
  94746. static DefaultMaterialFactory(scene: Scene): Material;
  94747. /**
  94748. * Factory used to create the a collision coordinator.
  94749. * @returns The collision coordinator
  94750. */
  94751. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94752. /** @hidden */
  94753. _inputManager: InputManager;
  94754. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94755. cameraToUseForPointers: Nullable<Camera>;
  94756. /** @hidden */
  94757. readonly _isScene: boolean;
  94758. /**
  94759. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94760. */
  94761. autoClear: boolean;
  94762. /**
  94763. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94764. */
  94765. autoClearDepthAndStencil: boolean;
  94766. /**
  94767. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94768. */
  94769. clearColor: Color4;
  94770. /**
  94771. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94772. */
  94773. ambientColor: Color3;
  94774. /**
  94775. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94776. * It should only be one of the following (if not the default embedded one):
  94777. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94778. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94779. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94780. * The material properties need to be setup according to the type of texture in use.
  94781. */
  94782. environmentBRDFTexture: BaseTexture;
  94783. /** @hidden */
  94784. protected _environmentTexture: Nullable<BaseTexture>;
  94785. /**
  94786. * Texture used in all pbr material as the reflection texture.
  94787. * As in the majority of the scene they are the same (exception for multi room and so on),
  94788. * this is easier to reference from here than from all the materials.
  94789. */
  94790. /**
  94791. * Texture used in all pbr material as the reflection texture.
  94792. * As in the majority of the scene they are the same (exception for multi room and so on),
  94793. * this is easier to set here than in all the materials.
  94794. */
  94795. environmentTexture: Nullable<BaseTexture>;
  94796. /** @hidden */
  94797. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94798. /**
  94799. * Default image processing configuration used either in the rendering
  94800. * Forward main pass or through the imageProcessingPostProcess if present.
  94801. * As in the majority of the scene they are the same (exception for multi camera),
  94802. * this is easier to reference from here than from all the materials and post process.
  94803. *
  94804. * No setter as we it is a shared configuration, you can set the values instead.
  94805. */
  94806. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94807. private _forceWireframe;
  94808. /**
  94809. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94810. */
  94811. forceWireframe: boolean;
  94812. private _forcePointsCloud;
  94813. /**
  94814. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94815. */
  94816. forcePointsCloud: boolean;
  94817. /**
  94818. * Gets or sets the active clipplane 1
  94819. */
  94820. clipPlane: Nullable<Plane>;
  94821. /**
  94822. * Gets or sets the active clipplane 2
  94823. */
  94824. clipPlane2: Nullable<Plane>;
  94825. /**
  94826. * Gets or sets the active clipplane 3
  94827. */
  94828. clipPlane3: Nullable<Plane>;
  94829. /**
  94830. * Gets or sets the active clipplane 4
  94831. */
  94832. clipPlane4: Nullable<Plane>;
  94833. /**
  94834. * Gets or sets a boolean indicating if animations are enabled
  94835. */
  94836. animationsEnabled: boolean;
  94837. private _animationPropertiesOverride;
  94838. /**
  94839. * Gets or sets the animation properties override
  94840. */
  94841. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94842. /**
  94843. * Gets or sets a boolean indicating if a constant deltatime has to be used
  94844. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  94845. */
  94846. useConstantAnimationDeltaTime: boolean;
  94847. /**
  94848. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  94849. * Please note that it requires to run a ray cast through the scene on every frame
  94850. */
  94851. constantlyUpdateMeshUnderPointer: boolean;
  94852. /**
  94853. * Defines the HTML cursor to use when hovering over interactive elements
  94854. */
  94855. hoverCursor: string;
  94856. /**
  94857. * Defines the HTML default cursor to use (empty by default)
  94858. */
  94859. defaultCursor: string;
  94860. /**
  94861. * This is used to call preventDefault() on pointer down
  94862. * in order to block unwanted artifacts like system double clicks
  94863. */
  94864. preventDefaultOnPointerDown: boolean;
  94865. /**
  94866. * This is used to call preventDefault() on pointer up
  94867. * in order to block unwanted artifacts like system double clicks
  94868. */
  94869. preventDefaultOnPointerUp: boolean;
  94870. /**
  94871. * Gets or sets user defined metadata
  94872. */
  94873. metadata: any;
  94874. /**
  94875. * For internal use only. Please do not use.
  94876. */
  94877. reservedDataStore: any;
  94878. /**
  94879. * Gets the name of the plugin used to load this scene (null by default)
  94880. */
  94881. loadingPluginName: string;
  94882. /**
  94883. * Use this array to add regular expressions used to disable offline support for specific urls
  94884. */
  94885. disableOfflineSupportExceptionRules: RegExp[];
  94886. /**
  94887. * An event triggered when the scene is disposed.
  94888. */
  94889. onDisposeObservable: Observable<Scene>;
  94890. private _onDisposeObserver;
  94891. /** Sets a function to be executed when this scene is disposed. */
  94892. onDispose: () => void;
  94893. /**
  94894. * An event triggered before rendering the scene (right after animations and physics)
  94895. */
  94896. onBeforeRenderObservable: Observable<Scene>;
  94897. private _onBeforeRenderObserver;
  94898. /** Sets a function to be executed before rendering this scene */
  94899. beforeRender: Nullable<() => void>;
  94900. /**
  94901. * An event triggered after rendering the scene
  94902. */
  94903. onAfterRenderObservable: Observable<Scene>;
  94904. /**
  94905. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  94906. */
  94907. onAfterRenderCameraObservable: Observable<Camera>;
  94908. private _onAfterRenderObserver;
  94909. /** Sets a function to be executed after rendering this scene */
  94910. afterRender: Nullable<() => void>;
  94911. /**
  94912. * An event triggered before animating the scene
  94913. */
  94914. onBeforeAnimationsObservable: Observable<Scene>;
  94915. /**
  94916. * An event triggered after animations processing
  94917. */
  94918. onAfterAnimationsObservable: Observable<Scene>;
  94919. /**
  94920. * An event triggered before draw calls are ready to be sent
  94921. */
  94922. onBeforeDrawPhaseObservable: Observable<Scene>;
  94923. /**
  94924. * An event triggered after draw calls have been sent
  94925. */
  94926. onAfterDrawPhaseObservable: Observable<Scene>;
  94927. /**
  94928. * An event triggered when the scene is ready
  94929. */
  94930. onReadyObservable: Observable<Scene>;
  94931. /**
  94932. * An event triggered before rendering a camera
  94933. */
  94934. onBeforeCameraRenderObservable: Observable<Camera>;
  94935. private _onBeforeCameraRenderObserver;
  94936. /** Sets a function to be executed before rendering a camera*/
  94937. beforeCameraRender: () => void;
  94938. /**
  94939. * An event triggered after rendering a camera
  94940. */
  94941. onAfterCameraRenderObservable: Observable<Camera>;
  94942. private _onAfterCameraRenderObserver;
  94943. /** Sets a function to be executed after rendering a camera*/
  94944. afterCameraRender: () => void;
  94945. /**
  94946. * An event triggered when active meshes evaluation is about to start
  94947. */
  94948. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  94949. /**
  94950. * An event triggered when active meshes evaluation is done
  94951. */
  94952. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  94953. /**
  94954. * An event triggered when particles rendering is about to start
  94955. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94956. */
  94957. onBeforeParticlesRenderingObservable: Observable<Scene>;
  94958. /**
  94959. * An event triggered when particles rendering is done
  94960. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94961. */
  94962. onAfterParticlesRenderingObservable: Observable<Scene>;
  94963. /**
  94964. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  94965. */
  94966. onDataLoadedObservable: Observable<Scene>;
  94967. /**
  94968. * An event triggered when a camera is created
  94969. */
  94970. onNewCameraAddedObservable: Observable<Camera>;
  94971. /**
  94972. * An event triggered when a camera is removed
  94973. */
  94974. onCameraRemovedObservable: Observable<Camera>;
  94975. /**
  94976. * An event triggered when a light is created
  94977. */
  94978. onNewLightAddedObservable: Observable<Light>;
  94979. /**
  94980. * An event triggered when a light is removed
  94981. */
  94982. onLightRemovedObservable: Observable<Light>;
  94983. /**
  94984. * An event triggered when a geometry is created
  94985. */
  94986. onNewGeometryAddedObservable: Observable<Geometry>;
  94987. /**
  94988. * An event triggered when a geometry is removed
  94989. */
  94990. onGeometryRemovedObservable: Observable<Geometry>;
  94991. /**
  94992. * An event triggered when a transform node is created
  94993. */
  94994. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  94995. /**
  94996. * An event triggered when a transform node is removed
  94997. */
  94998. onTransformNodeRemovedObservable: Observable<TransformNode>;
  94999. /**
  95000. * An event triggered when a mesh is created
  95001. */
  95002. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95003. /**
  95004. * An event triggered when a mesh is removed
  95005. */
  95006. onMeshRemovedObservable: Observable<AbstractMesh>;
  95007. /**
  95008. * An event triggered when a skeleton is created
  95009. */
  95010. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95011. /**
  95012. * An event triggered when a skeleton is removed
  95013. */
  95014. onSkeletonRemovedObservable: Observable<Skeleton>;
  95015. /**
  95016. * An event triggered when a material is created
  95017. */
  95018. onNewMaterialAddedObservable: Observable<Material>;
  95019. /**
  95020. * An event triggered when a material is removed
  95021. */
  95022. onMaterialRemovedObservable: Observable<Material>;
  95023. /**
  95024. * An event triggered when a texture is created
  95025. */
  95026. onNewTextureAddedObservable: Observable<BaseTexture>;
  95027. /**
  95028. * An event triggered when a texture is removed
  95029. */
  95030. onTextureRemovedObservable: Observable<BaseTexture>;
  95031. /**
  95032. * An event triggered when render targets are about to be rendered
  95033. * Can happen multiple times per frame.
  95034. */
  95035. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95036. /**
  95037. * An event triggered when render targets were rendered.
  95038. * Can happen multiple times per frame.
  95039. */
  95040. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95041. /**
  95042. * An event triggered before calculating deterministic simulation step
  95043. */
  95044. onBeforeStepObservable: Observable<Scene>;
  95045. /**
  95046. * An event triggered after calculating deterministic simulation step
  95047. */
  95048. onAfterStepObservable: Observable<Scene>;
  95049. /**
  95050. * An event triggered when the activeCamera property is updated
  95051. */
  95052. onActiveCameraChanged: Observable<Scene>;
  95053. /**
  95054. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95055. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95056. * 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)
  95057. */
  95058. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95059. /**
  95060. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95061. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95062. * 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)
  95063. */
  95064. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95065. /**
  95066. * This Observable will when a mesh has been imported into the scene.
  95067. */
  95068. onMeshImportedObservable: Observable<AbstractMesh>;
  95069. /**
  95070. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95071. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95072. */
  95073. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95074. /** @hidden */
  95075. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95076. /**
  95077. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95078. */
  95079. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95080. /**
  95081. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95082. */
  95083. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95084. /**
  95085. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95086. */
  95087. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95088. /** Callback called when a pointer move is detected */
  95089. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95090. /** Callback called when a pointer down is detected */
  95091. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95092. /** Callback called when a pointer up is detected */
  95093. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95094. /** Callback called when a pointer pick is detected */
  95095. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95096. /**
  95097. * 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).
  95098. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95099. */
  95100. onPrePointerObservable: Observable<PointerInfoPre>;
  95101. /**
  95102. * Observable event triggered each time an input event is received from the rendering canvas
  95103. */
  95104. onPointerObservable: Observable<PointerInfo>;
  95105. /**
  95106. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95107. */
  95108. readonly unTranslatedPointer: Vector2;
  95109. /**
  95110. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95111. */
  95112. static DragMovementThreshold: number;
  95113. /**
  95114. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95115. */
  95116. static LongPressDelay: number;
  95117. /**
  95118. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95119. */
  95120. static DoubleClickDelay: number;
  95121. /** If you need to check double click without raising a single click at first click, enable this flag */
  95122. static ExclusiveDoubleClickMode: boolean;
  95123. /** @hidden */
  95124. _mirroredCameraPosition: Nullable<Vector3>;
  95125. /**
  95126. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95127. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95128. */
  95129. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95130. /**
  95131. * Observable event triggered each time an keyboard event is received from the hosting window
  95132. */
  95133. onKeyboardObservable: Observable<KeyboardInfo>;
  95134. private _useRightHandedSystem;
  95135. /**
  95136. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95137. */
  95138. useRightHandedSystem: boolean;
  95139. private _timeAccumulator;
  95140. private _currentStepId;
  95141. private _currentInternalStep;
  95142. /**
  95143. * Sets the step Id used by deterministic lock step
  95144. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95145. * @param newStepId defines the step Id
  95146. */
  95147. setStepId(newStepId: number): void;
  95148. /**
  95149. * Gets the step Id used by deterministic lock step
  95150. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95151. * @returns the step Id
  95152. */
  95153. getStepId(): number;
  95154. /**
  95155. * Gets the internal step used by deterministic lock step
  95156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95157. * @returns the internal step
  95158. */
  95159. getInternalStep(): number;
  95160. private _fogEnabled;
  95161. /**
  95162. * Gets or sets a boolean indicating if fog is enabled on this scene
  95163. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95164. * (Default is true)
  95165. */
  95166. fogEnabled: boolean;
  95167. private _fogMode;
  95168. /**
  95169. * Gets or sets the fog mode to use
  95170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95171. * | mode | value |
  95172. * | --- | --- |
  95173. * | FOGMODE_NONE | 0 |
  95174. * | FOGMODE_EXP | 1 |
  95175. * | FOGMODE_EXP2 | 2 |
  95176. * | FOGMODE_LINEAR | 3 |
  95177. */
  95178. fogMode: number;
  95179. /**
  95180. * Gets or sets the fog color to use
  95181. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95182. * (Default is Color3(0.2, 0.2, 0.3))
  95183. */
  95184. fogColor: Color3;
  95185. /**
  95186. * Gets or sets the fog density to use
  95187. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95188. * (Default is 0.1)
  95189. */
  95190. fogDensity: number;
  95191. /**
  95192. * Gets or sets the fog start distance to use
  95193. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95194. * (Default is 0)
  95195. */
  95196. fogStart: number;
  95197. /**
  95198. * Gets or sets the fog end distance to use
  95199. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95200. * (Default is 1000)
  95201. */
  95202. fogEnd: number;
  95203. private _shadowsEnabled;
  95204. /**
  95205. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95206. */
  95207. shadowsEnabled: boolean;
  95208. private _lightsEnabled;
  95209. /**
  95210. * Gets or sets a boolean indicating if lights are enabled on this scene
  95211. */
  95212. lightsEnabled: boolean;
  95213. /** All of the active cameras added to this scene. */
  95214. activeCameras: Camera[];
  95215. /** @hidden */
  95216. _activeCamera: Nullable<Camera>;
  95217. /** Gets or sets the current active camera */
  95218. activeCamera: Nullable<Camera>;
  95219. private _defaultMaterial;
  95220. /** The default material used on meshes when no material is affected */
  95221. /** The default material used on meshes when no material is affected */
  95222. defaultMaterial: Material;
  95223. private _texturesEnabled;
  95224. /**
  95225. * Gets or sets a boolean indicating if textures are enabled on this scene
  95226. */
  95227. texturesEnabled: boolean;
  95228. /**
  95229. * Gets or sets a boolean indicating if particles are enabled on this scene
  95230. */
  95231. particlesEnabled: boolean;
  95232. /**
  95233. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95234. */
  95235. spritesEnabled: boolean;
  95236. private _skeletonsEnabled;
  95237. /**
  95238. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95239. */
  95240. skeletonsEnabled: boolean;
  95241. /**
  95242. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95243. */
  95244. lensFlaresEnabled: boolean;
  95245. /**
  95246. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95248. */
  95249. collisionsEnabled: boolean;
  95250. private _collisionCoordinator;
  95251. /** @hidden */
  95252. readonly collisionCoordinator: ICollisionCoordinator;
  95253. /**
  95254. * Defines the gravity applied to this scene (used only for collisions)
  95255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95256. */
  95257. gravity: Vector3;
  95258. /**
  95259. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95260. */
  95261. postProcessesEnabled: boolean;
  95262. /**
  95263. * The list of postprocesses added to the scene
  95264. */
  95265. postProcesses: PostProcess[];
  95266. /**
  95267. * Gets the current postprocess manager
  95268. */
  95269. postProcessManager: PostProcessManager;
  95270. /**
  95271. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95272. */
  95273. renderTargetsEnabled: boolean;
  95274. /**
  95275. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95276. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95277. */
  95278. dumpNextRenderTargets: boolean;
  95279. /**
  95280. * The list of user defined render targets added to the scene
  95281. */
  95282. customRenderTargets: RenderTargetTexture[];
  95283. /**
  95284. * Defines if texture loading must be delayed
  95285. * If true, textures will only be loaded when they need to be rendered
  95286. */
  95287. useDelayedTextureLoading: boolean;
  95288. /**
  95289. * Gets the list of meshes imported to the scene through SceneLoader
  95290. */
  95291. importedMeshesFiles: String[];
  95292. /**
  95293. * Gets or sets a boolean indicating if probes are enabled on this scene
  95294. */
  95295. probesEnabled: boolean;
  95296. /**
  95297. * Gets or sets the current offline provider to use to store scene data
  95298. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95299. */
  95300. offlineProvider: IOfflineProvider;
  95301. /**
  95302. * Gets or sets the action manager associated with the scene
  95303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95304. */
  95305. actionManager: AbstractActionManager;
  95306. private _meshesForIntersections;
  95307. /**
  95308. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95309. */
  95310. proceduralTexturesEnabled: boolean;
  95311. private _engine;
  95312. private _totalVertices;
  95313. /** @hidden */
  95314. _activeIndices: PerfCounter;
  95315. /** @hidden */
  95316. _activeParticles: PerfCounter;
  95317. /** @hidden */
  95318. _activeBones: PerfCounter;
  95319. private _animationRatio;
  95320. /** @hidden */
  95321. _animationTimeLast: number;
  95322. /** @hidden */
  95323. _animationTime: number;
  95324. /**
  95325. * Gets or sets a general scale for animation speed
  95326. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95327. */
  95328. animationTimeScale: number;
  95329. /** @hidden */
  95330. _cachedMaterial: Nullable<Material>;
  95331. /** @hidden */
  95332. _cachedEffect: Nullable<Effect>;
  95333. /** @hidden */
  95334. _cachedVisibility: Nullable<number>;
  95335. private _renderId;
  95336. private _frameId;
  95337. private _executeWhenReadyTimeoutId;
  95338. private _intermediateRendering;
  95339. private _viewUpdateFlag;
  95340. private _projectionUpdateFlag;
  95341. /** @hidden */
  95342. _toBeDisposed: Nullable<IDisposable>[];
  95343. private _activeRequests;
  95344. /** @hidden */
  95345. _pendingData: any[];
  95346. private _isDisposed;
  95347. /**
  95348. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95349. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95350. */
  95351. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95352. private _activeMeshes;
  95353. private _processedMaterials;
  95354. private _renderTargets;
  95355. /** @hidden */
  95356. _activeParticleSystems: SmartArray<IParticleSystem>;
  95357. private _activeSkeletons;
  95358. private _softwareSkinnedMeshes;
  95359. private _renderingManager;
  95360. /** @hidden */
  95361. _activeAnimatables: Animatable[];
  95362. private _transformMatrix;
  95363. private _sceneUbo;
  95364. /** @hidden */
  95365. _viewMatrix: Matrix;
  95366. private _projectionMatrix;
  95367. /** @hidden */
  95368. _forcedViewPosition: Nullable<Vector3>;
  95369. /** @hidden */
  95370. _frustumPlanes: Plane[];
  95371. /**
  95372. * Gets the list of frustum planes (built from the active camera)
  95373. */
  95374. readonly frustumPlanes: Plane[];
  95375. /**
  95376. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95377. * This is useful if there are more lights that the maximum simulteanous authorized
  95378. */
  95379. requireLightSorting: boolean;
  95380. /** @hidden */
  95381. readonly useMaterialMeshMap: boolean;
  95382. /** @hidden */
  95383. readonly useClonedMeshhMap: boolean;
  95384. private _externalData;
  95385. private _uid;
  95386. /**
  95387. * @hidden
  95388. * Backing store of defined scene components.
  95389. */
  95390. _components: ISceneComponent[];
  95391. /**
  95392. * @hidden
  95393. * Backing store of defined scene components.
  95394. */
  95395. _serializableComponents: ISceneSerializableComponent[];
  95396. /**
  95397. * List of components to register on the next registration step.
  95398. */
  95399. private _transientComponents;
  95400. /**
  95401. * Registers the transient components if needed.
  95402. */
  95403. private _registerTransientComponents;
  95404. /**
  95405. * @hidden
  95406. * Add a component to the scene.
  95407. * Note that the ccomponent could be registered on th next frame if this is called after
  95408. * the register component stage.
  95409. * @param component Defines the component to add to the scene
  95410. */
  95411. _addComponent(component: ISceneComponent): void;
  95412. /**
  95413. * @hidden
  95414. * Gets a component from the scene.
  95415. * @param name defines the name of the component to retrieve
  95416. * @returns the component or null if not present
  95417. */
  95418. _getComponent(name: string): Nullable<ISceneComponent>;
  95419. /**
  95420. * @hidden
  95421. * Defines the actions happening before camera updates.
  95422. */
  95423. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95424. /**
  95425. * @hidden
  95426. * Defines the actions happening before clear the canvas.
  95427. */
  95428. _beforeClearStage: Stage<SimpleStageAction>;
  95429. /**
  95430. * @hidden
  95431. * Defines the actions when collecting render targets for the frame.
  95432. */
  95433. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95434. /**
  95435. * @hidden
  95436. * Defines the actions happening for one camera in the frame.
  95437. */
  95438. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95439. /**
  95440. * @hidden
  95441. * Defines the actions happening during the per mesh ready checks.
  95442. */
  95443. _isReadyForMeshStage: Stage<MeshStageAction>;
  95444. /**
  95445. * @hidden
  95446. * Defines the actions happening before evaluate active mesh checks.
  95447. */
  95448. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95449. /**
  95450. * @hidden
  95451. * Defines the actions happening during the evaluate sub mesh checks.
  95452. */
  95453. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95454. /**
  95455. * @hidden
  95456. * Defines the actions happening during the active mesh stage.
  95457. */
  95458. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95459. /**
  95460. * @hidden
  95461. * Defines the actions happening during the per camera render target step.
  95462. */
  95463. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95464. /**
  95465. * @hidden
  95466. * Defines the actions happening just before the active camera is drawing.
  95467. */
  95468. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95469. /**
  95470. * @hidden
  95471. * Defines the actions happening just before a render target is drawing.
  95472. */
  95473. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95474. /**
  95475. * @hidden
  95476. * Defines the actions happening just before a rendering group is drawing.
  95477. */
  95478. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95479. /**
  95480. * @hidden
  95481. * Defines the actions happening just before a mesh is drawing.
  95482. */
  95483. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95484. /**
  95485. * @hidden
  95486. * Defines the actions happening just after a mesh has been drawn.
  95487. */
  95488. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95489. /**
  95490. * @hidden
  95491. * Defines the actions happening just after a rendering group has been drawn.
  95492. */
  95493. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95494. /**
  95495. * @hidden
  95496. * Defines the actions happening just after the active camera has been drawn.
  95497. */
  95498. _afterCameraDrawStage: Stage<CameraStageAction>;
  95499. /**
  95500. * @hidden
  95501. * Defines the actions happening just after a render target has been drawn.
  95502. */
  95503. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95504. /**
  95505. * @hidden
  95506. * Defines the actions happening just after rendering all cameras and computing intersections.
  95507. */
  95508. _afterRenderStage: Stage<SimpleStageAction>;
  95509. /**
  95510. * @hidden
  95511. * Defines the actions happening when a pointer move event happens.
  95512. */
  95513. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95514. /**
  95515. * @hidden
  95516. * Defines the actions happening when a pointer down event happens.
  95517. */
  95518. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95519. /**
  95520. * @hidden
  95521. * Defines the actions happening when a pointer up event happens.
  95522. */
  95523. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95524. /**
  95525. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95526. */
  95527. private geometriesByUniqueId;
  95528. /**
  95529. * Creates a new Scene
  95530. * @param engine defines the engine to use to render this scene
  95531. * @param options defines the scene options
  95532. */
  95533. constructor(engine: Engine, options?: SceneOptions);
  95534. /**
  95535. * Gets a string idenfifying the name of the class
  95536. * @returns "Scene" string
  95537. */
  95538. getClassName(): string;
  95539. private _defaultMeshCandidates;
  95540. /**
  95541. * @hidden
  95542. */
  95543. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95544. private _defaultSubMeshCandidates;
  95545. /**
  95546. * @hidden
  95547. */
  95548. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95549. /**
  95550. * Sets the default candidate providers for the scene.
  95551. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95552. * and getCollidingSubMeshCandidates to their default function
  95553. */
  95554. setDefaultCandidateProviders(): void;
  95555. /**
  95556. * Gets the mesh that is currently under the pointer
  95557. */
  95558. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95559. /**
  95560. * Gets or sets the current on-screen X position of the pointer
  95561. */
  95562. pointerX: number;
  95563. /**
  95564. * Gets or sets the current on-screen Y position of the pointer
  95565. */
  95566. pointerY: number;
  95567. /**
  95568. * Gets the cached material (ie. the latest rendered one)
  95569. * @returns the cached material
  95570. */
  95571. getCachedMaterial(): Nullable<Material>;
  95572. /**
  95573. * Gets the cached effect (ie. the latest rendered one)
  95574. * @returns the cached effect
  95575. */
  95576. getCachedEffect(): Nullable<Effect>;
  95577. /**
  95578. * Gets the cached visibility state (ie. the latest rendered one)
  95579. * @returns the cached visibility state
  95580. */
  95581. getCachedVisibility(): Nullable<number>;
  95582. /**
  95583. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95584. * @param material defines the current material
  95585. * @param effect defines the current effect
  95586. * @param visibility defines the current visibility state
  95587. * @returns true if one parameter is not cached
  95588. */
  95589. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95590. /**
  95591. * Gets the engine associated with the scene
  95592. * @returns an Engine
  95593. */
  95594. getEngine(): Engine;
  95595. /**
  95596. * Gets the total number of vertices rendered per frame
  95597. * @returns the total number of vertices rendered per frame
  95598. */
  95599. getTotalVertices(): number;
  95600. /**
  95601. * Gets the performance counter for total vertices
  95602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95603. */
  95604. readonly totalVerticesPerfCounter: PerfCounter;
  95605. /**
  95606. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95607. * @returns the total number of active indices rendered per frame
  95608. */
  95609. getActiveIndices(): number;
  95610. /**
  95611. * Gets the performance counter for active indices
  95612. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95613. */
  95614. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95615. /**
  95616. * Gets the total number of active particles rendered per frame
  95617. * @returns the total number of active particles rendered per frame
  95618. */
  95619. getActiveParticles(): number;
  95620. /**
  95621. * Gets the performance counter for active particles
  95622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95623. */
  95624. readonly activeParticlesPerfCounter: PerfCounter;
  95625. /**
  95626. * Gets the total number of active bones rendered per frame
  95627. * @returns the total number of active bones rendered per frame
  95628. */
  95629. getActiveBones(): number;
  95630. /**
  95631. * Gets the performance counter for active bones
  95632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95633. */
  95634. readonly activeBonesPerfCounter: PerfCounter;
  95635. /**
  95636. * Gets the array of active meshes
  95637. * @returns an array of AbstractMesh
  95638. */
  95639. getActiveMeshes(): SmartArray<AbstractMesh>;
  95640. /**
  95641. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95642. * @returns a number
  95643. */
  95644. getAnimationRatio(): number;
  95645. /**
  95646. * Gets an unique Id for the current render phase
  95647. * @returns a number
  95648. */
  95649. getRenderId(): number;
  95650. /**
  95651. * Gets an unique Id for the current frame
  95652. * @returns a number
  95653. */
  95654. getFrameId(): number;
  95655. /** Call this function if you want to manually increment the render Id*/
  95656. incrementRenderId(): void;
  95657. private _createUbo;
  95658. /**
  95659. * Use this method to simulate a pointer move on a mesh
  95660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95663. * @returns the current scene
  95664. */
  95665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95666. /**
  95667. * Use this method to simulate a pointer down on a mesh
  95668. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95669. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95670. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95671. * @returns the current scene
  95672. */
  95673. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95674. /**
  95675. * Use this method to simulate a pointer up on a mesh
  95676. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95677. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95678. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95679. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95680. * @returns the current scene
  95681. */
  95682. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95683. /**
  95684. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95685. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95686. * @returns true if the pointer was captured
  95687. */
  95688. isPointerCaptured(pointerId?: number): boolean;
  95689. /**
  95690. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95691. * @param attachUp defines if you want to attach events to pointerup
  95692. * @param attachDown defines if you want to attach events to pointerdown
  95693. * @param attachMove defines if you want to attach events to pointermove
  95694. */
  95695. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95696. /** Detaches all event handlers*/
  95697. detachControl(): void;
  95698. /**
  95699. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95700. * Delay loaded resources are not taking in account
  95701. * @return true if all required resources are ready
  95702. */
  95703. isReady(): boolean;
  95704. /** Resets all cached information relative to material (including effect and visibility) */
  95705. resetCachedMaterial(): void;
  95706. /**
  95707. * Registers a function to be called before every frame render
  95708. * @param func defines the function to register
  95709. */
  95710. registerBeforeRender(func: () => void): void;
  95711. /**
  95712. * Unregisters a function called before every frame render
  95713. * @param func defines the function to unregister
  95714. */
  95715. unregisterBeforeRender(func: () => void): void;
  95716. /**
  95717. * Registers a function to be called after every frame render
  95718. * @param func defines the function to register
  95719. */
  95720. registerAfterRender(func: () => void): void;
  95721. /**
  95722. * Unregisters a function called after every frame render
  95723. * @param func defines the function to unregister
  95724. */
  95725. unregisterAfterRender(func: () => void): void;
  95726. private _executeOnceBeforeRender;
  95727. /**
  95728. * The provided function will run before render once and will be disposed afterwards.
  95729. * A timeout delay can be provided so that the function will be executed in N ms.
  95730. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95731. * @param func The function to be executed.
  95732. * @param timeout optional delay in ms
  95733. */
  95734. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95735. /** @hidden */
  95736. _addPendingData(data: any): void;
  95737. /** @hidden */
  95738. _removePendingData(data: any): void;
  95739. /**
  95740. * Returns the number of items waiting to be loaded
  95741. * @returns the number of items waiting to be loaded
  95742. */
  95743. getWaitingItemsCount(): number;
  95744. /**
  95745. * Returns a boolean indicating if the scene is still loading data
  95746. */
  95747. readonly isLoading: boolean;
  95748. /**
  95749. * Registers a function to be executed when the scene is ready
  95750. * @param {Function} func - the function to be executed
  95751. */
  95752. executeWhenReady(func: () => void): void;
  95753. /**
  95754. * Returns a promise that resolves when the scene is ready
  95755. * @returns A promise that resolves when the scene is ready
  95756. */
  95757. whenReadyAsync(): Promise<void>;
  95758. /** @hidden */
  95759. _checkIsReady(): void;
  95760. /**
  95761. * Gets all animatable attached to the scene
  95762. */
  95763. readonly animatables: Animatable[];
  95764. /**
  95765. * Resets the last animation time frame.
  95766. * Useful to override when animations start running when loading a scene for the first time.
  95767. */
  95768. resetLastAnimationTimeFrame(): void;
  95769. /**
  95770. * Gets the current view matrix
  95771. * @returns a Matrix
  95772. */
  95773. getViewMatrix(): Matrix;
  95774. /**
  95775. * Gets the current projection matrix
  95776. * @returns a Matrix
  95777. */
  95778. getProjectionMatrix(): Matrix;
  95779. /**
  95780. * Gets the current transform matrix
  95781. * @returns a Matrix made of View * Projection
  95782. */
  95783. getTransformMatrix(): Matrix;
  95784. /**
  95785. * Sets the current transform matrix
  95786. * @param viewL defines the View matrix to use
  95787. * @param projectionL defines the Projection matrix to use
  95788. * @param viewR defines the right View matrix to use (if provided)
  95789. * @param projectionR defines the right Projection matrix to use (if provided)
  95790. */
  95791. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95792. /**
  95793. * Gets the uniform buffer used to store scene data
  95794. * @returns a UniformBuffer
  95795. */
  95796. getSceneUniformBuffer(): UniformBuffer;
  95797. /**
  95798. * Gets an unique (relatively to the current scene) Id
  95799. * @returns an unique number for the scene
  95800. */
  95801. getUniqueId(): number;
  95802. /**
  95803. * Add a mesh to the list of scene's meshes
  95804. * @param newMesh defines the mesh to add
  95805. * @param recursive if all child meshes should also be added to the scene
  95806. */
  95807. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95808. /**
  95809. * Remove a mesh for the list of scene's meshes
  95810. * @param toRemove defines the mesh to remove
  95811. * @param recursive if all child meshes should also be removed from the scene
  95812. * @returns the index where the mesh was in the mesh list
  95813. */
  95814. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95815. /**
  95816. * Add a transform node to the list of scene's transform nodes
  95817. * @param newTransformNode defines the transform node to add
  95818. */
  95819. addTransformNode(newTransformNode: TransformNode): void;
  95820. /**
  95821. * Remove a transform node for the list of scene's transform nodes
  95822. * @param toRemove defines the transform node to remove
  95823. * @returns the index where the transform node was in the transform node list
  95824. */
  95825. removeTransformNode(toRemove: TransformNode): number;
  95826. /**
  95827. * Remove a skeleton for the list of scene's skeletons
  95828. * @param toRemove defines the skeleton to remove
  95829. * @returns the index where the skeleton was in the skeleton list
  95830. */
  95831. removeSkeleton(toRemove: Skeleton): number;
  95832. /**
  95833. * Remove a morph target for the list of scene's morph targets
  95834. * @param toRemove defines the morph target to remove
  95835. * @returns the index where the morph target was in the morph target list
  95836. */
  95837. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95838. /**
  95839. * Remove a light for the list of scene's lights
  95840. * @param toRemove defines the light to remove
  95841. * @returns the index where the light was in the light list
  95842. */
  95843. removeLight(toRemove: Light): number;
  95844. /**
  95845. * Remove a camera for the list of scene's cameras
  95846. * @param toRemove defines the camera to remove
  95847. * @returns the index where the camera was in the camera list
  95848. */
  95849. removeCamera(toRemove: Camera): number;
  95850. /**
  95851. * Remove a particle system for the list of scene's particle systems
  95852. * @param toRemove defines the particle system to remove
  95853. * @returns the index where the particle system was in the particle system list
  95854. */
  95855. removeParticleSystem(toRemove: IParticleSystem): number;
  95856. /**
  95857. * Remove a animation for the list of scene's animations
  95858. * @param toRemove defines the animation to remove
  95859. * @returns the index where the animation was in the animation list
  95860. */
  95861. removeAnimation(toRemove: Animation): number;
  95862. /**
  95863. * Will stop the animation of the given target
  95864. * @param target - the target
  95865. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  95866. * @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)
  95867. */
  95868. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  95869. /**
  95870. * Removes the given animation group from this scene.
  95871. * @param toRemove The animation group to remove
  95872. * @returns The index of the removed animation group
  95873. */
  95874. removeAnimationGroup(toRemove: AnimationGroup): number;
  95875. /**
  95876. * Removes the given multi-material from this scene.
  95877. * @param toRemove The multi-material to remove
  95878. * @returns The index of the removed multi-material
  95879. */
  95880. removeMultiMaterial(toRemove: MultiMaterial): number;
  95881. /**
  95882. * Removes the given material from this scene.
  95883. * @param toRemove The material to remove
  95884. * @returns The index of the removed material
  95885. */
  95886. removeMaterial(toRemove: Material): number;
  95887. /**
  95888. * Removes the given action manager from this scene.
  95889. * @param toRemove The action manager to remove
  95890. * @returns The index of the removed action manager
  95891. */
  95892. removeActionManager(toRemove: AbstractActionManager): number;
  95893. /**
  95894. * Removes the given texture from this scene.
  95895. * @param toRemove The texture to remove
  95896. * @returns The index of the removed texture
  95897. */
  95898. removeTexture(toRemove: BaseTexture): number;
  95899. /**
  95900. * Adds the given light to this scene
  95901. * @param newLight The light to add
  95902. */
  95903. addLight(newLight: Light): void;
  95904. /**
  95905. * Sorts the list list based on light priorities
  95906. */
  95907. sortLightsByPriority(): void;
  95908. /**
  95909. * Adds the given camera to this scene
  95910. * @param newCamera The camera to add
  95911. */
  95912. addCamera(newCamera: Camera): void;
  95913. /**
  95914. * Adds the given skeleton to this scene
  95915. * @param newSkeleton The skeleton to add
  95916. */
  95917. addSkeleton(newSkeleton: Skeleton): void;
  95918. /**
  95919. * Adds the given particle system to this scene
  95920. * @param newParticleSystem The particle system to add
  95921. */
  95922. addParticleSystem(newParticleSystem: IParticleSystem): void;
  95923. /**
  95924. * Adds the given animation to this scene
  95925. * @param newAnimation The animation to add
  95926. */
  95927. addAnimation(newAnimation: Animation): void;
  95928. /**
  95929. * Adds the given animation group to this scene.
  95930. * @param newAnimationGroup The animation group to add
  95931. */
  95932. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  95933. /**
  95934. * Adds the given multi-material to this scene
  95935. * @param newMultiMaterial The multi-material to add
  95936. */
  95937. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  95938. /**
  95939. * Adds the given material to this scene
  95940. * @param newMaterial The material to add
  95941. */
  95942. addMaterial(newMaterial: Material): void;
  95943. /**
  95944. * Adds the given morph target to this scene
  95945. * @param newMorphTargetManager The morph target to add
  95946. */
  95947. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  95948. /**
  95949. * Adds the given geometry to this scene
  95950. * @param newGeometry The geometry to add
  95951. */
  95952. addGeometry(newGeometry: Geometry): void;
  95953. /**
  95954. * Adds the given action manager to this scene
  95955. * @param newActionManager The action manager to add
  95956. */
  95957. addActionManager(newActionManager: AbstractActionManager): void;
  95958. /**
  95959. * Adds the given texture to this scene.
  95960. * @param newTexture The texture to add
  95961. */
  95962. addTexture(newTexture: BaseTexture): void;
  95963. /**
  95964. * Switch active camera
  95965. * @param newCamera defines the new active camera
  95966. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  95967. */
  95968. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  95969. /**
  95970. * sets the active camera of the scene using its ID
  95971. * @param id defines the camera's ID
  95972. * @return the new active camera or null if none found.
  95973. */
  95974. setActiveCameraByID(id: string): Nullable<Camera>;
  95975. /**
  95976. * sets the active camera of the scene using its name
  95977. * @param name defines the camera's name
  95978. * @returns the new active camera or null if none found.
  95979. */
  95980. setActiveCameraByName(name: string): Nullable<Camera>;
  95981. /**
  95982. * get an animation group using its name
  95983. * @param name defines the material's name
  95984. * @return the animation group or null if none found.
  95985. */
  95986. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  95987. /**
  95988. * Get a material using its unique id
  95989. * @param uniqueId defines the material's unique id
  95990. * @return the material or null if none found.
  95991. */
  95992. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  95993. /**
  95994. * get a material using its id
  95995. * @param id defines the material's ID
  95996. * @return the material or null if none found.
  95997. */
  95998. getMaterialByID(id: string): Nullable<Material>;
  95999. /**
  96000. * Gets a material using its name
  96001. * @param name defines the material's name
  96002. * @return the material or null if none found.
  96003. */
  96004. getMaterialByName(name: string): Nullable<Material>;
  96005. /**
  96006. * Gets a camera using its id
  96007. * @param id defines the id to look for
  96008. * @returns the camera or null if not found
  96009. */
  96010. getCameraByID(id: string): Nullable<Camera>;
  96011. /**
  96012. * Gets a camera using its unique id
  96013. * @param uniqueId defines the unique id to look for
  96014. * @returns the camera or null if not found
  96015. */
  96016. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96017. /**
  96018. * Gets a camera using its name
  96019. * @param name defines the camera's name
  96020. * @return the camera or null if none found.
  96021. */
  96022. getCameraByName(name: string): Nullable<Camera>;
  96023. /**
  96024. * Gets a bone using its id
  96025. * @param id defines the bone's id
  96026. * @return the bone or null if not found
  96027. */
  96028. getBoneByID(id: string): Nullable<Bone>;
  96029. /**
  96030. * Gets a bone using its id
  96031. * @param name defines the bone's name
  96032. * @return the bone or null if not found
  96033. */
  96034. getBoneByName(name: string): Nullable<Bone>;
  96035. /**
  96036. * Gets a light node using its name
  96037. * @param name defines the the light's name
  96038. * @return the light or null if none found.
  96039. */
  96040. getLightByName(name: string): Nullable<Light>;
  96041. /**
  96042. * Gets a light node using its id
  96043. * @param id defines the light's id
  96044. * @return the light or null if none found.
  96045. */
  96046. getLightByID(id: string): Nullable<Light>;
  96047. /**
  96048. * Gets a light node using its scene-generated unique ID
  96049. * @param uniqueId defines the light's unique id
  96050. * @return the light or null if none found.
  96051. */
  96052. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96053. /**
  96054. * Gets a particle system by id
  96055. * @param id defines the particle system id
  96056. * @return the corresponding system or null if none found
  96057. */
  96058. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96059. /**
  96060. * Gets a geometry using its ID
  96061. * @param id defines the geometry's id
  96062. * @return the geometry or null if none found.
  96063. */
  96064. getGeometryByID(id: string): Nullable<Geometry>;
  96065. private _getGeometryByUniqueID;
  96066. /**
  96067. * Add a new geometry to this scene
  96068. * @param geometry defines the geometry to be added to the scene.
  96069. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96070. * @return a boolean defining if the geometry was added or not
  96071. */
  96072. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96073. /**
  96074. * Removes an existing geometry
  96075. * @param geometry defines the geometry to be removed from the scene
  96076. * @return a boolean defining if the geometry was removed or not
  96077. */
  96078. removeGeometry(geometry: Geometry): boolean;
  96079. /**
  96080. * Gets the list of geometries attached to the scene
  96081. * @returns an array of Geometry
  96082. */
  96083. getGeometries(): Geometry[];
  96084. /**
  96085. * Gets the first added mesh found of a given ID
  96086. * @param id defines the id to search for
  96087. * @return the mesh found or null if not found at all
  96088. */
  96089. getMeshByID(id: string): Nullable<AbstractMesh>;
  96090. /**
  96091. * Gets a list of meshes using their id
  96092. * @param id defines the id to search for
  96093. * @returns a list of meshes
  96094. */
  96095. getMeshesByID(id: string): Array<AbstractMesh>;
  96096. /**
  96097. * Gets the first added transform node found of a given ID
  96098. * @param id defines the id to search for
  96099. * @return the found transform node or null if not found at all.
  96100. */
  96101. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96102. /**
  96103. * Gets a transform node with its auto-generated unique id
  96104. * @param uniqueId efines the unique id to search for
  96105. * @return the found transform node or null if not found at all.
  96106. */
  96107. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96108. /**
  96109. * Gets a list of transform nodes using their id
  96110. * @param id defines the id to search for
  96111. * @returns a list of transform nodes
  96112. */
  96113. getTransformNodesByID(id: string): Array<TransformNode>;
  96114. /**
  96115. * Gets a mesh with its auto-generated unique id
  96116. * @param uniqueId defines the unique id to search for
  96117. * @return the found mesh or null if not found at all.
  96118. */
  96119. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96120. /**
  96121. * Gets a the last added mesh using a given id
  96122. * @param id defines the id to search for
  96123. * @return the found mesh or null if not found at all.
  96124. */
  96125. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96126. /**
  96127. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96128. * @param id defines the id to search for
  96129. * @return the found node or null if not found at all
  96130. */
  96131. getLastEntryByID(id: string): Nullable<Node>;
  96132. /**
  96133. * Gets a node (Mesh, Camera, Light) using a given id
  96134. * @param id defines the id to search for
  96135. * @return the found node or null if not found at all
  96136. */
  96137. getNodeByID(id: string): Nullable<Node>;
  96138. /**
  96139. * Gets a node (Mesh, Camera, Light) using a given name
  96140. * @param name defines the name to search for
  96141. * @return the found node or null if not found at all.
  96142. */
  96143. getNodeByName(name: string): Nullable<Node>;
  96144. /**
  96145. * Gets a mesh using a given name
  96146. * @param name defines the name to search for
  96147. * @return the found mesh or null if not found at all.
  96148. */
  96149. getMeshByName(name: string): Nullable<AbstractMesh>;
  96150. /**
  96151. * Gets a transform node using a given name
  96152. * @param name defines the name to search for
  96153. * @return the found transform node or null if not found at all.
  96154. */
  96155. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96156. /**
  96157. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96158. * @param id defines the id to search for
  96159. * @return the found skeleton or null if not found at all.
  96160. */
  96161. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96162. /**
  96163. * Gets a skeleton using a given auto generated unique id
  96164. * @param uniqueId defines the unique id to search for
  96165. * @return the found skeleton or null if not found at all.
  96166. */
  96167. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96168. /**
  96169. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96170. * @param id defines the id to search for
  96171. * @return the found skeleton or null if not found at all.
  96172. */
  96173. getSkeletonById(id: string): Nullable<Skeleton>;
  96174. /**
  96175. * Gets a skeleton using a given name
  96176. * @param name defines the name to search for
  96177. * @return the found skeleton or null if not found at all.
  96178. */
  96179. getSkeletonByName(name: string): Nullable<Skeleton>;
  96180. /**
  96181. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96182. * @param id defines the id to search for
  96183. * @return the found morph target manager or null if not found at all.
  96184. */
  96185. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96186. /**
  96187. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96188. * @param id defines the id to search for
  96189. * @return the found morph target or null if not found at all.
  96190. */
  96191. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96192. /**
  96193. * Gets a boolean indicating if the given mesh is active
  96194. * @param mesh defines the mesh to look for
  96195. * @returns true if the mesh is in the active list
  96196. */
  96197. isActiveMesh(mesh: AbstractMesh): boolean;
  96198. /**
  96199. * Return a unique id as a string which can serve as an identifier for the scene
  96200. */
  96201. readonly uid: string;
  96202. /**
  96203. * Add an externaly attached data from its key.
  96204. * This method call will fail and return false, if such key already exists.
  96205. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96206. * @param key the unique key that identifies the data
  96207. * @param data the data object to associate to the key for this Engine instance
  96208. * @return true if no such key were already present and the data was added successfully, false otherwise
  96209. */
  96210. addExternalData<T>(key: string, data: T): boolean;
  96211. /**
  96212. * Get an externaly attached data from its key
  96213. * @param key the unique key that identifies the data
  96214. * @return the associated data, if present (can be null), or undefined if not present
  96215. */
  96216. getExternalData<T>(key: string): Nullable<T>;
  96217. /**
  96218. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96219. * @param key the unique key that identifies the data
  96220. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96221. * @return the associated data, can be null if the factory returned null.
  96222. */
  96223. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96224. /**
  96225. * Remove an externaly attached data from the Engine instance
  96226. * @param key the unique key that identifies the data
  96227. * @return true if the data was successfully removed, false if it doesn't exist
  96228. */
  96229. removeExternalData(key: string): boolean;
  96230. private _evaluateSubMesh;
  96231. /**
  96232. * Clear the processed materials smart array preventing retention point in material dispose.
  96233. */
  96234. freeProcessedMaterials(): void;
  96235. private _preventFreeActiveMeshesAndRenderingGroups;
  96236. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96237. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96238. * when disposing several meshes in a row or a hierarchy of meshes.
  96239. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96240. */
  96241. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96242. /**
  96243. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96244. */
  96245. freeActiveMeshes(): void;
  96246. /**
  96247. * Clear the info related to rendering groups preventing retention points during dispose.
  96248. */
  96249. freeRenderingGroups(): void;
  96250. /** @hidden */
  96251. _isInIntermediateRendering(): boolean;
  96252. /**
  96253. * Lambda returning the list of potentially active meshes.
  96254. */
  96255. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96256. /**
  96257. * Lambda returning the list of potentially active sub meshes.
  96258. */
  96259. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96260. /**
  96261. * Lambda returning the list of potentially intersecting sub meshes.
  96262. */
  96263. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96264. /**
  96265. * Lambda returning the list of potentially colliding sub meshes.
  96266. */
  96267. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96268. private _activeMeshesFrozen;
  96269. /**
  96270. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96271. * @returns the current scene
  96272. */
  96273. freezeActiveMeshes(): Scene;
  96274. /**
  96275. * Use this function to restart evaluating active meshes on every frame
  96276. * @returns the current scene
  96277. */
  96278. unfreezeActiveMeshes(): Scene;
  96279. private _evaluateActiveMeshes;
  96280. private _activeMesh;
  96281. /**
  96282. * Update the transform matrix to update from the current active camera
  96283. * @param force defines a boolean used to force the update even if cache is up to date
  96284. */
  96285. updateTransformMatrix(force?: boolean): void;
  96286. private _bindFrameBuffer;
  96287. /** @hidden */
  96288. _allowPostProcessClearColor: boolean;
  96289. /** @hidden */
  96290. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96291. private _processSubCameras;
  96292. private _checkIntersections;
  96293. /** @hidden */
  96294. _advancePhysicsEngineStep(step: number): void;
  96295. /**
  96296. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96297. */
  96298. getDeterministicFrameTime: () => number;
  96299. /** @hidden */
  96300. _animate(): void;
  96301. /** Execute all animations (for a frame) */
  96302. animate(): void;
  96303. /**
  96304. * Render the scene
  96305. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96306. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96307. */
  96308. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96309. /**
  96310. * Freeze all materials
  96311. * A frozen material will not be updatable but should be faster to render
  96312. */
  96313. freezeMaterials(): void;
  96314. /**
  96315. * Unfreeze all materials
  96316. * A frozen material will not be updatable but should be faster to render
  96317. */
  96318. unfreezeMaterials(): void;
  96319. /**
  96320. * Releases all held ressources
  96321. */
  96322. dispose(): void;
  96323. /**
  96324. * Gets if the scene is already disposed
  96325. */
  96326. readonly isDisposed: boolean;
  96327. /**
  96328. * Call this function to reduce memory footprint of the scene.
  96329. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96330. */
  96331. clearCachedVertexData(): void;
  96332. /**
  96333. * This function will remove the local cached buffer data from texture.
  96334. * It will save memory but will prevent the texture from being rebuilt
  96335. */
  96336. cleanCachedTextureBuffer(): void;
  96337. /**
  96338. * Get the world extend vectors with an optional filter
  96339. *
  96340. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96341. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96342. */
  96343. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96344. min: Vector3;
  96345. max: Vector3;
  96346. };
  96347. /**
  96348. * Creates a ray that can be used to pick in the scene
  96349. * @param x defines the x coordinate of the origin (on-screen)
  96350. * @param y defines the y coordinate of the origin (on-screen)
  96351. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96352. * @param camera defines the camera to use for the picking
  96353. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96354. * @returns a Ray
  96355. */
  96356. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96357. /**
  96358. * Creates a ray that can be used to pick in the scene
  96359. * @param x defines the x coordinate of the origin (on-screen)
  96360. * @param y defines the y coordinate of the origin (on-screen)
  96361. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96362. * @param result defines the ray where to store the picking ray
  96363. * @param camera defines the camera to use for the picking
  96364. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96365. * @returns the current scene
  96366. */
  96367. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96368. /**
  96369. * Creates a ray that can be used to pick in the scene
  96370. * @param x defines the x coordinate of the origin (on-screen)
  96371. * @param y defines the y coordinate of the origin (on-screen)
  96372. * @param camera defines the camera to use for the picking
  96373. * @returns a Ray
  96374. */
  96375. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96376. /**
  96377. * Creates a ray that can be used to pick in the scene
  96378. * @param x defines the x coordinate of the origin (on-screen)
  96379. * @param y defines the y coordinate of the origin (on-screen)
  96380. * @param result defines the ray where to store the picking ray
  96381. * @param camera defines the camera to use for the picking
  96382. * @returns the current scene
  96383. */
  96384. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96385. /** Launch a ray to try to pick a mesh in the scene
  96386. * @param x position on screen
  96387. * @param y position on screen
  96388. * @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
  96389. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96390. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96391. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96392. * @returns a PickingInfo
  96393. */
  96394. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  96395. /** Use the given ray to pick a mesh in the scene
  96396. * @param ray The ray to use to pick meshes
  96397. * @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
  96398. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96399. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96400. * @returns a PickingInfo
  96401. */
  96402. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96403. /**
  96404. * Launch a ray to try to pick a mesh in the scene
  96405. * @param x X position on screen
  96406. * @param y Y position on screen
  96407. * @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
  96408. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96409. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96410. * @returns an array of PickingInfo
  96411. */
  96412. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96413. /**
  96414. * Launch a ray to try to pick a mesh in the scene
  96415. * @param ray Ray to use
  96416. * @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
  96417. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96418. * @returns an array of PickingInfo
  96419. */
  96420. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96421. /**
  96422. * Force the value of meshUnderPointer
  96423. * @param mesh defines the mesh to use
  96424. */
  96425. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96426. /**
  96427. * Gets the mesh under the pointer
  96428. * @returns a Mesh or null if no mesh is under the pointer
  96429. */
  96430. getPointerOverMesh(): Nullable<AbstractMesh>;
  96431. /** @hidden */
  96432. _rebuildGeometries(): void;
  96433. /** @hidden */
  96434. _rebuildTextures(): void;
  96435. private _getByTags;
  96436. /**
  96437. * Get a list of meshes by tags
  96438. * @param tagsQuery defines the tags query to use
  96439. * @param forEach defines a predicate used to filter results
  96440. * @returns an array of Mesh
  96441. */
  96442. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96443. /**
  96444. * Get a list of cameras by tags
  96445. * @param tagsQuery defines the tags query to use
  96446. * @param forEach defines a predicate used to filter results
  96447. * @returns an array of Camera
  96448. */
  96449. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96450. /**
  96451. * Get a list of lights by tags
  96452. * @param tagsQuery defines the tags query to use
  96453. * @param forEach defines a predicate used to filter results
  96454. * @returns an array of Light
  96455. */
  96456. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96457. /**
  96458. * Get a list of materials by tags
  96459. * @param tagsQuery defines the tags query to use
  96460. * @param forEach defines a predicate used to filter results
  96461. * @returns an array of Material
  96462. */
  96463. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96464. /**
  96465. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96466. * This allowed control for front to back rendering or reversly depending of the special needs.
  96467. *
  96468. * @param renderingGroupId The rendering group id corresponding to its index
  96469. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96470. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96471. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96472. */
  96473. 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;
  96474. /**
  96475. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96476. *
  96477. * @param renderingGroupId The rendering group id corresponding to its index
  96478. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96479. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96480. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96481. */
  96482. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96483. /**
  96484. * Gets the current auto clear configuration for one rendering group of the rendering
  96485. * manager.
  96486. * @param index the rendering group index to get the information for
  96487. * @returns The auto clear setup for the requested rendering group
  96488. */
  96489. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96490. private _blockMaterialDirtyMechanism;
  96491. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96492. blockMaterialDirtyMechanism: boolean;
  96493. /**
  96494. * Will flag all materials as dirty to trigger new shader compilation
  96495. * @param flag defines the flag used to specify which material part must be marked as dirty
  96496. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96497. */
  96498. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96499. /** @hidden */
  96500. _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;
  96501. /** @hidden */
  96502. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96503. }
  96504. }
  96505. declare module BABYLON {
  96506. /**
  96507. * Set of assets to keep when moving a scene into an asset container.
  96508. */
  96509. export class KeepAssets extends AbstractScene {
  96510. }
  96511. /**
  96512. * Container with a set of assets that can be added or removed from a scene.
  96513. */
  96514. export class AssetContainer extends AbstractScene {
  96515. /**
  96516. * The scene the AssetContainer belongs to.
  96517. */
  96518. scene: Scene;
  96519. /**
  96520. * Instantiates an AssetContainer.
  96521. * @param scene The scene the AssetContainer belongs to.
  96522. */
  96523. constructor(scene: Scene);
  96524. /**
  96525. * Adds all the assets from the container to the scene.
  96526. */
  96527. addAllToScene(): void;
  96528. /**
  96529. * Removes all the assets in the container from the scene
  96530. */
  96531. removeAllFromScene(): void;
  96532. /**
  96533. * Disposes all the assets in the container
  96534. */
  96535. dispose(): void;
  96536. private _moveAssets;
  96537. /**
  96538. * Removes all the assets contained in the scene and adds them to the container.
  96539. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96540. */
  96541. moveAllFromScene(keepAssets?: KeepAssets): void;
  96542. /**
  96543. * 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.
  96544. * @returns the root mesh
  96545. */
  96546. createRootMesh(): Mesh;
  96547. }
  96548. }
  96549. declare module BABYLON {
  96550. /**
  96551. * Defines how the parser contract is defined.
  96552. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96553. */
  96554. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96555. /**
  96556. * Defines how the individual parser contract is defined.
  96557. * These parser can parse an individual asset
  96558. */
  96559. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96560. /**
  96561. * Base class of the scene acting as a container for the different elements composing a scene.
  96562. * This class is dynamically extended by the different components of the scene increasing
  96563. * flexibility and reducing coupling
  96564. */
  96565. export abstract class AbstractScene {
  96566. /**
  96567. * Stores the list of available parsers in the application.
  96568. */
  96569. private static _BabylonFileParsers;
  96570. /**
  96571. * Stores the list of available individual parsers in the application.
  96572. */
  96573. private static _IndividualBabylonFileParsers;
  96574. /**
  96575. * Adds a parser in the list of available ones
  96576. * @param name Defines the name of the parser
  96577. * @param parser Defines the parser to add
  96578. */
  96579. static AddParser(name: string, parser: BabylonFileParser): void;
  96580. /**
  96581. * Gets a general parser from the list of avaialble ones
  96582. * @param name Defines the name of the parser
  96583. * @returns the requested parser or null
  96584. */
  96585. static GetParser(name: string): Nullable<BabylonFileParser>;
  96586. /**
  96587. * Adds n individual parser in the list of available ones
  96588. * @param name Defines the name of the parser
  96589. * @param parser Defines the parser to add
  96590. */
  96591. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96592. /**
  96593. * Gets an individual parser from the list of avaialble ones
  96594. * @param name Defines the name of the parser
  96595. * @returns the requested parser or null
  96596. */
  96597. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96598. /**
  96599. * Parser json data and populate both a scene and its associated container object
  96600. * @param jsonData Defines the data to parse
  96601. * @param scene Defines the scene to parse the data for
  96602. * @param container Defines the container attached to the parsing sequence
  96603. * @param rootUrl Defines the root url of the data
  96604. */
  96605. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96606. /**
  96607. * Gets the list of root nodes (ie. nodes with no parent)
  96608. */
  96609. rootNodes: Node[];
  96610. /** All of the cameras added to this scene
  96611. * @see http://doc.babylonjs.com/babylon101/cameras
  96612. */
  96613. cameras: Camera[];
  96614. /**
  96615. * All of the lights added to this scene
  96616. * @see http://doc.babylonjs.com/babylon101/lights
  96617. */
  96618. lights: Light[];
  96619. /**
  96620. * All of the (abstract) meshes added to this scene
  96621. */
  96622. meshes: AbstractMesh[];
  96623. /**
  96624. * The list of skeletons added to the scene
  96625. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96626. */
  96627. skeletons: Skeleton[];
  96628. /**
  96629. * All of the particle systems added to this scene
  96630. * @see http://doc.babylonjs.com/babylon101/particles
  96631. */
  96632. particleSystems: IParticleSystem[];
  96633. /**
  96634. * Gets a list of Animations associated with the scene
  96635. */
  96636. animations: Animation[];
  96637. /**
  96638. * All of the animation groups added to this scene
  96639. * @see http://doc.babylonjs.com/how_to/group
  96640. */
  96641. animationGroups: AnimationGroup[];
  96642. /**
  96643. * All of the multi-materials added to this scene
  96644. * @see http://doc.babylonjs.com/how_to/multi_materials
  96645. */
  96646. multiMaterials: MultiMaterial[];
  96647. /**
  96648. * All of the materials added to this scene
  96649. * In the context of a Scene, it is not supposed to be modified manually.
  96650. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96651. * Note also that the order of the Material wihin the array is not significant and might change.
  96652. * @see http://doc.babylonjs.com/babylon101/materials
  96653. */
  96654. materials: Material[];
  96655. /**
  96656. * The list of morph target managers added to the scene
  96657. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96658. */
  96659. morphTargetManagers: MorphTargetManager[];
  96660. /**
  96661. * The list of geometries used in the scene.
  96662. */
  96663. geometries: Geometry[];
  96664. /**
  96665. * All of the tranform nodes added to this scene
  96666. * In the context of a Scene, it is not supposed to be modified manually.
  96667. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96668. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96669. * @see http://doc.babylonjs.com/how_to/transformnode
  96670. */
  96671. transformNodes: TransformNode[];
  96672. /**
  96673. * ActionManagers available on the scene.
  96674. */
  96675. actionManagers: AbstractActionManager[];
  96676. /**
  96677. * Textures to keep.
  96678. */
  96679. textures: BaseTexture[];
  96680. /**
  96681. * Environment texture for the scene
  96682. */
  96683. environmentTexture: Nullable<BaseTexture>;
  96684. }
  96685. }
  96686. declare module BABYLON {
  96687. /**
  96688. * Defines a sound that can be played in the application.
  96689. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96691. */
  96692. export class Sound {
  96693. /**
  96694. * The name of the sound in the scene.
  96695. */
  96696. name: string;
  96697. /**
  96698. * Does the sound autoplay once loaded.
  96699. */
  96700. autoplay: boolean;
  96701. /**
  96702. * Does the sound loop after it finishes playing once.
  96703. */
  96704. loop: boolean;
  96705. /**
  96706. * Does the sound use a custom attenuation curve to simulate the falloff
  96707. * happening when the source gets further away from the camera.
  96708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96709. */
  96710. useCustomAttenuation: boolean;
  96711. /**
  96712. * The sound track id this sound belongs to.
  96713. */
  96714. soundTrackId: number;
  96715. /**
  96716. * Is this sound currently played.
  96717. */
  96718. isPlaying: boolean;
  96719. /**
  96720. * Is this sound currently paused.
  96721. */
  96722. isPaused: boolean;
  96723. /**
  96724. * Does this sound enables spatial sound.
  96725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96726. */
  96727. spatialSound: boolean;
  96728. /**
  96729. * Define the reference distance the sound should be heard perfectly.
  96730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96731. */
  96732. refDistance: number;
  96733. /**
  96734. * Define the roll off factor of spatial sounds.
  96735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96736. */
  96737. rolloffFactor: number;
  96738. /**
  96739. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  96740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96741. */
  96742. maxDistance: number;
  96743. /**
  96744. * Define the distance attenuation model the sound will follow.
  96745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96746. */
  96747. distanceModel: string;
  96748. /**
  96749. * @hidden
  96750. * Back Compat
  96751. **/
  96752. onended: () => any;
  96753. /**
  96754. * Observable event when the current playing sound finishes.
  96755. */
  96756. onEndedObservable: Observable<Sound>;
  96757. private _panningModel;
  96758. private _playbackRate;
  96759. private _streaming;
  96760. private _startTime;
  96761. private _startOffset;
  96762. private _position;
  96763. /** @hidden */
  96764. _positionInEmitterSpace: boolean;
  96765. private _localDirection;
  96766. private _volume;
  96767. private _isReadyToPlay;
  96768. private _isDirectional;
  96769. private _readyToPlayCallback;
  96770. private _audioBuffer;
  96771. private _soundSource;
  96772. private _streamingSource;
  96773. private _soundPanner;
  96774. private _soundGain;
  96775. private _inputAudioNode;
  96776. private _outputAudioNode;
  96777. private _coneInnerAngle;
  96778. private _coneOuterAngle;
  96779. private _coneOuterGain;
  96780. private _scene;
  96781. private _connectedTransformNode;
  96782. private _customAttenuationFunction;
  96783. private _registerFunc;
  96784. private _isOutputConnected;
  96785. private _htmlAudioElement;
  96786. private _urlType;
  96787. /** @hidden */
  96788. static _SceneComponentInitialization: (scene: Scene) => void;
  96789. /**
  96790. * Create a sound and attach it to a scene
  96791. * @param name Name of your sound
  96792. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  96793. * @param scene defines the scene the sound belongs to
  96794. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  96795. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  96796. */
  96797. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  96798. /**
  96799. * Release the sound and its associated resources
  96800. */
  96801. dispose(): void;
  96802. /**
  96803. * Gets if the sounds is ready to be played or not.
  96804. * @returns true if ready, otherwise false
  96805. */
  96806. isReady(): boolean;
  96807. private _soundLoaded;
  96808. /**
  96809. * Sets the data of the sound from an audiobuffer
  96810. * @param audioBuffer The audioBuffer containing the data
  96811. */
  96812. setAudioBuffer(audioBuffer: AudioBuffer): void;
  96813. /**
  96814. * Updates the current sounds options such as maxdistance, loop...
  96815. * @param options A JSON object containing values named as the object properties
  96816. */
  96817. updateOptions(options: any): void;
  96818. private _createSpatialParameters;
  96819. private _updateSpatialParameters;
  96820. /**
  96821. * Switch the panning model to HRTF:
  96822. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96824. */
  96825. switchPanningModelToHRTF(): void;
  96826. /**
  96827. * Switch the panning model to Equal Power:
  96828. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96830. */
  96831. switchPanningModelToEqualPower(): void;
  96832. private _switchPanningModel;
  96833. /**
  96834. * Connect this sound to a sound track audio node like gain...
  96835. * @param soundTrackAudioNode the sound track audio node to connect to
  96836. */
  96837. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  96838. /**
  96839. * Transform this sound into a directional source
  96840. * @param coneInnerAngle Size of the inner cone in degree
  96841. * @param coneOuterAngle Size of the outer cone in degree
  96842. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  96843. */
  96844. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  96845. /**
  96846. * Gets or sets the inner angle for the directional cone.
  96847. */
  96848. /**
  96849. * Gets or sets the inner angle for the directional cone.
  96850. */
  96851. directionalConeInnerAngle: number;
  96852. /**
  96853. * Gets or sets the outer angle for the directional cone.
  96854. */
  96855. /**
  96856. * Gets or sets the outer angle for the directional cone.
  96857. */
  96858. directionalConeOuterAngle: number;
  96859. /**
  96860. * Sets the position of the emitter if spatial sound is enabled
  96861. * @param newPosition Defines the new posisiton
  96862. */
  96863. setPosition(newPosition: Vector3): void;
  96864. /**
  96865. * Sets the local direction of the emitter if spatial sound is enabled
  96866. * @param newLocalDirection Defines the new local direction
  96867. */
  96868. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  96869. private _updateDirection;
  96870. /** @hidden */
  96871. updateDistanceFromListener(): void;
  96872. /**
  96873. * Sets a new custom attenuation function for the sound.
  96874. * @param callback Defines the function used for the attenuation
  96875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96876. */
  96877. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  96878. /**
  96879. * Play the sound
  96880. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  96881. * @param offset (optional) Start the sound setting it at a specific time
  96882. */
  96883. play(time?: number, offset?: number): void;
  96884. private _onended;
  96885. /**
  96886. * Stop the sound
  96887. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  96888. */
  96889. stop(time?: number): void;
  96890. /**
  96891. * Put the sound in pause
  96892. */
  96893. pause(): void;
  96894. /**
  96895. * Sets a dedicated volume for this sounds
  96896. * @param newVolume Define the new volume of the sound
  96897. * @param time Define in how long the sound should be at this value
  96898. */
  96899. setVolume(newVolume: number, time?: number): void;
  96900. /**
  96901. * Set the sound play back rate
  96902. * @param newPlaybackRate Define the playback rate the sound should be played at
  96903. */
  96904. setPlaybackRate(newPlaybackRate: number): void;
  96905. /**
  96906. * Gets the volume of the sound.
  96907. * @returns the volume of the sound
  96908. */
  96909. getVolume(): number;
  96910. /**
  96911. * Attach the sound to a dedicated mesh
  96912. * @param transformNode The transform node to connect the sound with
  96913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96914. */
  96915. attachToMesh(transformNode: TransformNode): void;
  96916. /**
  96917. * Detach the sound from the previously attached mesh
  96918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96919. */
  96920. detachFromMesh(): void;
  96921. private _onRegisterAfterWorldMatrixUpdate;
  96922. /**
  96923. * Clone the current sound in the scene.
  96924. * @returns the new sound clone
  96925. */
  96926. clone(): Nullable<Sound>;
  96927. /**
  96928. * Gets the current underlying audio buffer containing the data
  96929. * @returns the audio buffer
  96930. */
  96931. getAudioBuffer(): Nullable<AudioBuffer>;
  96932. /**
  96933. * Serializes the Sound in a JSON representation
  96934. * @returns the JSON representation of the sound
  96935. */
  96936. serialize(): any;
  96937. /**
  96938. * Parse a JSON representation of a sound to innstantiate in a given scene
  96939. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  96940. * @param scene Define the scene the new parsed sound should be created in
  96941. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  96942. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  96943. * @returns the newly parsed sound
  96944. */
  96945. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  96946. }
  96947. }
  96948. declare module BABYLON {
  96949. /**
  96950. * This defines an action helpful to play a defined sound on a triggered action.
  96951. */
  96952. export class PlaySoundAction extends Action {
  96953. private _sound;
  96954. /**
  96955. * Instantiate the action
  96956. * @param triggerOptions defines the trigger options
  96957. * @param sound defines the sound to play
  96958. * @param condition defines the trigger related conditions
  96959. */
  96960. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96961. /** @hidden */
  96962. _prepare(): void;
  96963. /**
  96964. * Execute the action and play the sound.
  96965. */
  96966. execute(): void;
  96967. /**
  96968. * Serializes the actions and its related information.
  96969. * @param parent defines the object to serialize in
  96970. * @returns the serialized object
  96971. */
  96972. serialize(parent: any): any;
  96973. }
  96974. /**
  96975. * This defines an action helpful to stop a defined sound on a triggered action.
  96976. */
  96977. export class StopSoundAction extends Action {
  96978. private _sound;
  96979. /**
  96980. * Instantiate the action
  96981. * @param triggerOptions defines the trigger options
  96982. * @param sound defines the sound to stop
  96983. * @param condition defines the trigger related conditions
  96984. */
  96985. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96986. /** @hidden */
  96987. _prepare(): void;
  96988. /**
  96989. * Execute the action and stop the sound.
  96990. */
  96991. execute(): void;
  96992. /**
  96993. * Serializes the actions and its related information.
  96994. * @param parent defines the object to serialize in
  96995. * @returns the serialized object
  96996. */
  96997. serialize(parent: any): any;
  96998. }
  96999. }
  97000. declare module BABYLON {
  97001. /**
  97002. * This defines an action responsible to change the value of a property
  97003. * by interpolating between its current value and the newly set one once triggered.
  97004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97005. */
  97006. export class InterpolateValueAction extends Action {
  97007. /**
  97008. * Defines the path of the property where the value should be interpolated
  97009. */
  97010. propertyPath: string;
  97011. /**
  97012. * Defines the target value at the end of the interpolation.
  97013. */
  97014. value: any;
  97015. /**
  97016. * Defines the time it will take for the property to interpolate to the value.
  97017. */
  97018. duration: number;
  97019. /**
  97020. * Defines if the other scene animations should be stopped when the action has been triggered
  97021. */
  97022. stopOtherAnimations?: boolean;
  97023. /**
  97024. * Defines a callback raised once the interpolation animation has been done.
  97025. */
  97026. onInterpolationDone?: () => void;
  97027. /**
  97028. * Observable triggered once the interpolation animation has been done.
  97029. */
  97030. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97031. private _target;
  97032. private _effectiveTarget;
  97033. private _property;
  97034. /**
  97035. * Instantiate the action
  97036. * @param triggerOptions defines the trigger options
  97037. * @param target defines the object containing the value to interpolate
  97038. * @param propertyPath defines the path to the property in the target object
  97039. * @param value defines the target value at the end of the interpolation
  97040. * @param duration deines the time it will take for the property to interpolate to the value.
  97041. * @param condition defines the trigger related conditions
  97042. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97043. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97044. */
  97045. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97046. /** @hidden */
  97047. _prepare(): void;
  97048. /**
  97049. * Execute the action starts the value interpolation.
  97050. */
  97051. execute(): void;
  97052. /**
  97053. * Serializes the actions and its related information.
  97054. * @param parent defines the object to serialize in
  97055. * @returns the serialized object
  97056. */
  97057. serialize(parent: any): any;
  97058. }
  97059. }
  97060. declare module BABYLON {
  97061. /**
  97062. * Options allowed during the creation of a sound track.
  97063. */
  97064. export interface ISoundTrackOptions {
  97065. /**
  97066. * The volume the sound track should take during creation
  97067. */
  97068. volume?: number;
  97069. /**
  97070. * Define if the sound track is the main sound track of the scene
  97071. */
  97072. mainTrack?: boolean;
  97073. }
  97074. /**
  97075. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97076. * It will be also used in a future release to apply effects on a specific track.
  97077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97078. */
  97079. export class SoundTrack {
  97080. /**
  97081. * The unique identifier of the sound track in the scene.
  97082. */
  97083. id: number;
  97084. /**
  97085. * The list of sounds included in the sound track.
  97086. */
  97087. soundCollection: Array<Sound>;
  97088. private _outputAudioNode;
  97089. private _scene;
  97090. private _isMainTrack;
  97091. private _connectedAnalyser;
  97092. private _options;
  97093. private _isInitialized;
  97094. /**
  97095. * Creates a new sound track.
  97096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97097. * @param scene Define the scene the sound track belongs to
  97098. * @param options
  97099. */
  97100. constructor(scene: Scene, options?: ISoundTrackOptions);
  97101. private _initializeSoundTrackAudioGraph;
  97102. /**
  97103. * Release the sound track and its associated resources
  97104. */
  97105. dispose(): void;
  97106. /**
  97107. * Adds a sound to this sound track
  97108. * @param sound define the cound to add
  97109. * @ignoreNaming
  97110. */
  97111. AddSound(sound: Sound): void;
  97112. /**
  97113. * Removes a sound to this sound track
  97114. * @param sound define the cound to remove
  97115. * @ignoreNaming
  97116. */
  97117. RemoveSound(sound: Sound): void;
  97118. /**
  97119. * Set a global volume for the full sound track.
  97120. * @param newVolume Define the new volume of the sound track
  97121. */
  97122. setVolume(newVolume: number): void;
  97123. /**
  97124. * Switch the panning model to HRTF:
  97125. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97127. */
  97128. switchPanningModelToHRTF(): void;
  97129. /**
  97130. * Switch the panning model to Equal Power:
  97131. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97133. */
  97134. switchPanningModelToEqualPower(): void;
  97135. /**
  97136. * Connect the sound track to an audio analyser allowing some amazing
  97137. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97139. * @param analyser The analyser to connect to the engine
  97140. */
  97141. connectToAnalyser(analyser: Analyser): void;
  97142. }
  97143. }
  97144. declare module BABYLON {
  97145. interface AbstractScene {
  97146. /**
  97147. * The list of sounds used in the scene.
  97148. */
  97149. sounds: Nullable<Array<Sound>>;
  97150. }
  97151. interface Scene {
  97152. /**
  97153. * @hidden
  97154. * Backing field
  97155. */
  97156. _mainSoundTrack: SoundTrack;
  97157. /**
  97158. * The main sound track played by the scene.
  97159. * It cotains your primary collection of sounds.
  97160. */
  97161. mainSoundTrack: SoundTrack;
  97162. /**
  97163. * The list of sound tracks added to the scene
  97164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97165. */
  97166. soundTracks: Nullable<Array<SoundTrack>>;
  97167. /**
  97168. * Gets a sound using a given name
  97169. * @param name defines the name to search for
  97170. * @return the found sound or null if not found at all.
  97171. */
  97172. getSoundByName(name: string): Nullable<Sound>;
  97173. /**
  97174. * Gets or sets if audio support is enabled
  97175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97176. */
  97177. audioEnabled: boolean;
  97178. /**
  97179. * Gets or sets if audio will be output to headphones
  97180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97181. */
  97182. headphone: boolean;
  97183. }
  97184. /**
  97185. * Defines the sound scene component responsible to manage any sounds
  97186. * in a given scene.
  97187. */
  97188. export class AudioSceneComponent implements ISceneSerializableComponent {
  97189. /**
  97190. * The component name helpfull to identify the component in the list of scene components.
  97191. */
  97192. readonly name: string;
  97193. /**
  97194. * The scene the component belongs to.
  97195. */
  97196. scene: Scene;
  97197. private _audioEnabled;
  97198. /**
  97199. * Gets whether audio is enabled or not.
  97200. * Please use related enable/disable method to switch state.
  97201. */
  97202. readonly audioEnabled: boolean;
  97203. private _headphone;
  97204. /**
  97205. * Gets whether audio is outputing to headphone or not.
  97206. * Please use the according Switch methods to change output.
  97207. */
  97208. readonly headphone: boolean;
  97209. /**
  97210. * Creates a new instance of the component for the given scene
  97211. * @param scene Defines the scene to register the component in
  97212. */
  97213. constructor(scene: Scene);
  97214. /**
  97215. * Registers the component in a given scene
  97216. */
  97217. register(): void;
  97218. /**
  97219. * Rebuilds the elements related to this component in case of
  97220. * context lost for instance.
  97221. */
  97222. rebuild(): void;
  97223. /**
  97224. * Serializes the component data to the specified json object
  97225. * @param serializationObject The object to serialize to
  97226. */
  97227. serialize(serializationObject: any): void;
  97228. /**
  97229. * Adds all the elements from the container to the scene
  97230. * @param container the container holding the elements
  97231. */
  97232. addFromContainer(container: AbstractScene): void;
  97233. /**
  97234. * Removes all the elements in the container from the scene
  97235. * @param container contains the elements to remove
  97236. * @param dispose if the removed element should be disposed (default: false)
  97237. */
  97238. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97239. /**
  97240. * Disposes the component and the associated ressources.
  97241. */
  97242. dispose(): void;
  97243. /**
  97244. * Disables audio in the associated scene.
  97245. */
  97246. disableAudio(): void;
  97247. /**
  97248. * Enables audio in the associated scene.
  97249. */
  97250. enableAudio(): void;
  97251. /**
  97252. * Switch audio to headphone output.
  97253. */
  97254. switchAudioModeForHeadphones(): void;
  97255. /**
  97256. * Switch audio to normal speakers.
  97257. */
  97258. switchAudioModeForNormalSpeakers(): void;
  97259. private _afterRender;
  97260. }
  97261. }
  97262. declare module BABYLON {
  97263. /**
  97264. * Wraps one or more Sound objects and selects one with random weight for playback.
  97265. */
  97266. export class WeightedSound {
  97267. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97268. loop: boolean;
  97269. private _coneInnerAngle;
  97270. private _coneOuterAngle;
  97271. private _volume;
  97272. /** A Sound is currently playing. */
  97273. isPlaying: boolean;
  97274. /** A Sound is currently paused. */
  97275. isPaused: boolean;
  97276. private _sounds;
  97277. private _weights;
  97278. private _currentIndex?;
  97279. /**
  97280. * Creates a new WeightedSound from the list of sounds given.
  97281. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97282. * @param sounds Array of Sounds that will be selected from.
  97283. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97284. */
  97285. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97286. /**
  97287. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97288. */
  97289. /**
  97290. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97291. */
  97292. directionalConeInnerAngle: number;
  97293. /**
  97294. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97295. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97296. */
  97297. /**
  97298. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97299. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97300. */
  97301. directionalConeOuterAngle: number;
  97302. /**
  97303. * Playback volume.
  97304. */
  97305. /**
  97306. * Playback volume.
  97307. */
  97308. volume: number;
  97309. private _onended;
  97310. /**
  97311. * Suspend playback
  97312. */
  97313. pause(): void;
  97314. /**
  97315. * Stop playback
  97316. */
  97317. stop(): void;
  97318. /**
  97319. * Start playback.
  97320. * @param startOffset Position the clip head at a specific time in seconds.
  97321. */
  97322. play(startOffset?: number): void;
  97323. }
  97324. }
  97325. declare module BABYLON {
  97326. /**
  97327. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97328. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97329. */
  97330. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97331. /**
  97332. * Gets the name of the behavior.
  97333. */
  97334. readonly name: string;
  97335. /**
  97336. * The easing function used by animations
  97337. */
  97338. static EasingFunction: BackEase;
  97339. /**
  97340. * The easing mode used by animations
  97341. */
  97342. static EasingMode: number;
  97343. /**
  97344. * The duration of the animation, in milliseconds
  97345. */
  97346. transitionDuration: number;
  97347. /**
  97348. * Length of the distance animated by the transition when lower radius is reached
  97349. */
  97350. lowerRadiusTransitionRange: number;
  97351. /**
  97352. * Length of the distance animated by the transition when upper radius is reached
  97353. */
  97354. upperRadiusTransitionRange: number;
  97355. private _autoTransitionRange;
  97356. /**
  97357. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97358. */
  97359. /**
  97360. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97361. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97362. */
  97363. autoTransitionRange: boolean;
  97364. private _attachedCamera;
  97365. private _onAfterCheckInputsObserver;
  97366. private _onMeshTargetChangedObserver;
  97367. /**
  97368. * Initializes the behavior.
  97369. */
  97370. init(): void;
  97371. /**
  97372. * Attaches the behavior to its arc rotate camera.
  97373. * @param camera Defines the camera to attach the behavior to
  97374. */
  97375. attach(camera: ArcRotateCamera): void;
  97376. /**
  97377. * Detaches the behavior from its current arc rotate camera.
  97378. */
  97379. detach(): void;
  97380. private _radiusIsAnimating;
  97381. private _radiusBounceTransition;
  97382. private _animatables;
  97383. private _cachedWheelPrecision;
  97384. /**
  97385. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97386. * @param radiusLimit The limit to check against.
  97387. * @return Bool to indicate if at limit.
  97388. */
  97389. private _isRadiusAtLimit;
  97390. /**
  97391. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97392. * @param radiusDelta The delta by which to animate to. Can be negative.
  97393. */
  97394. private _applyBoundRadiusAnimation;
  97395. /**
  97396. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97397. */
  97398. protected _clearAnimationLocks(): void;
  97399. /**
  97400. * Stops and removes all animations that have been applied to the camera
  97401. */
  97402. stopAllAnimations(): void;
  97403. }
  97404. }
  97405. declare module BABYLON {
  97406. /**
  97407. * 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.
  97408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97409. */
  97410. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97411. /**
  97412. * Gets the name of the behavior.
  97413. */
  97414. readonly name: string;
  97415. private _mode;
  97416. private _radiusScale;
  97417. private _positionScale;
  97418. private _defaultElevation;
  97419. private _elevationReturnTime;
  97420. private _elevationReturnWaitTime;
  97421. private _zoomStopsAnimation;
  97422. private _framingTime;
  97423. /**
  97424. * The easing function used by animations
  97425. */
  97426. static EasingFunction: ExponentialEase;
  97427. /**
  97428. * The easing mode used by animations
  97429. */
  97430. static EasingMode: number;
  97431. /**
  97432. * Sets the current mode used by the behavior
  97433. */
  97434. /**
  97435. * Gets current mode used by the behavior.
  97436. */
  97437. mode: number;
  97438. /**
  97439. * Sets the scale applied to the radius (1 by default)
  97440. */
  97441. /**
  97442. * Gets the scale applied to the radius
  97443. */
  97444. radiusScale: number;
  97445. /**
  97446. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97447. */
  97448. /**
  97449. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97450. */
  97451. positionScale: number;
  97452. /**
  97453. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97454. * behaviour is triggered, in radians.
  97455. */
  97456. /**
  97457. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97458. * behaviour is triggered, in radians.
  97459. */
  97460. defaultElevation: number;
  97461. /**
  97462. * Sets the time (in milliseconds) taken to return to the default beta position.
  97463. * Negative value indicates camera should not return to default.
  97464. */
  97465. /**
  97466. * Gets the time (in milliseconds) taken to return to the default beta position.
  97467. * Negative value indicates camera should not return to default.
  97468. */
  97469. elevationReturnTime: number;
  97470. /**
  97471. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97472. */
  97473. /**
  97474. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97475. */
  97476. elevationReturnWaitTime: number;
  97477. /**
  97478. * Sets the flag that indicates if user zooming should stop animation.
  97479. */
  97480. /**
  97481. * Gets the flag that indicates if user zooming should stop animation.
  97482. */
  97483. zoomStopsAnimation: boolean;
  97484. /**
  97485. * Sets the transition time when framing the mesh, in milliseconds
  97486. */
  97487. /**
  97488. * Gets the transition time when framing the mesh, in milliseconds
  97489. */
  97490. framingTime: number;
  97491. /**
  97492. * Define if the behavior should automatically change the configured
  97493. * camera limits and sensibilities.
  97494. */
  97495. autoCorrectCameraLimitsAndSensibility: boolean;
  97496. private _onPrePointerObservableObserver;
  97497. private _onAfterCheckInputsObserver;
  97498. private _onMeshTargetChangedObserver;
  97499. private _attachedCamera;
  97500. private _isPointerDown;
  97501. private _lastInteractionTime;
  97502. /**
  97503. * Initializes the behavior.
  97504. */
  97505. init(): void;
  97506. /**
  97507. * Attaches the behavior to its arc rotate camera.
  97508. * @param camera Defines the camera to attach the behavior to
  97509. */
  97510. attach(camera: ArcRotateCamera): void;
  97511. /**
  97512. * Detaches the behavior from its current arc rotate camera.
  97513. */
  97514. detach(): void;
  97515. private _animatables;
  97516. private _betaIsAnimating;
  97517. private _betaTransition;
  97518. private _radiusTransition;
  97519. private _vectorTransition;
  97520. /**
  97521. * Targets the given mesh and updates zoom level accordingly.
  97522. * @param mesh The mesh to target.
  97523. * @param radius Optional. If a cached radius position already exists, overrides default.
  97524. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97525. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97526. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97527. */
  97528. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97529. /**
  97530. * Targets the given mesh with its children and updates zoom level accordingly.
  97531. * @param mesh The mesh to target.
  97532. * @param radius Optional. If a cached radius position already exists, overrides default.
  97533. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97534. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97535. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97536. */
  97537. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97538. /**
  97539. * Targets the given meshes with their children and updates zoom level accordingly.
  97540. * @param meshes The mesh to target.
  97541. * @param radius Optional. If a cached radius position already exists, overrides default.
  97542. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97543. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97544. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97545. */
  97546. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97547. /**
  97548. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97549. * @param minimumWorld Determines the smaller position of the bounding box extend
  97550. * @param maximumWorld Determines the bigger position of the bounding box extend
  97551. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97552. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97553. */
  97554. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97555. /**
  97556. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97557. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97558. * frustum width.
  97559. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97560. * to fully enclose the mesh in the viewing frustum.
  97561. */
  97562. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97563. /**
  97564. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97565. * is automatically returned to its default position (expected to be above ground plane).
  97566. */
  97567. private _maintainCameraAboveGround;
  97568. /**
  97569. * Returns the frustum slope based on the canvas ratio and camera FOV
  97570. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97571. */
  97572. private _getFrustumSlope;
  97573. /**
  97574. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97575. */
  97576. private _clearAnimationLocks;
  97577. /**
  97578. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97579. */
  97580. private _applyUserInteraction;
  97581. /**
  97582. * Stops and removes all animations that have been applied to the camera
  97583. */
  97584. stopAllAnimations(): void;
  97585. /**
  97586. * Gets a value indicating if the user is moving the camera
  97587. */
  97588. readonly isUserIsMoving: boolean;
  97589. /**
  97590. * The camera can move all the way towards the mesh.
  97591. */
  97592. static IgnoreBoundsSizeMode: number;
  97593. /**
  97594. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97595. */
  97596. static FitFrustumSidesMode: number;
  97597. }
  97598. }
  97599. declare module BABYLON {
  97600. /**
  97601. * Base class for Camera Pointer Inputs.
  97602. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97603. * for example usage.
  97604. */
  97605. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97606. /**
  97607. * Defines the camera the input is attached to.
  97608. */
  97609. abstract camera: Camera;
  97610. /**
  97611. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97612. */
  97613. protected _altKey: boolean;
  97614. protected _ctrlKey: boolean;
  97615. protected _metaKey: boolean;
  97616. protected _shiftKey: boolean;
  97617. /**
  97618. * Which mouse buttons were pressed at time of last mouse event.
  97619. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97620. */
  97621. protected _buttonsPressed: number;
  97622. /**
  97623. * Defines the buttons associated with the input to handle camera move.
  97624. */
  97625. buttons: number[];
  97626. /**
  97627. * Attach the input controls to a specific dom element to get the input from.
  97628. * @param element Defines the element the controls should be listened from
  97629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97630. */
  97631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97632. /**
  97633. * Detach the current controls from the specified dom element.
  97634. * @param element Defines the element to stop listening the inputs from
  97635. */
  97636. detachControl(element: Nullable<HTMLElement>): void;
  97637. /**
  97638. * Gets the class name of the current input.
  97639. * @returns the class name
  97640. */
  97641. getClassName(): string;
  97642. /**
  97643. * Get the friendly name associated with the input class.
  97644. * @returns the input friendly name
  97645. */
  97646. getSimpleName(): string;
  97647. /**
  97648. * Called on pointer POINTERDOUBLETAP event.
  97649. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97650. */
  97651. protected onDoubleTap(type: string): void;
  97652. /**
  97653. * Called on pointer POINTERMOVE event if only a single touch is active.
  97654. * Override this method to provide functionality.
  97655. */
  97656. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97657. /**
  97658. * Called on pointer POINTERMOVE event if multiple touches are active.
  97659. * Override this method to provide functionality.
  97660. */
  97661. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97662. /**
  97663. * Called on JS contextmenu event.
  97664. * Override this method to provide functionality.
  97665. */
  97666. protected onContextMenu(evt: PointerEvent): void;
  97667. /**
  97668. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97669. * press.
  97670. * Override this method to provide functionality.
  97671. */
  97672. protected onButtonDown(evt: PointerEvent): void;
  97673. /**
  97674. * Called each time a new POINTERUP event occurs. Ie, for each button
  97675. * release.
  97676. * Override this method to provide functionality.
  97677. */
  97678. protected onButtonUp(evt: PointerEvent): void;
  97679. /**
  97680. * Called when window becomes inactive.
  97681. * Override this method to provide functionality.
  97682. */
  97683. protected onLostFocus(): void;
  97684. private _pointerInput;
  97685. private _observer;
  97686. private _onLostFocus;
  97687. private pointA;
  97688. private pointB;
  97689. }
  97690. }
  97691. declare module BABYLON {
  97692. /**
  97693. * Manage the pointers inputs to control an arc rotate camera.
  97694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97695. */
  97696. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97697. /**
  97698. * Defines the camera the input is attached to.
  97699. */
  97700. camera: ArcRotateCamera;
  97701. /**
  97702. * Gets the class name of the current input.
  97703. * @returns the class name
  97704. */
  97705. getClassName(): string;
  97706. /**
  97707. * Defines the buttons associated with the input to handle camera move.
  97708. */
  97709. buttons: number[];
  97710. /**
  97711. * Defines the pointer angular sensibility along the X axis or how fast is
  97712. * the camera rotating.
  97713. */
  97714. angularSensibilityX: number;
  97715. /**
  97716. * Defines the pointer angular sensibility along the Y axis or how fast is
  97717. * the camera rotating.
  97718. */
  97719. angularSensibilityY: number;
  97720. /**
  97721. * Defines the pointer pinch precision or how fast is the camera zooming.
  97722. */
  97723. pinchPrecision: number;
  97724. /**
  97725. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97726. * from 0.
  97727. * It defines the percentage of current camera.radius to use as delta when
  97728. * pinch zoom is used.
  97729. */
  97730. pinchDeltaPercentage: number;
  97731. /**
  97732. * Defines the pointer panning sensibility or how fast is the camera moving.
  97733. */
  97734. panningSensibility: number;
  97735. /**
  97736. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  97737. */
  97738. multiTouchPanning: boolean;
  97739. /**
  97740. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  97741. * zoom (pinch) through multitouch.
  97742. */
  97743. multiTouchPanAndZoom: boolean;
  97744. /**
  97745. * Revers pinch action direction.
  97746. */
  97747. pinchInwards: boolean;
  97748. private _isPanClick;
  97749. private _twoFingerActivityCount;
  97750. private _isPinching;
  97751. /**
  97752. * Called on pointer POINTERMOVE event if only a single touch is active.
  97753. */
  97754. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97755. /**
  97756. * Called on pointer POINTERDOUBLETAP event.
  97757. */
  97758. protected onDoubleTap(type: string): void;
  97759. /**
  97760. * Called on pointer POINTERMOVE event if multiple touches are active.
  97761. */
  97762. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97763. /**
  97764. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97765. * press.
  97766. */
  97767. protected onButtonDown(evt: PointerEvent): void;
  97768. /**
  97769. * Called each time a new POINTERUP event occurs. Ie, for each button
  97770. * release.
  97771. */
  97772. protected onButtonUp(evt: PointerEvent): void;
  97773. /**
  97774. * Called when window becomes inactive.
  97775. */
  97776. protected onLostFocus(): void;
  97777. }
  97778. }
  97779. declare module BABYLON {
  97780. /**
  97781. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  97782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97783. */
  97784. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  97785. /**
  97786. * Defines the camera the input is attached to.
  97787. */
  97788. camera: ArcRotateCamera;
  97789. /**
  97790. * Defines the list of key codes associated with the up action (increase alpha)
  97791. */
  97792. keysUp: number[];
  97793. /**
  97794. * Defines the list of key codes associated with the down action (decrease alpha)
  97795. */
  97796. keysDown: number[];
  97797. /**
  97798. * Defines the list of key codes associated with the left action (increase beta)
  97799. */
  97800. keysLeft: number[];
  97801. /**
  97802. * Defines the list of key codes associated with the right action (decrease beta)
  97803. */
  97804. keysRight: number[];
  97805. /**
  97806. * Defines the list of key codes associated with the reset action.
  97807. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  97808. */
  97809. keysReset: number[];
  97810. /**
  97811. * Defines the panning sensibility of the inputs.
  97812. * (How fast is the camera paning)
  97813. */
  97814. panningSensibility: number;
  97815. /**
  97816. * Defines the zooming sensibility of the inputs.
  97817. * (How fast is the camera zooming)
  97818. */
  97819. zoomingSensibility: number;
  97820. /**
  97821. * Defines wether maintaining the alt key down switch the movement mode from
  97822. * orientation to zoom.
  97823. */
  97824. useAltToZoom: boolean;
  97825. /**
  97826. * Rotation speed of the camera
  97827. */
  97828. angularSpeed: number;
  97829. private _keys;
  97830. private _ctrlPressed;
  97831. private _altPressed;
  97832. private _onCanvasBlurObserver;
  97833. private _onKeyboardObserver;
  97834. private _engine;
  97835. private _scene;
  97836. /**
  97837. * Attach the input controls to a specific dom element to get the input from.
  97838. * @param element Defines the element the controls should be listened from
  97839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97840. */
  97841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97842. /**
  97843. * Detach the current controls from the specified dom element.
  97844. * @param element Defines the element to stop listening the inputs from
  97845. */
  97846. detachControl(element: Nullable<HTMLElement>): void;
  97847. /**
  97848. * Update the current camera state depending on the inputs that have been used this frame.
  97849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97850. */
  97851. checkInputs(): void;
  97852. /**
  97853. * Gets the class name of the current intput.
  97854. * @returns the class name
  97855. */
  97856. getClassName(): string;
  97857. /**
  97858. * Get the friendly name associated with the input class.
  97859. * @returns the input friendly name
  97860. */
  97861. getSimpleName(): string;
  97862. }
  97863. }
  97864. declare module BABYLON {
  97865. /**
  97866. * Manage the mouse wheel inputs to control an arc rotate camera.
  97867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97868. */
  97869. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  97870. /**
  97871. * Defines the camera the input is attached to.
  97872. */
  97873. camera: ArcRotateCamera;
  97874. /**
  97875. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97876. */
  97877. wheelPrecision: number;
  97878. /**
  97879. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  97880. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  97881. */
  97882. wheelDeltaPercentage: number;
  97883. private _wheel;
  97884. private _observer;
  97885. private computeDeltaFromMouseWheelLegacyEvent;
  97886. /**
  97887. * Attach the input controls to a specific dom element to get the input from.
  97888. * @param element Defines the element the controls should be listened from
  97889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97890. */
  97891. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97892. /**
  97893. * Detach the current controls from the specified dom element.
  97894. * @param element Defines the element to stop listening the inputs from
  97895. */
  97896. detachControl(element: Nullable<HTMLElement>): void;
  97897. /**
  97898. * Gets the class name of the current intput.
  97899. * @returns the class name
  97900. */
  97901. getClassName(): string;
  97902. /**
  97903. * Get the friendly name associated with the input class.
  97904. * @returns the input friendly name
  97905. */
  97906. getSimpleName(): string;
  97907. }
  97908. }
  97909. declare module BABYLON {
  97910. /**
  97911. * Default Inputs manager for the ArcRotateCamera.
  97912. * It groups all the default supported inputs for ease of use.
  97913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97914. */
  97915. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  97916. /**
  97917. * Instantiates a new ArcRotateCameraInputsManager.
  97918. * @param camera Defines the camera the inputs belong to
  97919. */
  97920. constructor(camera: ArcRotateCamera);
  97921. /**
  97922. * Add mouse wheel input support to the input manager.
  97923. * @returns the current input manager
  97924. */
  97925. addMouseWheel(): ArcRotateCameraInputsManager;
  97926. /**
  97927. * Add pointers input support to the input manager.
  97928. * @returns the current input manager
  97929. */
  97930. addPointers(): ArcRotateCameraInputsManager;
  97931. /**
  97932. * Add keyboard input support to the input manager.
  97933. * @returns the current input manager
  97934. */
  97935. addKeyboard(): ArcRotateCameraInputsManager;
  97936. }
  97937. }
  97938. declare module BABYLON {
  97939. /**
  97940. * This represents an orbital type of camera.
  97941. *
  97942. * 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.
  97943. * 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.
  97944. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  97945. */
  97946. export class ArcRotateCamera extends TargetCamera {
  97947. /**
  97948. * Defines the rotation angle of the camera along the longitudinal axis.
  97949. */
  97950. alpha: number;
  97951. /**
  97952. * Defines the rotation angle of the camera along the latitudinal axis.
  97953. */
  97954. beta: number;
  97955. /**
  97956. * Defines the radius of the camera from it s target point.
  97957. */
  97958. radius: number;
  97959. protected _target: Vector3;
  97960. protected _targetHost: Nullable<AbstractMesh>;
  97961. /**
  97962. * Defines the target point of the camera.
  97963. * The camera looks towards it form the radius distance.
  97964. */
  97965. target: Vector3;
  97966. /**
  97967. * Define the current local position of the camera in the scene
  97968. */
  97969. position: Vector3;
  97970. protected _upVector: Vector3;
  97971. protected _upToYMatrix: Matrix;
  97972. protected _YToUpMatrix: Matrix;
  97973. /**
  97974. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  97975. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  97976. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  97977. */
  97978. upVector: Vector3;
  97979. /**
  97980. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  97981. */
  97982. setMatUp(): void;
  97983. /**
  97984. * Current inertia value on the longitudinal axis.
  97985. * The bigger this number the longer it will take for the camera to stop.
  97986. */
  97987. inertialAlphaOffset: number;
  97988. /**
  97989. * Current inertia value on the latitudinal axis.
  97990. * The bigger this number the longer it will take for the camera to stop.
  97991. */
  97992. inertialBetaOffset: number;
  97993. /**
  97994. * Current inertia value on the radius axis.
  97995. * The bigger this number the longer it will take for the camera to stop.
  97996. */
  97997. inertialRadiusOffset: number;
  97998. /**
  97999. * Minimum allowed angle on the longitudinal axis.
  98000. * This can help limiting how the Camera is able to move in the scene.
  98001. */
  98002. lowerAlphaLimit: Nullable<number>;
  98003. /**
  98004. * Maximum allowed angle on the longitudinal axis.
  98005. * This can help limiting how the Camera is able to move in the scene.
  98006. */
  98007. upperAlphaLimit: Nullable<number>;
  98008. /**
  98009. * Minimum allowed angle on the latitudinal axis.
  98010. * This can help limiting how the Camera is able to move in the scene.
  98011. */
  98012. lowerBetaLimit: number;
  98013. /**
  98014. * Maximum allowed angle on the latitudinal axis.
  98015. * This can help limiting how the Camera is able to move in the scene.
  98016. */
  98017. upperBetaLimit: number;
  98018. /**
  98019. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98020. * This can help limiting how the Camera is able to move in the scene.
  98021. */
  98022. lowerRadiusLimit: Nullable<number>;
  98023. /**
  98024. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98025. * This can help limiting how the Camera is able to move in the scene.
  98026. */
  98027. upperRadiusLimit: Nullable<number>;
  98028. /**
  98029. * Defines the current inertia value used during panning of the camera along the X axis.
  98030. */
  98031. inertialPanningX: number;
  98032. /**
  98033. * Defines the current inertia value used during panning of the camera along the Y axis.
  98034. */
  98035. inertialPanningY: number;
  98036. /**
  98037. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98038. * Basically if your fingers moves away from more than this distance you will be considered
  98039. * in pinch mode.
  98040. */
  98041. pinchToPanMaxDistance: number;
  98042. /**
  98043. * Defines the maximum distance the camera can pan.
  98044. * This could help keeping the cammera always in your scene.
  98045. */
  98046. panningDistanceLimit: Nullable<number>;
  98047. /**
  98048. * Defines the target of the camera before paning.
  98049. */
  98050. panningOriginTarget: Vector3;
  98051. /**
  98052. * Defines the value of the inertia used during panning.
  98053. * 0 would mean stop inertia and one would mean no decelleration at all.
  98054. */
  98055. panningInertia: number;
  98056. /**
  98057. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98058. */
  98059. angularSensibilityX: number;
  98060. /**
  98061. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98062. */
  98063. angularSensibilityY: number;
  98064. /**
  98065. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98066. */
  98067. pinchPrecision: number;
  98068. /**
  98069. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98070. * It will be used instead of pinchDeltaPrecision if different from 0.
  98071. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98072. */
  98073. pinchDeltaPercentage: number;
  98074. /**
  98075. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98076. */
  98077. panningSensibility: number;
  98078. /**
  98079. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98080. */
  98081. keysUp: number[];
  98082. /**
  98083. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98084. */
  98085. keysDown: number[];
  98086. /**
  98087. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98088. */
  98089. keysLeft: number[];
  98090. /**
  98091. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98092. */
  98093. keysRight: number[];
  98094. /**
  98095. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98096. */
  98097. wheelPrecision: number;
  98098. /**
  98099. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98100. * It will be used instead of pinchDeltaPrecision if different from 0.
  98101. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98102. */
  98103. wheelDeltaPercentage: number;
  98104. /**
  98105. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98106. */
  98107. zoomOnFactor: number;
  98108. /**
  98109. * Defines a screen offset for the camera position.
  98110. */
  98111. targetScreenOffset: Vector2;
  98112. /**
  98113. * Allows the camera to be completely reversed.
  98114. * If false the camera can not arrive upside down.
  98115. */
  98116. allowUpsideDown: boolean;
  98117. /**
  98118. * Define if double tap/click is used to restore the previously saved state of the camera.
  98119. */
  98120. useInputToRestoreState: boolean;
  98121. /** @hidden */
  98122. _viewMatrix: Matrix;
  98123. /** @hidden */
  98124. _useCtrlForPanning: boolean;
  98125. /** @hidden */
  98126. _panningMouseButton: number;
  98127. /**
  98128. * Defines the input associated to the camera.
  98129. */
  98130. inputs: ArcRotateCameraInputsManager;
  98131. /** @hidden */
  98132. _reset: () => void;
  98133. /**
  98134. * Defines the allowed panning axis.
  98135. */
  98136. panningAxis: Vector3;
  98137. protected _localDirection: Vector3;
  98138. protected _transformedDirection: Vector3;
  98139. private _bouncingBehavior;
  98140. /**
  98141. * Gets the bouncing behavior of the camera if it has been enabled.
  98142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98143. */
  98144. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98145. /**
  98146. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98148. */
  98149. useBouncingBehavior: boolean;
  98150. private _framingBehavior;
  98151. /**
  98152. * Gets the framing behavior of the camera if it has been enabled.
  98153. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98154. */
  98155. readonly framingBehavior: Nullable<FramingBehavior>;
  98156. /**
  98157. * Defines if the framing behavior of the camera is enabled on the camera.
  98158. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98159. */
  98160. useFramingBehavior: boolean;
  98161. private _autoRotationBehavior;
  98162. /**
  98163. * Gets the auto rotation behavior of the camera if it has been enabled.
  98164. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98165. */
  98166. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98167. /**
  98168. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98169. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98170. */
  98171. useAutoRotationBehavior: boolean;
  98172. /**
  98173. * Observable triggered when the mesh target has been changed on the camera.
  98174. */
  98175. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98176. /**
  98177. * Event raised when the camera is colliding with a mesh.
  98178. */
  98179. onCollide: (collidedMesh: AbstractMesh) => void;
  98180. /**
  98181. * Defines whether the camera should check collision with the objects oh the scene.
  98182. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98183. */
  98184. checkCollisions: boolean;
  98185. /**
  98186. * Defines the collision radius of the camera.
  98187. * This simulates a sphere around the camera.
  98188. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98189. */
  98190. collisionRadius: Vector3;
  98191. protected _collider: Collider;
  98192. protected _previousPosition: Vector3;
  98193. protected _collisionVelocity: Vector3;
  98194. protected _newPosition: Vector3;
  98195. protected _previousAlpha: number;
  98196. protected _previousBeta: number;
  98197. protected _previousRadius: number;
  98198. protected _collisionTriggered: boolean;
  98199. protected _targetBoundingCenter: Nullable<Vector3>;
  98200. private _computationVector;
  98201. /**
  98202. * Instantiates a new ArcRotateCamera in a given scene
  98203. * @param name Defines the name of the camera
  98204. * @param alpha Defines the camera rotation along the logitudinal axis
  98205. * @param beta Defines the camera rotation along the latitudinal axis
  98206. * @param radius Defines the camera distance from its target
  98207. * @param target Defines the camera target
  98208. * @param scene Defines the scene the camera belongs to
  98209. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98210. */
  98211. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98212. /** @hidden */
  98213. _initCache(): void;
  98214. /** @hidden */
  98215. _updateCache(ignoreParentClass?: boolean): void;
  98216. protected _getTargetPosition(): Vector3;
  98217. private _storedAlpha;
  98218. private _storedBeta;
  98219. private _storedRadius;
  98220. private _storedTarget;
  98221. /**
  98222. * Stores the current state of the camera (alpha, beta, radius and target)
  98223. * @returns the camera itself
  98224. */
  98225. storeState(): Camera;
  98226. /**
  98227. * @hidden
  98228. * Restored camera state. You must call storeState() first
  98229. */
  98230. _restoreStateValues(): boolean;
  98231. /** @hidden */
  98232. _isSynchronizedViewMatrix(): boolean;
  98233. /**
  98234. * Attached controls to the current camera.
  98235. * @param element Defines the element the controls should be listened from
  98236. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98237. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98238. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98239. */
  98240. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98241. /**
  98242. * Detach the current controls from the camera.
  98243. * The camera will stop reacting to inputs.
  98244. * @param element Defines the element to stop listening the inputs from
  98245. */
  98246. detachControl(element: HTMLElement): void;
  98247. /** @hidden */
  98248. _checkInputs(): void;
  98249. protected _checkLimits(): void;
  98250. /**
  98251. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98252. */
  98253. rebuildAnglesAndRadius(): void;
  98254. /**
  98255. * Use a position to define the current camera related information like aplha, beta and radius
  98256. * @param position Defines the position to set the camera at
  98257. */
  98258. setPosition(position: Vector3): void;
  98259. /**
  98260. * Defines the target the camera should look at.
  98261. * This will automatically adapt alpha beta and radius to fit within the new target.
  98262. * @param target Defines the new target as a Vector or a mesh
  98263. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98264. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98265. */
  98266. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98267. /** @hidden */
  98268. _getViewMatrix(): Matrix;
  98269. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98270. /**
  98271. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98272. * @param meshes Defines the mesh to zoom on
  98273. * @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)
  98274. */
  98275. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98276. /**
  98277. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98278. * The target will be changed but the radius
  98279. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98280. * @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)
  98281. */
  98282. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98283. min: Vector3;
  98284. max: Vector3;
  98285. distance: number;
  98286. }, doNotUpdateMaxZ?: boolean): void;
  98287. /**
  98288. * @override
  98289. * Override Camera.createRigCamera
  98290. */
  98291. createRigCamera(name: string, cameraIndex: number): Camera;
  98292. /**
  98293. * @hidden
  98294. * @override
  98295. * Override Camera._updateRigCameras
  98296. */
  98297. _updateRigCameras(): void;
  98298. /**
  98299. * Destroy the camera and release the current resources hold by it.
  98300. */
  98301. dispose(): void;
  98302. /**
  98303. * Gets the current object class name.
  98304. * @return the class name
  98305. */
  98306. getClassName(): string;
  98307. }
  98308. }
  98309. declare module BABYLON {
  98310. /**
  98311. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98312. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98313. */
  98314. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98315. /**
  98316. * Gets the name of the behavior.
  98317. */
  98318. readonly name: string;
  98319. private _zoomStopsAnimation;
  98320. private _idleRotationSpeed;
  98321. private _idleRotationWaitTime;
  98322. private _idleRotationSpinupTime;
  98323. /**
  98324. * Sets the flag that indicates if user zooming should stop animation.
  98325. */
  98326. /**
  98327. * Gets the flag that indicates if user zooming should stop animation.
  98328. */
  98329. zoomStopsAnimation: boolean;
  98330. /**
  98331. * Sets the default speed at which the camera rotates around the model.
  98332. */
  98333. /**
  98334. * Gets the default speed at which the camera rotates around the model.
  98335. */
  98336. idleRotationSpeed: number;
  98337. /**
  98338. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98339. */
  98340. /**
  98341. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98342. */
  98343. idleRotationWaitTime: number;
  98344. /**
  98345. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98346. */
  98347. /**
  98348. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98349. */
  98350. idleRotationSpinupTime: number;
  98351. /**
  98352. * Gets a value indicating if the camera is currently rotating because of this behavior
  98353. */
  98354. readonly rotationInProgress: boolean;
  98355. private _onPrePointerObservableObserver;
  98356. private _onAfterCheckInputsObserver;
  98357. private _attachedCamera;
  98358. private _isPointerDown;
  98359. private _lastFrameTime;
  98360. private _lastInteractionTime;
  98361. private _cameraRotationSpeed;
  98362. /**
  98363. * Initializes the behavior.
  98364. */
  98365. init(): void;
  98366. /**
  98367. * Attaches the behavior to its arc rotate camera.
  98368. * @param camera Defines the camera to attach the behavior to
  98369. */
  98370. attach(camera: ArcRotateCamera): void;
  98371. /**
  98372. * Detaches the behavior from its current arc rotate camera.
  98373. */
  98374. detach(): void;
  98375. /**
  98376. * Returns true if user is scrolling.
  98377. * @return true if user is scrolling.
  98378. */
  98379. private _userIsZooming;
  98380. private _lastFrameRadius;
  98381. private _shouldAnimationStopForInteraction;
  98382. /**
  98383. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98384. */
  98385. private _applyUserInteraction;
  98386. private _userIsMoving;
  98387. }
  98388. }
  98389. declare module BABYLON {
  98390. /**
  98391. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98392. */
  98393. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98394. private ui;
  98395. /**
  98396. * The name of the behavior
  98397. */
  98398. name: string;
  98399. /**
  98400. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98401. */
  98402. distanceAwayFromFace: number;
  98403. /**
  98404. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98405. */
  98406. distanceAwayFromBottomOfFace: number;
  98407. private _faceVectors;
  98408. private _target;
  98409. private _scene;
  98410. private _onRenderObserver;
  98411. private _tmpMatrix;
  98412. private _tmpVector;
  98413. /**
  98414. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98415. * @param ui The transform node that should be attched to the mesh
  98416. */
  98417. constructor(ui: TransformNode);
  98418. /**
  98419. * Initializes the behavior
  98420. */
  98421. init(): void;
  98422. private _closestFace;
  98423. private _zeroVector;
  98424. private _lookAtTmpMatrix;
  98425. private _lookAtToRef;
  98426. /**
  98427. * Attaches the AttachToBoxBehavior to the passed in mesh
  98428. * @param target The mesh that the specified node will be attached to
  98429. */
  98430. attach(target: Mesh): void;
  98431. /**
  98432. * Detaches the behavior from the mesh
  98433. */
  98434. detach(): void;
  98435. }
  98436. }
  98437. declare module BABYLON {
  98438. /**
  98439. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98440. */
  98441. export class FadeInOutBehavior implements Behavior<Mesh> {
  98442. /**
  98443. * Time in milliseconds to delay before fading in (Default: 0)
  98444. */
  98445. delay: number;
  98446. /**
  98447. * Time in milliseconds for the mesh to fade in (Default: 300)
  98448. */
  98449. fadeInTime: number;
  98450. private _millisecondsPerFrame;
  98451. private _hovered;
  98452. private _hoverValue;
  98453. private _ownerNode;
  98454. /**
  98455. * Instatiates the FadeInOutBehavior
  98456. */
  98457. constructor();
  98458. /**
  98459. * The name of the behavior
  98460. */
  98461. readonly name: string;
  98462. /**
  98463. * Initializes the behavior
  98464. */
  98465. init(): void;
  98466. /**
  98467. * Attaches the fade behavior on the passed in mesh
  98468. * @param ownerNode The mesh that will be faded in/out once attached
  98469. */
  98470. attach(ownerNode: Mesh): void;
  98471. /**
  98472. * Detaches the behavior from the mesh
  98473. */
  98474. detach(): void;
  98475. /**
  98476. * Triggers the mesh to begin fading in or out
  98477. * @param value if the object should fade in or out (true to fade in)
  98478. */
  98479. fadeIn(value: boolean): void;
  98480. private _update;
  98481. private _setAllVisibility;
  98482. }
  98483. }
  98484. declare module BABYLON {
  98485. /**
  98486. * Class containing a set of static utilities functions for managing Pivots
  98487. * @hidden
  98488. */
  98489. export class PivotTools {
  98490. private static _PivotCached;
  98491. private static _OldPivotPoint;
  98492. private static _PivotTranslation;
  98493. private static _PivotTmpVector;
  98494. /** @hidden */
  98495. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98496. /** @hidden */
  98497. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98498. }
  98499. }
  98500. declare module BABYLON {
  98501. /**
  98502. * Class containing static functions to help procedurally build meshes
  98503. */
  98504. export class PlaneBuilder {
  98505. /**
  98506. * Creates a plane mesh
  98507. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98508. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98509. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98513. * @param name defines the name of the mesh
  98514. * @param options defines the options used to create the mesh
  98515. * @param scene defines the hosting scene
  98516. * @returns the plane mesh
  98517. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98518. */
  98519. static CreatePlane(name: string, options: {
  98520. size?: number;
  98521. width?: number;
  98522. height?: number;
  98523. sideOrientation?: number;
  98524. frontUVs?: Vector4;
  98525. backUVs?: Vector4;
  98526. updatable?: boolean;
  98527. sourcePlane?: Plane;
  98528. }, scene?: Nullable<Scene>): Mesh;
  98529. }
  98530. }
  98531. declare module BABYLON {
  98532. /**
  98533. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98534. */
  98535. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98536. private static _AnyMouseID;
  98537. /**
  98538. * Abstract mesh the behavior is set on
  98539. */
  98540. attachedNode: AbstractMesh;
  98541. private _dragPlane;
  98542. private _scene;
  98543. private _pointerObserver;
  98544. private _beforeRenderObserver;
  98545. private static _planeScene;
  98546. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98547. /**
  98548. * 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)
  98549. */
  98550. maxDragAngle: number;
  98551. /**
  98552. * @hidden
  98553. */
  98554. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98555. /**
  98556. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98557. */
  98558. currentDraggingPointerID: number;
  98559. /**
  98560. * The last position where the pointer hit the drag plane in world space
  98561. */
  98562. lastDragPosition: Vector3;
  98563. /**
  98564. * If the behavior is currently in a dragging state
  98565. */
  98566. dragging: boolean;
  98567. /**
  98568. * 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)
  98569. */
  98570. dragDeltaRatio: number;
  98571. /**
  98572. * If the drag plane orientation should be updated during the dragging (Default: true)
  98573. */
  98574. updateDragPlane: boolean;
  98575. private _debugMode;
  98576. private _moving;
  98577. /**
  98578. * Fires each time the attached mesh is dragged with the pointer
  98579. * * delta between last drag position and current drag position in world space
  98580. * * dragDistance along the drag axis
  98581. * * dragPlaneNormal normal of the current drag plane used during the drag
  98582. * * dragPlanePoint in world space where the drag intersects the drag plane
  98583. */
  98584. onDragObservable: Observable<{
  98585. delta: Vector3;
  98586. dragPlanePoint: Vector3;
  98587. dragPlaneNormal: Vector3;
  98588. dragDistance: number;
  98589. pointerId: number;
  98590. }>;
  98591. /**
  98592. * Fires each time a drag begins (eg. mouse down on mesh)
  98593. */
  98594. onDragStartObservable: Observable<{
  98595. dragPlanePoint: Vector3;
  98596. pointerId: number;
  98597. }>;
  98598. /**
  98599. * Fires each time a drag ends (eg. mouse release after drag)
  98600. */
  98601. onDragEndObservable: Observable<{
  98602. dragPlanePoint: Vector3;
  98603. pointerId: number;
  98604. }>;
  98605. /**
  98606. * If the attached mesh should be moved when dragged
  98607. */
  98608. moveAttached: boolean;
  98609. /**
  98610. * If the drag behavior will react to drag events (Default: true)
  98611. */
  98612. enabled: boolean;
  98613. /**
  98614. * If camera controls should be detached during the drag
  98615. */
  98616. detachCameraControls: boolean;
  98617. /**
  98618. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98619. */
  98620. useObjectOrienationForDragging: boolean;
  98621. private _options;
  98622. /**
  98623. * Creates a pointer drag behavior that can be attached to a mesh
  98624. * @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)
  98625. */
  98626. constructor(options?: {
  98627. dragAxis?: Vector3;
  98628. dragPlaneNormal?: Vector3;
  98629. });
  98630. /**
  98631. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98632. */
  98633. validateDrag: (targetPosition: Vector3) => boolean;
  98634. /**
  98635. * The name of the behavior
  98636. */
  98637. readonly name: string;
  98638. /**
  98639. * Initializes the behavior
  98640. */
  98641. init(): void;
  98642. private _tmpVector;
  98643. private _alternatePickedPoint;
  98644. private _worldDragAxis;
  98645. private _targetPosition;
  98646. private _attachedElement;
  98647. /**
  98648. * Attaches the drag behavior the passed in mesh
  98649. * @param ownerNode The mesh that will be dragged around once attached
  98650. */
  98651. attach(ownerNode: AbstractMesh): void;
  98652. /**
  98653. * Force relase the drag action by code.
  98654. */
  98655. releaseDrag(): void;
  98656. private _startDragRay;
  98657. private _lastPointerRay;
  98658. /**
  98659. * Simulates the start of a pointer drag event on the behavior
  98660. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98661. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98662. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98663. */
  98664. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98665. private _startDrag;
  98666. private _dragDelta;
  98667. private _moveDrag;
  98668. private _pickWithRayOnDragPlane;
  98669. private _pointA;
  98670. private _pointB;
  98671. private _pointC;
  98672. private _lineA;
  98673. private _lineB;
  98674. private _localAxis;
  98675. private _lookAt;
  98676. private _updateDragPlanePosition;
  98677. /**
  98678. * Detaches the behavior from the mesh
  98679. */
  98680. detach(): void;
  98681. }
  98682. }
  98683. declare module BABYLON {
  98684. /**
  98685. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98686. */
  98687. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98688. private _dragBehaviorA;
  98689. private _dragBehaviorB;
  98690. private _startDistance;
  98691. private _initialScale;
  98692. private _targetScale;
  98693. private _ownerNode;
  98694. private _sceneRenderObserver;
  98695. /**
  98696. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98697. */
  98698. constructor();
  98699. /**
  98700. * The name of the behavior
  98701. */
  98702. readonly name: string;
  98703. /**
  98704. * Initializes the behavior
  98705. */
  98706. init(): void;
  98707. private _getCurrentDistance;
  98708. /**
  98709. * Attaches the scale behavior the passed in mesh
  98710. * @param ownerNode The mesh that will be scaled around once attached
  98711. */
  98712. attach(ownerNode: Mesh): void;
  98713. /**
  98714. * Detaches the behavior from the mesh
  98715. */
  98716. detach(): void;
  98717. }
  98718. }
  98719. declare module BABYLON {
  98720. /**
  98721. * 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
  98722. */
  98723. export class SixDofDragBehavior implements Behavior<Mesh> {
  98724. private static _virtualScene;
  98725. private _ownerNode;
  98726. private _sceneRenderObserver;
  98727. private _scene;
  98728. private _targetPosition;
  98729. private _virtualOriginMesh;
  98730. private _virtualDragMesh;
  98731. private _pointerObserver;
  98732. private _moving;
  98733. private _startingOrientation;
  98734. /**
  98735. * 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)
  98736. */
  98737. private zDragFactor;
  98738. /**
  98739. * If the object should rotate to face the drag origin
  98740. */
  98741. rotateDraggedObject: boolean;
  98742. /**
  98743. * If the behavior is currently in a dragging state
  98744. */
  98745. dragging: boolean;
  98746. /**
  98747. * 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)
  98748. */
  98749. dragDeltaRatio: number;
  98750. /**
  98751. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98752. */
  98753. currentDraggingPointerID: number;
  98754. /**
  98755. * If camera controls should be detached during the drag
  98756. */
  98757. detachCameraControls: boolean;
  98758. /**
  98759. * Fires each time a drag starts
  98760. */
  98761. onDragStartObservable: Observable<{}>;
  98762. /**
  98763. * Fires each time a drag ends (eg. mouse release after drag)
  98764. */
  98765. onDragEndObservable: Observable<{}>;
  98766. /**
  98767. * 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
  98768. */
  98769. constructor();
  98770. /**
  98771. * The name of the behavior
  98772. */
  98773. readonly name: string;
  98774. /**
  98775. * Initializes the behavior
  98776. */
  98777. init(): void;
  98778. /**
  98779. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  98780. */
  98781. private readonly _pointerCamera;
  98782. /**
  98783. * Attaches the scale behavior the passed in mesh
  98784. * @param ownerNode The mesh that will be scaled around once attached
  98785. */
  98786. attach(ownerNode: Mesh): void;
  98787. /**
  98788. * Detaches the behavior from the mesh
  98789. */
  98790. detach(): void;
  98791. }
  98792. }
  98793. declare module BABYLON {
  98794. /**
  98795. * Class used to apply inverse kinematics to bones
  98796. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  98797. */
  98798. export class BoneIKController {
  98799. private static _tmpVecs;
  98800. private static _tmpQuat;
  98801. private static _tmpMats;
  98802. /**
  98803. * Gets or sets the target mesh
  98804. */
  98805. targetMesh: AbstractMesh;
  98806. /** Gets or sets the mesh used as pole */
  98807. poleTargetMesh: AbstractMesh;
  98808. /**
  98809. * Gets or sets the bone used as pole
  98810. */
  98811. poleTargetBone: Nullable<Bone>;
  98812. /**
  98813. * Gets or sets the target position
  98814. */
  98815. targetPosition: Vector3;
  98816. /**
  98817. * Gets or sets the pole target position
  98818. */
  98819. poleTargetPosition: Vector3;
  98820. /**
  98821. * Gets or sets the pole target local offset
  98822. */
  98823. poleTargetLocalOffset: Vector3;
  98824. /**
  98825. * Gets or sets the pole angle
  98826. */
  98827. poleAngle: number;
  98828. /**
  98829. * Gets or sets the mesh associated with the controller
  98830. */
  98831. mesh: AbstractMesh;
  98832. /**
  98833. * 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)
  98834. */
  98835. slerpAmount: number;
  98836. private _bone1Quat;
  98837. private _bone1Mat;
  98838. private _bone2Ang;
  98839. private _bone1;
  98840. private _bone2;
  98841. private _bone1Length;
  98842. private _bone2Length;
  98843. private _maxAngle;
  98844. private _maxReach;
  98845. private _rightHandedSystem;
  98846. private _bendAxis;
  98847. private _slerping;
  98848. private _adjustRoll;
  98849. /**
  98850. * Gets or sets maximum allowed angle
  98851. */
  98852. maxAngle: number;
  98853. /**
  98854. * Creates a new BoneIKController
  98855. * @param mesh defines the mesh to control
  98856. * @param bone defines the bone to control
  98857. * @param options defines options to set up the controller
  98858. */
  98859. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  98860. targetMesh?: AbstractMesh;
  98861. poleTargetMesh?: AbstractMesh;
  98862. poleTargetBone?: Bone;
  98863. poleTargetLocalOffset?: Vector3;
  98864. poleAngle?: number;
  98865. bendAxis?: Vector3;
  98866. maxAngle?: number;
  98867. slerpAmount?: number;
  98868. });
  98869. private _setMaxAngle;
  98870. /**
  98871. * Force the controller to update the bones
  98872. */
  98873. update(): void;
  98874. }
  98875. }
  98876. declare module BABYLON {
  98877. /**
  98878. * Class used to make a bone look toward a point in space
  98879. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  98880. */
  98881. export class BoneLookController {
  98882. private static _tmpVecs;
  98883. private static _tmpQuat;
  98884. private static _tmpMats;
  98885. /**
  98886. * The target Vector3 that the bone will look at
  98887. */
  98888. target: Vector3;
  98889. /**
  98890. * The mesh that the bone is attached to
  98891. */
  98892. mesh: AbstractMesh;
  98893. /**
  98894. * The bone that will be looking to the target
  98895. */
  98896. bone: Bone;
  98897. /**
  98898. * The up axis of the coordinate system that is used when the bone is rotated
  98899. */
  98900. upAxis: Vector3;
  98901. /**
  98902. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  98903. */
  98904. upAxisSpace: Space;
  98905. /**
  98906. * Used to make an adjustment to the yaw of the bone
  98907. */
  98908. adjustYaw: number;
  98909. /**
  98910. * Used to make an adjustment to the pitch of the bone
  98911. */
  98912. adjustPitch: number;
  98913. /**
  98914. * Used to make an adjustment to the roll of the bone
  98915. */
  98916. adjustRoll: number;
  98917. /**
  98918. * 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)
  98919. */
  98920. slerpAmount: number;
  98921. private _minYaw;
  98922. private _maxYaw;
  98923. private _minPitch;
  98924. private _maxPitch;
  98925. private _minYawSin;
  98926. private _minYawCos;
  98927. private _maxYawSin;
  98928. private _maxYawCos;
  98929. private _midYawConstraint;
  98930. private _minPitchTan;
  98931. private _maxPitchTan;
  98932. private _boneQuat;
  98933. private _slerping;
  98934. private _transformYawPitch;
  98935. private _transformYawPitchInv;
  98936. private _firstFrameSkipped;
  98937. private _yawRange;
  98938. private _fowardAxis;
  98939. /**
  98940. * Gets or sets the minimum yaw angle that the bone can look to
  98941. */
  98942. minYaw: number;
  98943. /**
  98944. * Gets or sets the maximum yaw angle that the bone can look to
  98945. */
  98946. maxYaw: number;
  98947. /**
  98948. * Gets or sets the minimum pitch angle that the bone can look to
  98949. */
  98950. minPitch: number;
  98951. /**
  98952. * Gets or sets the maximum pitch angle that the bone can look to
  98953. */
  98954. maxPitch: number;
  98955. /**
  98956. * Create a BoneLookController
  98957. * @param mesh the mesh that the bone belongs to
  98958. * @param bone the bone that will be looking to the target
  98959. * @param target the target Vector3 to look at
  98960. * @param options optional settings:
  98961. * * maxYaw: the maximum angle the bone will yaw to
  98962. * * minYaw: the minimum angle the bone will yaw to
  98963. * * maxPitch: the maximum angle the bone will pitch to
  98964. * * minPitch: the minimum angle the bone will yaw to
  98965. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  98966. * * upAxis: the up axis of the coordinate system
  98967. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  98968. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  98969. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  98970. * * adjustYaw: used to make an adjustment to the yaw of the bone
  98971. * * adjustPitch: used to make an adjustment to the pitch of the bone
  98972. * * adjustRoll: used to make an adjustment to the roll of the bone
  98973. **/
  98974. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  98975. maxYaw?: number;
  98976. minYaw?: number;
  98977. maxPitch?: number;
  98978. minPitch?: number;
  98979. slerpAmount?: number;
  98980. upAxis?: Vector3;
  98981. upAxisSpace?: Space;
  98982. yawAxis?: Vector3;
  98983. pitchAxis?: Vector3;
  98984. adjustYaw?: number;
  98985. adjustPitch?: number;
  98986. adjustRoll?: number;
  98987. });
  98988. /**
  98989. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  98990. */
  98991. update(): void;
  98992. private _getAngleDiff;
  98993. private _getAngleBetween;
  98994. private _isAngleBetween;
  98995. }
  98996. }
  98997. declare module BABYLON {
  98998. /**
  98999. * Manage the gamepad inputs to control an arc rotate camera.
  99000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99001. */
  99002. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99003. /**
  99004. * Defines the camera the input is attached to.
  99005. */
  99006. camera: ArcRotateCamera;
  99007. /**
  99008. * Defines the gamepad the input is gathering event from.
  99009. */
  99010. gamepad: Nullable<Gamepad>;
  99011. /**
  99012. * Defines the gamepad rotation sensiblity.
  99013. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99014. */
  99015. gamepadRotationSensibility: number;
  99016. /**
  99017. * Defines the gamepad move sensiblity.
  99018. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99019. */
  99020. gamepadMoveSensibility: number;
  99021. private _onGamepadConnectedObserver;
  99022. private _onGamepadDisconnectedObserver;
  99023. /**
  99024. * Attach the input controls to a specific dom element to get the input from.
  99025. * @param element Defines the element the controls should be listened from
  99026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99027. */
  99028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99029. /**
  99030. * Detach the current controls from the specified dom element.
  99031. * @param element Defines the element to stop listening the inputs from
  99032. */
  99033. detachControl(element: Nullable<HTMLElement>): void;
  99034. /**
  99035. * Update the current camera state depending on the inputs that have been used this frame.
  99036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99037. */
  99038. checkInputs(): void;
  99039. /**
  99040. * Gets the class name of the current intput.
  99041. * @returns the class name
  99042. */
  99043. getClassName(): string;
  99044. /**
  99045. * Get the friendly name associated with the input class.
  99046. * @returns the input friendly name
  99047. */
  99048. getSimpleName(): string;
  99049. }
  99050. }
  99051. declare module BABYLON {
  99052. interface ArcRotateCameraInputsManager {
  99053. /**
  99054. * Add orientation input support to the input manager.
  99055. * @returns the current input manager
  99056. */
  99057. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99058. }
  99059. /**
  99060. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99061. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99062. */
  99063. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99064. /**
  99065. * Defines the camera the input is attached to.
  99066. */
  99067. camera: ArcRotateCamera;
  99068. /**
  99069. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99070. */
  99071. alphaCorrection: number;
  99072. /**
  99073. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99074. */
  99075. gammaCorrection: number;
  99076. private _alpha;
  99077. private _gamma;
  99078. private _dirty;
  99079. private _deviceOrientationHandler;
  99080. /**
  99081. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99082. */
  99083. constructor();
  99084. /**
  99085. * Attach the input controls to a specific dom element to get the input from.
  99086. * @param element Defines the element the controls should be listened from
  99087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99088. */
  99089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99090. /** @hidden */
  99091. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99092. /**
  99093. * Update the current camera state depending on the inputs that have been used this frame.
  99094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99095. */
  99096. checkInputs(): void;
  99097. /**
  99098. * Detach the current controls from the specified dom element.
  99099. * @param element Defines the element to stop listening the inputs from
  99100. */
  99101. detachControl(element: Nullable<HTMLElement>): void;
  99102. /**
  99103. * Gets the class name of the current intput.
  99104. * @returns the class name
  99105. */
  99106. getClassName(): string;
  99107. /**
  99108. * Get the friendly name associated with the input class.
  99109. * @returns the input friendly name
  99110. */
  99111. getSimpleName(): string;
  99112. }
  99113. }
  99114. declare module BABYLON {
  99115. /**
  99116. * Listen to mouse events to control the camera.
  99117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99118. */
  99119. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99120. /**
  99121. * Defines the camera the input is attached to.
  99122. */
  99123. camera: FlyCamera;
  99124. /**
  99125. * Defines if touch is enabled. (Default is true.)
  99126. */
  99127. touchEnabled: boolean;
  99128. /**
  99129. * Defines the buttons associated with the input to handle camera rotation.
  99130. */
  99131. buttons: number[];
  99132. /**
  99133. * Assign buttons for Yaw control.
  99134. */
  99135. buttonsYaw: number[];
  99136. /**
  99137. * Assign buttons for Pitch control.
  99138. */
  99139. buttonsPitch: number[];
  99140. /**
  99141. * Assign buttons for Roll control.
  99142. */
  99143. buttonsRoll: number[];
  99144. /**
  99145. * Detect if any button is being pressed while mouse is moved.
  99146. * -1 = Mouse locked.
  99147. * 0 = Left button.
  99148. * 1 = Middle Button.
  99149. * 2 = Right Button.
  99150. */
  99151. activeButton: number;
  99152. /**
  99153. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99154. * Higher values reduce its sensitivity.
  99155. */
  99156. angularSensibility: number;
  99157. private _mousemoveCallback;
  99158. private _observer;
  99159. private _rollObserver;
  99160. private previousPosition;
  99161. private noPreventDefault;
  99162. private element;
  99163. /**
  99164. * Listen to mouse events to control the camera.
  99165. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99167. */
  99168. constructor(touchEnabled?: boolean);
  99169. /**
  99170. * Attach the mouse control to the HTML DOM element.
  99171. * @param element Defines the element that listens to the input events.
  99172. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99173. */
  99174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99175. /**
  99176. * Detach the current controls from the specified dom element.
  99177. * @param element Defines the element to stop listening the inputs from
  99178. */
  99179. detachControl(element: Nullable<HTMLElement>): void;
  99180. /**
  99181. * Gets the class name of the current input.
  99182. * @returns the class name.
  99183. */
  99184. getClassName(): string;
  99185. /**
  99186. * Get the friendly name associated with the input class.
  99187. * @returns the input's friendly name.
  99188. */
  99189. getSimpleName(): string;
  99190. private _pointerInput;
  99191. private _onMouseMove;
  99192. /**
  99193. * Rotate camera by mouse offset.
  99194. */
  99195. private rotateCamera;
  99196. }
  99197. }
  99198. declare module BABYLON {
  99199. /**
  99200. * Default Inputs manager for the FlyCamera.
  99201. * It groups all the default supported inputs for ease of use.
  99202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99203. */
  99204. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99205. /**
  99206. * Instantiates a new FlyCameraInputsManager.
  99207. * @param camera Defines the camera the inputs belong to.
  99208. */
  99209. constructor(camera: FlyCamera);
  99210. /**
  99211. * Add keyboard input support to the input manager.
  99212. * @returns the new FlyCameraKeyboardMoveInput().
  99213. */
  99214. addKeyboard(): FlyCameraInputsManager;
  99215. /**
  99216. * Add mouse input support to the input manager.
  99217. * @param touchEnabled Enable touch screen support.
  99218. * @returns the new FlyCameraMouseInput().
  99219. */
  99220. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99221. }
  99222. }
  99223. declare module BABYLON {
  99224. /**
  99225. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99226. * such as in a 3D Space Shooter or a Flight Simulator.
  99227. */
  99228. export class FlyCamera extends TargetCamera {
  99229. /**
  99230. * Define the collision ellipsoid of the camera.
  99231. * This is helpful for simulating a camera body, like a player's body.
  99232. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99233. */
  99234. ellipsoid: Vector3;
  99235. /**
  99236. * Define an offset for the position of the ellipsoid around the camera.
  99237. * This can be helpful if the camera is attached away from the player's body center,
  99238. * such as at its head.
  99239. */
  99240. ellipsoidOffset: Vector3;
  99241. /**
  99242. * Enable or disable collisions of the camera with the rest of the scene objects.
  99243. */
  99244. checkCollisions: boolean;
  99245. /**
  99246. * Enable or disable gravity on the camera.
  99247. */
  99248. applyGravity: boolean;
  99249. /**
  99250. * Define the current direction the camera is moving to.
  99251. */
  99252. cameraDirection: Vector3;
  99253. /**
  99254. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99255. * This overrides and empties cameraRotation.
  99256. */
  99257. rotationQuaternion: Quaternion;
  99258. /**
  99259. * Track Roll to maintain the wanted Rolling when looking around.
  99260. */
  99261. _trackRoll: number;
  99262. /**
  99263. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99264. */
  99265. rollCorrect: number;
  99266. /**
  99267. * Mimic a banked turn, Rolling the camera when Yawing.
  99268. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99269. */
  99270. bankedTurn: boolean;
  99271. /**
  99272. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99273. */
  99274. bankedTurnLimit: number;
  99275. /**
  99276. * Value of 0 disables the banked Roll.
  99277. * Value of 1 is equal to the Yaw angle in radians.
  99278. */
  99279. bankedTurnMultiplier: number;
  99280. /**
  99281. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99282. */
  99283. inputs: FlyCameraInputsManager;
  99284. /**
  99285. * Gets the input sensibility for mouse input.
  99286. * Higher values reduce sensitivity.
  99287. */
  99288. /**
  99289. * Sets the input sensibility for a mouse input.
  99290. * Higher values reduce sensitivity.
  99291. */
  99292. angularSensibility: number;
  99293. /**
  99294. * Get the keys for camera movement forward.
  99295. */
  99296. /**
  99297. * Set the keys for camera movement forward.
  99298. */
  99299. keysForward: number[];
  99300. /**
  99301. * Get the keys for camera movement backward.
  99302. */
  99303. keysBackward: number[];
  99304. /**
  99305. * Get the keys for camera movement up.
  99306. */
  99307. /**
  99308. * Set the keys for camera movement up.
  99309. */
  99310. keysUp: number[];
  99311. /**
  99312. * Get the keys for camera movement down.
  99313. */
  99314. /**
  99315. * Set the keys for camera movement down.
  99316. */
  99317. keysDown: number[];
  99318. /**
  99319. * Get the keys for camera movement left.
  99320. */
  99321. /**
  99322. * Set the keys for camera movement left.
  99323. */
  99324. keysLeft: number[];
  99325. /**
  99326. * Set the keys for camera movement right.
  99327. */
  99328. /**
  99329. * Set the keys for camera movement right.
  99330. */
  99331. keysRight: number[];
  99332. /**
  99333. * Event raised when the camera collides with a mesh in the scene.
  99334. */
  99335. onCollide: (collidedMesh: AbstractMesh) => void;
  99336. private _collider;
  99337. private _needMoveForGravity;
  99338. private _oldPosition;
  99339. private _diffPosition;
  99340. private _newPosition;
  99341. /** @hidden */
  99342. _localDirection: Vector3;
  99343. /** @hidden */
  99344. _transformedDirection: Vector3;
  99345. /**
  99346. * Instantiates a FlyCamera.
  99347. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99348. * such as in a 3D Space Shooter or a Flight Simulator.
  99349. * @param name Define the name of the camera in the scene.
  99350. * @param position Define the starting position of the camera in the scene.
  99351. * @param scene Define the scene the camera belongs to.
  99352. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99353. */
  99354. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99355. /**
  99356. * Attach a control to the HTML DOM element.
  99357. * @param element Defines the element that listens to the input events.
  99358. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99359. */
  99360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99361. /**
  99362. * Detach a control from the HTML DOM element.
  99363. * The camera will stop reacting to that input.
  99364. * @param element Defines the element that listens to the input events.
  99365. */
  99366. detachControl(element: HTMLElement): void;
  99367. private _collisionMask;
  99368. /**
  99369. * Get the mask that the camera ignores in collision events.
  99370. */
  99371. /**
  99372. * Set the mask that the camera ignores in collision events.
  99373. */
  99374. collisionMask: number;
  99375. /** @hidden */
  99376. _collideWithWorld(displacement: Vector3): void;
  99377. /** @hidden */
  99378. private _onCollisionPositionChange;
  99379. /** @hidden */
  99380. _checkInputs(): void;
  99381. /** @hidden */
  99382. _decideIfNeedsToMove(): boolean;
  99383. /** @hidden */
  99384. _updatePosition(): void;
  99385. /**
  99386. * Restore the Roll to its target value at the rate specified.
  99387. * @param rate - Higher means slower restoring.
  99388. * @hidden
  99389. */
  99390. restoreRoll(rate: number): void;
  99391. /**
  99392. * Destroy the camera and release the current resources held by it.
  99393. */
  99394. dispose(): void;
  99395. /**
  99396. * Get the current object class name.
  99397. * @returns the class name.
  99398. */
  99399. getClassName(): string;
  99400. }
  99401. }
  99402. declare module BABYLON {
  99403. /**
  99404. * Listen to keyboard events to control the camera.
  99405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99406. */
  99407. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99408. /**
  99409. * Defines the camera the input is attached to.
  99410. */
  99411. camera: FlyCamera;
  99412. /**
  99413. * The list of keyboard keys used to control the forward move of the camera.
  99414. */
  99415. keysForward: number[];
  99416. /**
  99417. * The list of keyboard keys used to control the backward move of the camera.
  99418. */
  99419. keysBackward: number[];
  99420. /**
  99421. * The list of keyboard keys used to control the forward move of the camera.
  99422. */
  99423. keysUp: number[];
  99424. /**
  99425. * The list of keyboard keys used to control the backward move of the camera.
  99426. */
  99427. keysDown: number[];
  99428. /**
  99429. * The list of keyboard keys used to control the right strafe move of the camera.
  99430. */
  99431. keysRight: number[];
  99432. /**
  99433. * The list of keyboard keys used to control the left strafe move of the camera.
  99434. */
  99435. keysLeft: number[];
  99436. private _keys;
  99437. private _onCanvasBlurObserver;
  99438. private _onKeyboardObserver;
  99439. private _engine;
  99440. private _scene;
  99441. /**
  99442. * Attach the input controls to a specific dom element to get the input from.
  99443. * @param element Defines the element the controls should be listened from
  99444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99445. */
  99446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99447. /**
  99448. * Detach the current controls from the specified dom element.
  99449. * @param element Defines the element to stop listening the inputs from
  99450. */
  99451. detachControl(element: Nullable<HTMLElement>): void;
  99452. /**
  99453. * Gets the class name of the current intput.
  99454. * @returns the class name
  99455. */
  99456. getClassName(): string;
  99457. /** @hidden */
  99458. _onLostFocus(e: FocusEvent): void;
  99459. /**
  99460. * Get the friendly name associated with the input class.
  99461. * @returns the input friendly name
  99462. */
  99463. getSimpleName(): string;
  99464. /**
  99465. * Update the current camera state depending on the inputs that have been used this frame.
  99466. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99467. */
  99468. checkInputs(): void;
  99469. }
  99470. }
  99471. declare module BABYLON {
  99472. /**
  99473. * Manage the mouse wheel inputs to control a follow camera.
  99474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99475. */
  99476. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99477. /**
  99478. * Defines the camera the input is attached to.
  99479. */
  99480. camera: FollowCamera;
  99481. /**
  99482. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99483. */
  99484. axisControlRadius: boolean;
  99485. /**
  99486. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99487. */
  99488. axisControlHeight: boolean;
  99489. /**
  99490. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99491. */
  99492. axisControlRotation: boolean;
  99493. /**
  99494. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99495. * relation to mouseWheel events.
  99496. */
  99497. wheelPrecision: number;
  99498. /**
  99499. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99500. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99501. */
  99502. wheelDeltaPercentage: number;
  99503. private _wheel;
  99504. private _observer;
  99505. /**
  99506. * Attach the input controls to a specific dom element to get the input from.
  99507. * @param element Defines the element the controls should be listened from
  99508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99509. */
  99510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99511. /**
  99512. * Detach the current controls from the specified dom element.
  99513. * @param element Defines the element to stop listening the inputs from
  99514. */
  99515. detachControl(element: Nullable<HTMLElement>): void;
  99516. /**
  99517. * Gets the class name of the current intput.
  99518. * @returns the class name
  99519. */
  99520. getClassName(): string;
  99521. /**
  99522. * Get the friendly name associated with the input class.
  99523. * @returns the input friendly name
  99524. */
  99525. getSimpleName(): string;
  99526. }
  99527. }
  99528. declare module BABYLON {
  99529. /**
  99530. * Manage the pointers inputs to control an follow camera.
  99531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99532. */
  99533. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99534. /**
  99535. * Defines the camera the input is attached to.
  99536. */
  99537. camera: FollowCamera;
  99538. /**
  99539. * Gets the class name of the current input.
  99540. * @returns the class name
  99541. */
  99542. getClassName(): string;
  99543. /**
  99544. * Defines the pointer angular sensibility along the X axis or how fast is
  99545. * the camera rotating.
  99546. * A negative number will reverse the axis direction.
  99547. */
  99548. angularSensibilityX: number;
  99549. /**
  99550. * Defines the pointer angular sensibility along the Y axis or how fast is
  99551. * the camera rotating.
  99552. * A negative number will reverse the axis direction.
  99553. */
  99554. angularSensibilityY: number;
  99555. /**
  99556. * Defines the pointer pinch precision or how fast is the camera zooming.
  99557. * A negative number will reverse the axis direction.
  99558. */
  99559. pinchPrecision: number;
  99560. /**
  99561. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99562. * from 0.
  99563. * It defines the percentage of current camera.radius to use as delta when
  99564. * pinch zoom is used.
  99565. */
  99566. pinchDeltaPercentage: number;
  99567. /**
  99568. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99569. */
  99570. axisXControlRadius: boolean;
  99571. /**
  99572. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99573. */
  99574. axisXControlHeight: boolean;
  99575. /**
  99576. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99577. */
  99578. axisXControlRotation: boolean;
  99579. /**
  99580. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99581. */
  99582. axisYControlRadius: boolean;
  99583. /**
  99584. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99585. */
  99586. axisYControlHeight: boolean;
  99587. /**
  99588. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99589. */
  99590. axisYControlRotation: boolean;
  99591. /**
  99592. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99593. */
  99594. axisPinchControlRadius: boolean;
  99595. /**
  99596. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99597. */
  99598. axisPinchControlHeight: boolean;
  99599. /**
  99600. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99601. */
  99602. axisPinchControlRotation: boolean;
  99603. /**
  99604. * Log error messages if basic misconfiguration has occurred.
  99605. */
  99606. warningEnable: boolean;
  99607. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99608. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99609. private _warningCounter;
  99610. private _warning;
  99611. }
  99612. }
  99613. declare module BABYLON {
  99614. /**
  99615. * Default Inputs manager for the FollowCamera.
  99616. * It groups all the default supported inputs for ease of use.
  99617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99618. */
  99619. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99620. /**
  99621. * Instantiates a new FollowCameraInputsManager.
  99622. * @param camera Defines the camera the inputs belong to
  99623. */
  99624. constructor(camera: FollowCamera);
  99625. /**
  99626. * Add keyboard input support to the input manager.
  99627. * @returns the current input manager
  99628. */
  99629. addKeyboard(): FollowCameraInputsManager;
  99630. /**
  99631. * Add mouse wheel input support to the input manager.
  99632. * @returns the current input manager
  99633. */
  99634. addMouseWheel(): FollowCameraInputsManager;
  99635. /**
  99636. * Add pointers input support to the input manager.
  99637. * @returns the current input manager
  99638. */
  99639. addPointers(): FollowCameraInputsManager;
  99640. /**
  99641. * Add orientation input support to the input manager.
  99642. * @returns the current input manager
  99643. */
  99644. addVRDeviceOrientation(): FollowCameraInputsManager;
  99645. }
  99646. }
  99647. declare module BABYLON {
  99648. /**
  99649. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99650. * an arc rotate version arcFollowCamera are available.
  99651. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99652. */
  99653. export class FollowCamera extends TargetCamera {
  99654. /**
  99655. * Distance the follow camera should follow an object at
  99656. */
  99657. radius: number;
  99658. /**
  99659. * Minimum allowed distance of the camera to the axis of rotation
  99660. * (The camera can not get closer).
  99661. * This can help limiting how the Camera is able to move in the scene.
  99662. */
  99663. lowerRadiusLimit: Nullable<number>;
  99664. /**
  99665. * Maximum allowed distance of the camera to the axis of rotation
  99666. * (The camera can not get further).
  99667. * This can help limiting how the Camera is able to move in the scene.
  99668. */
  99669. upperRadiusLimit: Nullable<number>;
  99670. /**
  99671. * Define a rotation offset between the camera and the object it follows
  99672. */
  99673. rotationOffset: number;
  99674. /**
  99675. * Minimum allowed angle to camera position relative to target object.
  99676. * This can help limiting how the Camera is able to move in the scene.
  99677. */
  99678. lowerRotationOffsetLimit: Nullable<number>;
  99679. /**
  99680. * Maximum allowed angle to camera position relative to target object.
  99681. * This can help limiting how the Camera is able to move in the scene.
  99682. */
  99683. upperRotationOffsetLimit: Nullable<number>;
  99684. /**
  99685. * Define a height offset between the camera and the object it follows.
  99686. * It can help following an object from the top (like a car chaing a plane)
  99687. */
  99688. heightOffset: number;
  99689. /**
  99690. * Minimum allowed height of camera position relative to target object.
  99691. * This can help limiting how the Camera is able to move in the scene.
  99692. */
  99693. lowerHeightOffsetLimit: Nullable<number>;
  99694. /**
  99695. * Maximum allowed height of camera position relative to target object.
  99696. * This can help limiting how the Camera is able to move in the scene.
  99697. */
  99698. upperHeightOffsetLimit: Nullable<number>;
  99699. /**
  99700. * Define how fast the camera can accelerate to follow it s target.
  99701. */
  99702. cameraAcceleration: number;
  99703. /**
  99704. * Define the speed limit of the camera following an object.
  99705. */
  99706. maxCameraSpeed: number;
  99707. /**
  99708. * Define the target of the camera.
  99709. */
  99710. lockedTarget: Nullable<AbstractMesh>;
  99711. /**
  99712. * Defines the input associated with the camera.
  99713. */
  99714. inputs: FollowCameraInputsManager;
  99715. /**
  99716. * Instantiates the follow camera.
  99717. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99718. * @param name Define the name of the camera in the scene
  99719. * @param position Define the position of the camera
  99720. * @param scene Define the scene the camera belong to
  99721. * @param lockedTarget Define the target of the camera
  99722. */
  99723. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99724. private _follow;
  99725. /**
  99726. * Attached controls to the current camera.
  99727. * @param element Defines the element the controls should be listened from
  99728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99729. */
  99730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99731. /**
  99732. * Detach the current controls from the camera.
  99733. * The camera will stop reacting to inputs.
  99734. * @param element Defines the element to stop listening the inputs from
  99735. */
  99736. detachControl(element: HTMLElement): void;
  99737. /** @hidden */
  99738. _checkInputs(): void;
  99739. private _checkLimits;
  99740. /**
  99741. * Gets the camera class name.
  99742. * @returns the class name
  99743. */
  99744. getClassName(): string;
  99745. }
  99746. /**
  99747. * Arc Rotate version of the follow camera.
  99748. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  99749. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99750. */
  99751. export class ArcFollowCamera extends TargetCamera {
  99752. /** The longitudinal angle of the camera */
  99753. alpha: number;
  99754. /** The latitudinal angle of the camera */
  99755. beta: number;
  99756. /** The radius of the camera from its target */
  99757. radius: number;
  99758. /** Define the camera target (the messh it should follow) */
  99759. target: Nullable<AbstractMesh>;
  99760. private _cartesianCoordinates;
  99761. /**
  99762. * Instantiates a new ArcFollowCamera
  99763. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99764. * @param name Define the name of the camera
  99765. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  99766. * @param beta Define the rotation angle of the camera around the elevation axis
  99767. * @param radius Define the radius of the camera from its target point
  99768. * @param target Define the target of the camera
  99769. * @param scene Define the scene the camera belongs to
  99770. */
  99771. constructor(name: string,
  99772. /** The longitudinal angle of the camera */
  99773. alpha: number,
  99774. /** The latitudinal angle of the camera */
  99775. beta: number,
  99776. /** The radius of the camera from its target */
  99777. radius: number,
  99778. /** Define the camera target (the messh it should follow) */
  99779. target: Nullable<AbstractMesh>, scene: Scene);
  99780. private _follow;
  99781. /** @hidden */
  99782. _checkInputs(): void;
  99783. /**
  99784. * Returns the class name of the object.
  99785. * It is mostly used internally for serialization purposes.
  99786. */
  99787. getClassName(): string;
  99788. }
  99789. }
  99790. declare module BABYLON {
  99791. /**
  99792. * Manage the keyboard inputs to control the movement of a follow camera.
  99793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99794. */
  99795. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  99796. /**
  99797. * Defines the camera the input is attached to.
  99798. */
  99799. camera: FollowCamera;
  99800. /**
  99801. * Defines the list of key codes associated with the up action (increase heightOffset)
  99802. */
  99803. keysHeightOffsetIncr: number[];
  99804. /**
  99805. * Defines the list of key codes associated with the down action (decrease heightOffset)
  99806. */
  99807. keysHeightOffsetDecr: number[];
  99808. /**
  99809. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  99810. */
  99811. keysHeightOffsetModifierAlt: boolean;
  99812. /**
  99813. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  99814. */
  99815. keysHeightOffsetModifierCtrl: boolean;
  99816. /**
  99817. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  99818. */
  99819. keysHeightOffsetModifierShift: boolean;
  99820. /**
  99821. * Defines the list of key codes associated with the left action (increase rotationOffset)
  99822. */
  99823. keysRotationOffsetIncr: number[];
  99824. /**
  99825. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  99826. */
  99827. keysRotationOffsetDecr: number[];
  99828. /**
  99829. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  99830. */
  99831. keysRotationOffsetModifierAlt: boolean;
  99832. /**
  99833. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  99834. */
  99835. keysRotationOffsetModifierCtrl: boolean;
  99836. /**
  99837. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  99838. */
  99839. keysRotationOffsetModifierShift: boolean;
  99840. /**
  99841. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  99842. */
  99843. keysRadiusIncr: number[];
  99844. /**
  99845. * Defines the list of key codes associated with the zoom-out action (increase radius)
  99846. */
  99847. keysRadiusDecr: number[];
  99848. /**
  99849. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  99850. */
  99851. keysRadiusModifierAlt: boolean;
  99852. /**
  99853. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  99854. */
  99855. keysRadiusModifierCtrl: boolean;
  99856. /**
  99857. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  99858. */
  99859. keysRadiusModifierShift: boolean;
  99860. /**
  99861. * Defines the rate of change of heightOffset.
  99862. */
  99863. heightSensibility: number;
  99864. /**
  99865. * Defines the rate of change of rotationOffset.
  99866. */
  99867. rotationSensibility: number;
  99868. /**
  99869. * Defines the rate of change of radius.
  99870. */
  99871. radiusSensibility: number;
  99872. private _keys;
  99873. private _ctrlPressed;
  99874. private _altPressed;
  99875. private _shiftPressed;
  99876. private _onCanvasBlurObserver;
  99877. private _onKeyboardObserver;
  99878. private _engine;
  99879. private _scene;
  99880. /**
  99881. * Attach the input controls to a specific dom element to get the input from.
  99882. * @param element Defines the element the controls should be listened from
  99883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99884. */
  99885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99886. /**
  99887. * Detach the current controls from the specified dom element.
  99888. * @param element Defines the element to stop listening the inputs from
  99889. */
  99890. detachControl(element: Nullable<HTMLElement>): void;
  99891. /**
  99892. * Update the current camera state depending on the inputs that have been used this frame.
  99893. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99894. */
  99895. checkInputs(): void;
  99896. /**
  99897. * Gets the class name of the current input.
  99898. * @returns the class name
  99899. */
  99900. getClassName(): string;
  99901. /**
  99902. * Get the friendly name associated with the input class.
  99903. * @returns the input friendly name
  99904. */
  99905. getSimpleName(): string;
  99906. /**
  99907. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99908. * allow modification of the heightOffset value.
  99909. */
  99910. private _modifierHeightOffset;
  99911. /**
  99912. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99913. * allow modification of the rotationOffset value.
  99914. */
  99915. private _modifierRotationOffset;
  99916. /**
  99917. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99918. * allow modification of the radius value.
  99919. */
  99920. private _modifierRadius;
  99921. }
  99922. }
  99923. declare module BABYLON {
  99924. interface FreeCameraInputsManager {
  99925. /**
  99926. * @hidden
  99927. */
  99928. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  99929. /**
  99930. * Add orientation input support to the input manager.
  99931. * @returns the current input manager
  99932. */
  99933. addDeviceOrientation(): FreeCameraInputsManager;
  99934. }
  99935. /**
  99936. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  99937. * Screen rotation is taken into account.
  99938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99939. */
  99940. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  99941. private _camera;
  99942. private _screenOrientationAngle;
  99943. private _constantTranform;
  99944. private _screenQuaternion;
  99945. private _alpha;
  99946. private _beta;
  99947. private _gamma;
  99948. /**
  99949. * @hidden
  99950. */
  99951. _onDeviceOrientationChangedObservable: Observable<void>;
  99952. /**
  99953. * Instantiates a new input
  99954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99955. */
  99956. constructor();
  99957. /**
  99958. * Define the camera controlled by the input.
  99959. */
  99960. camera: FreeCamera;
  99961. /**
  99962. * Attach the input controls to a specific dom element to get the input from.
  99963. * @param element Defines the element the controls should be listened from
  99964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99965. */
  99966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99967. private _orientationChanged;
  99968. private _deviceOrientation;
  99969. /**
  99970. * Detach the current controls from the specified dom element.
  99971. * @param element Defines the element to stop listening the inputs from
  99972. */
  99973. detachControl(element: Nullable<HTMLElement>): void;
  99974. /**
  99975. * Update the current camera state depending on the inputs that have been used this frame.
  99976. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99977. */
  99978. checkInputs(): void;
  99979. /**
  99980. * Gets the class name of the current intput.
  99981. * @returns the class name
  99982. */
  99983. getClassName(): string;
  99984. /**
  99985. * Get the friendly name associated with the input class.
  99986. * @returns the input friendly name
  99987. */
  99988. getSimpleName(): string;
  99989. }
  99990. }
  99991. declare module BABYLON {
  99992. /**
  99993. * Manage the gamepad inputs to control a free camera.
  99994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99995. */
  99996. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  99997. /**
  99998. * Define the camera the input is attached to.
  99999. */
  100000. camera: FreeCamera;
  100001. /**
  100002. * Define the Gamepad controlling the input
  100003. */
  100004. gamepad: Nullable<Gamepad>;
  100005. /**
  100006. * Defines the gamepad rotation sensiblity.
  100007. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100008. */
  100009. gamepadAngularSensibility: number;
  100010. /**
  100011. * Defines the gamepad move sensiblity.
  100012. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100013. */
  100014. gamepadMoveSensibility: number;
  100015. private _onGamepadConnectedObserver;
  100016. private _onGamepadDisconnectedObserver;
  100017. private _cameraTransform;
  100018. private _deltaTransform;
  100019. private _vector3;
  100020. private _vector2;
  100021. /**
  100022. * Attach the input controls to a specific dom element to get the input from.
  100023. * @param element Defines the element the controls should be listened from
  100024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100025. */
  100026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100027. /**
  100028. * Detach the current controls from the specified dom element.
  100029. * @param element Defines the element to stop listening the inputs from
  100030. */
  100031. detachControl(element: Nullable<HTMLElement>): void;
  100032. /**
  100033. * Update the current camera state depending on the inputs that have been used this frame.
  100034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100035. */
  100036. checkInputs(): void;
  100037. /**
  100038. * Gets the class name of the current intput.
  100039. * @returns the class name
  100040. */
  100041. getClassName(): string;
  100042. /**
  100043. * Get the friendly name associated with the input class.
  100044. * @returns the input friendly name
  100045. */
  100046. getSimpleName(): string;
  100047. }
  100048. }
  100049. declare module BABYLON {
  100050. /**
  100051. * Defines the potential axis of a Joystick
  100052. */
  100053. export enum JoystickAxis {
  100054. /** X axis */
  100055. X = 0,
  100056. /** Y axis */
  100057. Y = 1,
  100058. /** Z axis */
  100059. Z = 2
  100060. }
  100061. /**
  100062. * Class used to define virtual joystick (used in touch mode)
  100063. */
  100064. export class VirtualJoystick {
  100065. /**
  100066. * Gets or sets a boolean indicating that left and right values must be inverted
  100067. */
  100068. reverseLeftRight: boolean;
  100069. /**
  100070. * Gets or sets a boolean indicating that up and down values must be inverted
  100071. */
  100072. reverseUpDown: boolean;
  100073. /**
  100074. * Gets the offset value for the position (ie. the change of the position value)
  100075. */
  100076. deltaPosition: Vector3;
  100077. /**
  100078. * Gets a boolean indicating if the virtual joystick was pressed
  100079. */
  100080. pressed: boolean;
  100081. /**
  100082. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100083. */
  100084. static Canvas: Nullable<HTMLCanvasElement>;
  100085. private static _globalJoystickIndex;
  100086. private static vjCanvasContext;
  100087. private static vjCanvasWidth;
  100088. private static vjCanvasHeight;
  100089. private static halfWidth;
  100090. private _action;
  100091. private _axisTargetedByLeftAndRight;
  100092. private _axisTargetedByUpAndDown;
  100093. private _joystickSensibility;
  100094. private _inversedSensibility;
  100095. private _joystickPointerID;
  100096. private _joystickColor;
  100097. private _joystickPointerPos;
  100098. private _joystickPreviousPointerPos;
  100099. private _joystickPointerStartPos;
  100100. private _deltaJoystickVector;
  100101. private _leftJoystick;
  100102. private _touches;
  100103. private _onPointerDownHandlerRef;
  100104. private _onPointerMoveHandlerRef;
  100105. private _onPointerUpHandlerRef;
  100106. private _onResize;
  100107. /**
  100108. * Creates a new virtual joystick
  100109. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100110. */
  100111. constructor(leftJoystick?: boolean);
  100112. /**
  100113. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100114. * @param newJoystickSensibility defines the new sensibility
  100115. */
  100116. setJoystickSensibility(newJoystickSensibility: number): void;
  100117. private _onPointerDown;
  100118. private _onPointerMove;
  100119. private _onPointerUp;
  100120. /**
  100121. * Change the color of the virtual joystick
  100122. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100123. */
  100124. setJoystickColor(newColor: string): void;
  100125. /**
  100126. * Defines a callback to call when the joystick is touched
  100127. * @param action defines the callback
  100128. */
  100129. setActionOnTouch(action: () => any): void;
  100130. /**
  100131. * Defines which axis you'd like to control for left & right
  100132. * @param axis defines the axis to use
  100133. */
  100134. setAxisForLeftRight(axis: JoystickAxis): void;
  100135. /**
  100136. * Defines which axis you'd like to control for up & down
  100137. * @param axis defines the axis to use
  100138. */
  100139. setAxisForUpDown(axis: JoystickAxis): void;
  100140. private _drawVirtualJoystick;
  100141. /**
  100142. * Release internal HTML canvas
  100143. */
  100144. releaseCanvas(): void;
  100145. }
  100146. }
  100147. declare module BABYLON {
  100148. interface FreeCameraInputsManager {
  100149. /**
  100150. * Add virtual joystick input support to the input manager.
  100151. * @returns the current input manager
  100152. */
  100153. addVirtualJoystick(): FreeCameraInputsManager;
  100154. }
  100155. /**
  100156. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100158. */
  100159. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100160. /**
  100161. * Defines the camera the input is attached to.
  100162. */
  100163. camera: FreeCamera;
  100164. private _leftjoystick;
  100165. private _rightjoystick;
  100166. /**
  100167. * Gets the left stick of the virtual joystick.
  100168. * @returns The virtual Joystick
  100169. */
  100170. getLeftJoystick(): VirtualJoystick;
  100171. /**
  100172. * Gets the right stick of the virtual joystick.
  100173. * @returns The virtual Joystick
  100174. */
  100175. getRightJoystick(): VirtualJoystick;
  100176. /**
  100177. * Update the current camera state depending on the inputs that have been used this frame.
  100178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100179. */
  100180. checkInputs(): void;
  100181. /**
  100182. * Attach the input controls to a specific dom element to get the input from.
  100183. * @param element Defines the element the controls should be listened from
  100184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100185. */
  100186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100187. /**
  100188. * Detach the current controls from the specified dom element.
  100189. * @param element Defines the element to stop listening the inputs from
  100190. */
  100191. detachControl(element: Nullable<HTMLElement>): void;
  100192. /**
  100193. * Gets the class name of the current intput.
  100194. * @returns the class name
  100195. */
  100196. getClassName(): string;
  100197. /**
  100198. * Get the friendly name associated with the input class.
  100199. * @returns the input friendly name
  100200. */
  100201. getSimpleName(): string;
  100202. }
  100203. }
  100204. declare module BABYLON {
  100205. /**
  100206. * This represents a FPS type of camera controlled by touch.
  100207. * This is like a universal camera minus the Gamepad controls.
  100208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100209. */
  100210. export class TouchCamera extends FreeCamera {
  100211. /**
  100212. * Defines the touch sensibility for rotation.
  100213. * The higher the faster.
  100214. */
  100215. touchAngularSensibility: number;
  100216. /**
  100217. * Defines the touch sensibility for move.
  100218. * The higher the faster.
  100219. */
  100220. touchMoveSensibility: number;
  100221. /**
  100222. * Instantiates a new touch camera.
  100223. * This represents a FPS type of camera controlled by touch.
  100224. * This is like a universal camera minus the Gamepad controls.
  100225. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100226. * @param name Define the name of the camera in the scene
  100227. * @param position Define the start position of the camera in the scene
  100228. * @param scene Define the scene the camera belongs to
  100229. */
  100230. constructor(name: string, position: Vector3, scene: Scene);
  100231. /**
  100232. * Gets the current object class name.
  100233. * @return the class name
  100234. */
  100235. getClassName(): string;
  100236. /** @hidden */
  100237. _setupInputs(): void;
  100238. }
  100239. }
  100240. declare module BABYLON {
  100241. /**
  100242. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100243. * being tilted forward or back and left or right.
  100244. */
  100245. export class DeviceOrientationCamera extends FreeCamera {
  100246. private _initialQuaternion;
  100247. private _quaternionCache;
  100248. private _tmpDragQuaternion;
  100249. /**
  100250. * Creates a new device orientation camera
  100251. * @param name The name of the camera
  100252. * @param position The start position camera
  100253. * @param scene The scene the camera belongs to
  100254. */
  100255. constructor(name: string, position: Vector3, scene: Scene);
  100256. /**
  100257. * @hidden
  100258. * Disabled pointer input on first orientation sensor update (Default: true)
  100259. */
  100260. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100261. private _dragFactor;
  100262. /**
  100263. * Enabled turning on the y axis when the orientation sensor is active
  100264. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100265. */
  100266. enableHorizontalDragging(dragFactor?: number): void;
  100267. /**
  100268. * Gets the current instance class name ("DeviceOrientationCamera").
  100269. * This helps avoiding instanceof at run time.
  100270. * @returns the class name
  100271. */
  100272. getClassName(): string;
  100273. /**
  100274. * @hidden
  100275. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100276. */
  100277. _checkInputs(): void;
  100278. /**
  100279. * Reset the camera to its default orientation on the specified axis only.
  100280. * @param axis The axis to reset
  100281. */
  100282. resetToCurrentRotation(axis?: Axis): void;
  100283. }
  100284. }
  100285. declare module BABYLON {
  100286. /**
  100287. * Defines supported buttons for XBox360 compatible gamepads
  100288. */
  100289. export enum Xbox360Button {
  100290. /** A */
  100291. A = 0,
  100292. /** B */
  100293. B = 1,
  100294. /** X */
  100295. X = 2,
  100296. /** Y */
  100297. Y = 3,
  100298. /** Start */
  100299. Start = 4,
  100300. /** Back */
  100301. Back = 5,
  100302. /** Left button */
  100303. LB = 6,
  100304. /** Right button */
  100305. RB = 7,
  100306. /** Left stick */
  100307. LeftStick = 8,
  100308. /** Right stick */
  100309. RightStick = 9
  100310. }
  100311. /** Defines values for XBox360 DPad */
  100312. export enum Xbox360Dpad {
  100313. /** Up */
  100314. Up = 0,
  100315. /** Down */
  100316. Down = 1,
  100317. /** Left */
  100318. Left = 2,
  100319. /** Right */
  100320. Right = 3
  100321. }
  100322. /**
  100323. * Defines a XBox360 gamepad
  100324. */
  100325. export class Xbox360Pad extends Gamepad {
  100326. private _leftTrigger;
  100327. private _rightTrigger;
  100328. private _onlefttriggerchanged;
  100329. private _onrighttriggerchanged;
  100330. private _onbuttondown;
  100331. private _onbuttonup;
  100332. private _ondpaddown;
  100333. private _ondpadup;
  100334. /** Observable raised when a button is pressed */
  100335. onButtonDownObservable: Observable<Xbox360Button>;
  100336. /** Observable raised when a button is released */
  100337. onButtonUpObservable: Observable<Xbox360Button>;
  100338. /** Observable raised when a pad is pressed */
  100339. onPadDownObservable: Observable<Xbox360Dpad>;
  100340. /** Observable raised when a pad is released */
  100341. onPadUpObservable: Observable<Xbox360Dpad>;
  100342. private _buttonA;
  100343. private _buttonB;
  100344. private _buttonX;
  100345. private _buttonY;
  100346. private _buttonBack;
  100347. private _buttonStart;
  100348. private _buttonLB;
  100349. private _buttonRB;
  100350. private _buttonLeftStick;
  100351. private _buttonRightStick;
  100352. private _dPadUp;
  100353. private _dPadDown;
  100354. private _dPadLeft;
  100355. private _dPadRight;
  100356. private _isXboxOnePad;
  100357. /**
  100358. * Creates a new XBox360 gamepad object
  100359. * @param id defines the id of this gamepad
  100360. * @param index defines its index
  100361. * @param gamepad defines the internal HTML gamepad object
  100362. * @param xboxOne defines if it is a XBox One gamepad
  100363. */
  100364. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100365. /**
  100366. * Defines the callback to call when left trigger is pressed
  100367. * @param callback defines the callback to use
  100368. */
  100369. onlefttriggerchanged(callback: (value: number) => void): void;
  100370. /**
  100371. * Defines the callback to call when right trigger is pressed
  100372. * @param callback defines the callback to use
  100373. */
  100374. onrighttriggerchanged(callback: (value: number) => void): void;
  100375. /**
  100376. * Gets the left trigger value
  100377. */
  100378. /**
  100379. * Sets the left trigger value
  100380. */
  100381. leftTrigger: number;
  100382. /**
  100383. * Gets the right trigger value
  100384. */
  100385. /**
  100386. * Sets the right trigger value
  100387. */
  100388. rightTrigger: number;
  100389. /**
  100390. * Defines the callback to call when a button is pressed
  100391. * @param callback defines the callback to use
  100392. */
  100393. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100394. /**
  100395. * Defines the callback to call when a button is released
  100396. * @param callback defines the callback to use
  100397. */
  100398. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100399. /**
  100400. * Defines the callback to call when a pad is pressed
  100401. * @param callback defines the callback to use
  100402. */
  100403. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100404. /**
  100405. * Defines the callback to call when a pad is released
  100406. * @param callback defines the callback to use
  100407. */
  100408. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100409. private _setButtonValue;
  100410. private _setDPadValue;
  100411. /**
  100412. * Gets the value of the `A` button
  100413. */
  100414. /**
  100415. * Sets the value of the `A` button
  100416. */
  100417. buttonA: number;
  100418. /**
  100419. * Gets the value of the `B` button
  100420. */
  100421. /**
  100422. * Sets the value of the `B` button
  100423. */
  100424. buttonB: number;
  100425. /**
  100426. * Gets the value of the `X` button
  100427. */
  100428. /**
  100429. * Sets the value of the `X` button
  100430. */
  100431. buttonX: number;
  100432. /**
  100433. * Gets the value of the `Y` button
  100434. */
  100435. /**
  100436. * Sets the value of the `Y` button
  100437. */
  100438. buttonY: number;
  100439. /**
  100440. * Gets the value of the `Start` button
  100441. */
  100442. /**
  100443. * Sets the value of the `Start` button
  100444. */
  100445. buttonStart: number;
  100446. /**
  100447. * Gets the value of the `Back` button
  100448. */
  100449. /**
  100450. * Sets the value of the `Back` button
  100451. */
  100452. buttonBack: number;
  100453. /**
  100454. * Gets the value of the `Left` button
  100455. */
  100456. /**
  100457. * Sets the value of the `Left` button
  100458. */
  100459. buttonLB: number;
  100460. /**
  100461. * Gets the value of the `Right` button
  100462. */
  100463. /**
  100464. * Sets the value of the `Right` button
  100465. */
  100466. buttonRB: number;
  100467. /**
  100468. * Gets the value of the Left joystick
  100469. */
  100470. /**
  100471. * Sets the value of the Left joystick
  100472. */
  100473. buttonLeftStick: number;
  100474. /**
  100475. * Gets the value of the Right joystick
  100476. */
  100477. /**
  100478. * Sets the value of the Right joystick
  100479. */
  100480. buttonRightStick: number;
  100481. /**
  100482. * Gets the value of D-pad up
  100483. */
  100484. /**
  100485. * Sets the value of D-pad up
  100486. */
  100487. dPadUp: number;
  100488. /**
  100489. * Gets the value of D-pad down
  100490. */
  100491. /**
  100492. * Sets the value of D-pad down
  100493. */
  100494. dPadDown: number;
  100495. /**
  100496. * Gets the value of D-pad left
  100497. */
  100498. /**
  100499. * Sets the value of D-pad left
  100500. */
  100501. dPadLeft: number;
  100502. /**
  100503. * Gets the value of D-pad right
  100504. */
  100505. /**
  100506. * Sets the value of D-pad right
  100507. */
  100508. dPadRight: number;
  100509. /**
  100510. * Force the gamepad to synchronize with device values
  100511. */
  100512. update(): void;
  100513. /**
  100514. * Disposes the gamepad
  100515. */
  100516. dispose(): void;
  100517. }
  100518. }
  100519. declare module BABYLON {
  100520. /**
  100521. * Manager for handling gamepads
  100522. */
  100523. export class GamepadManager {
  100524. private _scene?;
  100525. private _babylonGamepads;
  100526. private _oneGamepadConnected;
  100527. /** @hidden */
  100528. _isMonitoring: boolean;
  100529. private _gamepadEventSupported;
  100530. private _gamepadSupport;
  100531. /**
  100532. * observable to be triggered when the gamepad controller has been connected
  100533. */
  100534. onGamepadConnectedObservable: Observable<Gamepad>;
  100535. /**
  100536. * observable to be triggered when the gamepad controller has been disconnected
  100537. */
  100538. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100539. private _onGamepadConnectedEvent;
  100540. private _onGamepadDisconnectedEvent;
  100541. /**
  100542. * Initializes the gamepad manager
  100543. * @param _scene BabylonJS scene
  100544. */
  100545. constructor(_scene?: Scene | undefined);
  100546. /**
  100547. * The gamepads in the game pad manager
  100548. */
  100549. readonly gamepads: Gamepad[];
  100550. /**
  100551. * Get the gamepad controllers based on type
  100552. * @param type The type of gamepad controller
  100553. * @returns Nullable gamepad
  100554. */
  100555. getGamepadByType(type?: number): Nullable<Gamepad>;
  100556. /**
  100557. * Disposes the gamepad manager
  100558. */
  100559. dispose(): void;
  100560. private _addNewGamepad;
  100561. private _startMonitoringGamepads;
  100562. private _stopMonitoringGamepads;
  100563. /** @hidden */
  100564. _checkGamepadsStatus(): void;
  100565. private _updateGamepadObjects;
  100566. }
  100567. }
  100568. declare module BABYLON {
  100569. interface Scene {
  100570. /** @hidden */
  100571. _gamepadManager: Nullable<GamepadManager>;
  100572. /**
  100573. * Gets the gamepad manager associated with the scene
  100574. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100575. */
  100576. gamepadManager: GamepadManager;
  100577. }
  100578. /**
  100579. * Interface representing a free camera inputs manager
  100580. */
  100581. interface FreeCameraInputsManager {
  100582. /**
  100583. * Adds gamepad input support to the FreeCameraInputsManager.
  100584. * @returns the FreeCameraInputsManager
  100585. */
  100586. addGamepad(): FreeCameraInputsManager;
  100587. }
  100588. /**
  100589. * Interface representing an arc rotate camera inputs manager
  100590. */
  100591. interface ArcRotateCameraInputsManager {
  100592. /**
  100593. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100594. * @returns the camera inputs manager
  100595. */
  100596. addGamepad(): ArcRotateCameraInputsManager;
  100597. }
  100598. /**
  100599. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100600. */
  100601. export class GamepadSystemSceneComponent implements ISceneComponent {
  100602. /**
  100603. * The component name helpfull to identify the component in the list of scene components.
  100604. */
  100605. readonly name: string;
  100606. /**
  100607. * The scene the component belongs to.
  100608. */
  100609. scene: Scene;
  100610. /**
  100611. * Creates a new instance of the component for the given scene
  100612. * @param scene Defines the scene to register the component in
  100613. */
  100614. constructor(scene: Scene);
  100615. /**
  100616. * Registers the component in a given scene
  100617. */
  100618. register(): void;
  100619. /**
  100620. * Rebuilds the elements related to this component in case of
  100621. * context lost for instance.
  100622. */
  100623. rebuild(): void;
  100624. /**
  100625. * Disposes the component and the associated ressources
  100626. */
  100627. dispose(): void;
  100628. private _beforeCameraUpdate;
  100629. }
  100630. }
  100631. declare module BABYLON {
  100632. /**
  100633. * 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,
  100634. * which still works and will still be found in many Playgrounds.
  100635. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100636. */
  100637. export class UniversalCamera extends TouchCamera {
  100638. /**
  100639. * Defines the gamepad rotation sensiblity.
  100640. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100641. */
  100642. gamepadAngularSensibility: number;
  100643. /**
  100644. * Defines the gamepad move sensiblity.
  100645. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100646. */
  100647. gamepadMoveSensibility: number;
  100648. /**
  100649. * 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,
  100650. * which still works and will still be found in many Playgrounds.
  100651. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100652. * @param name Define the name of the camera in the scene
  100653. * @param position Define the start position of the camera in the scene
  100654. * @param scene Define the scene the camera belongs to
  100655. */
  100656. constructor(name: string, position: Vector3, scene: Scene);
  100657. /**
  100658. * Gets the current object class name.
  100659. * @return the class name
  100660. */
  100661. getClassName(): string;
  100662. }
  100663. }
  100664. declare module BABYLON {
  100665. /**
  100666. * This represents a FPS type of camera. This is only here for back compat purpose.
  100667. * Please use the UniversalCamera instead as both are identical.
  100668. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100669. */
  100670. export class GamepadCamera extends UniversalCamera {
  100671. /**
  100672. * Instantiates a new Gamepad Camera
  100673. * This represents a FPS type of camera. This is only here for back compat purpose.
  100674. * Please use the UniversalCamera instead as both are identical.
  100675. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100676. * @param name Define the name of the camera in the scene
  100677. * @param position Define the start position of the camera in the scene
  100678. * @param scene Define the scene the camera belongs to
  100679. */
  100680. constructor(name: string, position: Vector3, scene: Scene);
  100681. /**
  100682. * Gets the current object class name.
  100683. * @return the class name
  100684. */
  100685. getClassName(): string;
  100686. }
  100687. }
  100688. declare module BABYLON {
  100689. /** @hidden */
  100690. export var passPixelShader: {
  100691. name: string;
  100692. shader: string;
  100693. };
  100694. }
  100695. declare module BABYLON {
  100696. /** @hidden */
  100697. export var passCubePixelShader: {
  100698. name: string;
  100699. shader: string;
  100700. };
  100701. }
  100702. declare module BABYLON {
  100703. /**
  100704. * PassPostProcess which produces an output the same as it's input
  100705. */
  100706. export class PassPostProcess extends PostProcess {
  100707. /**
  100708. * Creates the PassPostProcess
  100709. * @param name The name of the effect.
  100710. * @param options The required width/height ratio to downsize to before computing the render pass.
  100711. * @param camera The camera to apply the render pass to.
  100712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100713. * @param engine The engine which the post process will be applied. (default: current engine)
  100714. * @param reusable If the post process can be reused on the same frame. (default: false)
  100715. * @param textureType The type of texture to be used when performing the post processing.
  100716. * @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)
  100717. */
  100718. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100719. }
  100720. /**
  100721. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  100722. */
  100723. export class PassCubePostProcess extends PostProcess {
  100724. private _face;
  100725. /**
  100726. * Gets or sets the cube face to display.
  100727. * * 0 is +X
  100728. * * 1 is -X
  100729. * * 2 is +Y
  100730. * * 3 is -Y
  100731. * * 4 is +Z
  100732. * * 5 is -Z
  100733. */
  100734. face: number;
  100735. /**
  100736. * Creates the PassCubePostProcess
  100737. * @param name The name of the effect.
  100738. * @param options The required width/height ratio to downsize to before computing the render pass.
  100739. * @param camera The camera to apply the render pass to.
  100740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100741. * @param engine The engine which the post process will be applied. (default: current engine)
  100742. * @param reusable If the post process can be reused on the same frame. (default: false)
  100743. * @param textureType The type of texture to be used when performing the post processing.
  100744. * @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)
  100745. */
  100746. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100747. }
  100748. }
  100749. declare module BABYLON {
  100750. /** @hidden */
  100751. export var anaglyphPixelShader: {
  100752. name: string;
  100753. shader: string;
  100754. };
  100755. }
  100756. declare module BABYLON {
  100757. /**
  100758. * Postprocess used to generate anaglyphic rendering
  100759. */
  100760. export class AnaglyphPostProcess extends PostProcess {
  100761. private _passedProcess;
  100762. /**
  100763. * Creates a new AnaglyphPostProcess
  100764. * @param name defines postprocess name
  100765. * @param options defines creation options or target ratio scale
  100766. * @param rigCameras defines cameras using this postprocess
  100767. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  100768. * @param engine defines hosting engine
  100769. * @param reusable defines if the postprocess will be reused multiple times per frame
  100770. */
  100771. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  100772. }
  100773. }
  100774. declare module BABYLON {
  100775. /**
  100776. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  100777. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100778. */
  100779. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  100780. /**
  100781. * Creates a new AnaglyphArcRotateCamera
  100782. * @param name defines camera name
  100783. * @param alpha defines alpha angle (in radians)
  100784. * @param beta defines beta angle (in radians)
  100785. * @param radius defines radius
  100786. * @param target defines camera target
  100787. * @param interaxialDistance defines distance between each color axis
  100788. * @param scene defines the hosting scene
  100789. */
  100790. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  100791. /**
  100792. * Gets camera class name
  100793. * @returns AnaglyphArcRotateCamera
  100794. */
  100795. getClassName(): string;
  100796. }
  100797. }
  100798. declare module BABYLON {
  100799. /**
  100800. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  100801. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100802. */
  100803. export class AnaglyphFreeCamera extends FreeCamera {
  100804. /**
  100805. * Creates a new AnaglyphFreeCamera
  100806. * @param name defines camera name
  100807. * @param position defines initial position
  100808. * @param interaxialDistance defines distance between each color axis
  100809. * @param scene defines the hosting scene
  100810. */
  100811. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100812. /**
  100813. * Gets camera class name
  100814. * @returns AnaglyphFreeCamera
  100815. */
  100816. getClassName(): string;
  100817. }
  100818. }
  100819. declare module BABYLON {
  100820. /**
  100821. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  100822. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100823. */
  100824. export class AnaglyphGamepadCamera extends GamepadCamera {
  100825. /**
  100826. * Creates a new AnaglyphGamepadCamera
  100827. * @param name defines camera name
  100828. * @param position defines initial position
  100829. * @param interaxialDistance defines distance between each color axis
  100830. * @param scene defines the hosting scene
  100831. */
  100832. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100833. /**
  100834. * Gets camera class name
  100835. * @returns AnaglyphGamepadCamera
  100836. */
  100837. getClassName(): string;
  100838. }
  100839. }
  100840. declare module BABYLON {
  100841. /**
  100842. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  100843. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100844. */
  100845. export class AnaglyphUniversalCamera extends UniversalCamera {
  100846. /**
  100847. * Creates a new AnaglyphUniversalCamera
  100848. * @param name defines camera name
  100849. * @param position defines initial position
  100850. * @param interaxialDistance defines distance between each color axis
  100851. * @param scene defines the hosting scene
  100852. */
  100853. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100854. /**
  100855. * Gets camera class name
  100856. * @returns AnaglyphUniversalCamera
  100857. */
  100858. getClassName(): string;
  100859. }
  100860. }
  100861. declare module BABYLON {
  100862. /** @hidden */
  100863. export var stereoscopicInterlacePixelShader: {
  100864. name: string;
  100865. shader: string;
  100866. };
  100867. }
  100868. declare module BABYLON {
  100869. /**
  100870. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  100871. */
  100872. export class StereoscopicInterlacePostProcess extends PostProcess {
  100873. private _stepSize;
  100874. private _passedProcess;
  100875. /**
  100876. * Initializes a StereoscopicInterlacePostProcess
  100877. * @param name The name of the effect.
  100878. * @param rigCameras The rig cameras to be appled to the post process
  100879. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  100880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100881. * @param engine The engine which the post process will be applied. (default: current engine)
  100882. * @param reusable If the post process can be reused on the same frame. (default: false)
  100883. */
  100884. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  100885. }
  100886. }
  100887. declare module BABYLON {
  100888. /**
  100889. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  100890. * @see http://doc.babylonjs.com/features/cameras
  100891. */
  100892. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  100893. /**
  100894. * Creates a new StereoscopicArcRotateCamera
  100895. * @param name defines camera name
  100896. * @param alpha defines alpha angle (in radians)
  100897. * @param beta defines beta angle (in radians)
  100898. * @param radius defines radius
  100899. * @param target defines camera target
  100900. * @param interaxialDistance defines distance between each color axis
  100901. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100902. * @param scene defines the hosting scene
  100903. */
  100904. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100905. /**
  100906. * Gets camera class name
  100907. * @returns StereoscopicArcRotateCamera
  100908. */
  100909. getClassName(): string;
  100910. }
  100911. }
  100912. declare module BABYLON {
  100913. /**
  100914. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  100915. * @see http://doc.babylonjs.com/features/cameras
  100916. */
  100917. export class StereoscopicFreeCamera extends FreeCamera {
  100918. /**
  100919. * Creates a new StereoscopicFreeCamera
  100920. * @param name defines camera name
  100921. * @param position defines initial position
  100922. * @param interaxialDistance defines distance between each color axis
  100923. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100924. * @param scene defines the hosting scene
  100925. */
  100926. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100927. /**
  100928. * Gets camera class name
  100929. * @returns StereoscopicFreeCamera
  100930. */
  100931. getClassName(): string;
  100932. }
  100933. }
  100934. declare module BABYLON {
  100935. /**
  100936. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  100937. * @see http://doc.babylonjs.com/features/cameras
  100938. */
  100939. export class StereoscopicGamepadCamera extends GamepadCamera {
  100940. /**
  100941. * Creates a new StereoscopicGamepadCamera
  100942. * @param name defines camera name
  100943. * @param position defines initial position
  100944. * @param interaxialDistance defines distance between each color axis
  100945. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100946. * @param scene defines the hosting scene
  100947. */
  100948. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100949. /**
  100950. * Gets camera class name
  100951. * @returns StereoscopicGamepadCamera
  100952. */
  100953. getClassName(): string;
  100954. }
  100955. }
  100956. declare module BABYLON {
  100957. /**
  100958. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  100959. * @see http://doc.babylonjs.com/features/cameras
  100960. */
  100961. export class StereoscopicUniversalCamera extends UniversalCamera {
  100962. /**
  100963. * Creates a new StereoscopicUniversalCamera
  100964. * @param name defines camera name
  100965. * @param position defines initial position
  100966. * @param interaxialDistance defines distance between each color axis
  100967. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100968. * @param scene defines the hosting scene
  100969. */
  100970. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100971. /**
  100972. * Gets camera class name
  100973. * @returns StereoscopicUniversalCamera
  100974. */
  100975. getClassName(): string;
  100976. }
  100977. }
  100978. declare module BABYLON {
  100979. /**
  100980. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100981. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100982. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100983. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100984. */
  100985. export class VirtualJoysticksCamera extends FreeCamera {
  100986. /**
  100987. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  100988. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100989. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100990. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100991. * @param name Define the name of the camera in the scene
  100992. * @param position Define the start position of the camera in the scene
  100993. * @param scene Define the scene the camera belongs to
  100994. */
  100995. constructor(name: string, position: Vector3, scene: Scene);
  100996. /**
  100997. * Gets the current object class name.
  100998. * @return the class name
  100999. */
  101000. getClassName(): string;
  101001. }
  101002. }
  101003. declare module BABYLON {
  101004. /**
  101005. * This represents all the required metrics to create a VR camera.
  101006. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101007. */
  101008. export class VRCameraMetrics {
  101009. /**
  101010. * Define the horizontal resolution off the screen.
  101011. */
  101012. hResolution: number;
  101013. /**
  101014. * Define the vertical resolution off the screen.
  101015. */
  101016. vResolution: number;
  101017. /**
  101018. * Define the horizontal screen size.
  101019. */
  101020. hScreenSize: number;
  101021. /**
  101022. * Define the vertical screen size.
  101023. */
  101024. vScreenSize: number;
  101025. /**
  101026. * Define the vertical screen center position.
  101027. */
  101028. vScreenCenter: number;
  101029. /**
  101030. * Define the distance of the eyes to the screen.
  101031. */
  101032. eyeToScreenDistance: number;
  101033. /**
  101034. * Define the distance between both lenses
  101035. */
  101036. lensSeparationDistance: number;
  101037. /**
  101038. * Define the distance between both viewer's eyes.
  101039. */
  101040. interpupillaryDistance: number;
  101041. /**
  101042. * Define the distortion factor of the VR postprocess.
  101043. * Please, touch with care.
  101044. */
  101045. distortionK: number[];
  101046. /**
  101047. * Define the chromatic aberration correction factors for the VR post process.
  101048. */
  101049. chromaAbCorrection: number[];
  101050. /**
  101051. * Define the scale factor of the post process.
  101052. * The smaller the better but the slower.
  101053. */
  101054. postProcessScaleFactor: number;
  101055. /**
  101056. * Define an offset for the lens center.
  101057. */
  101058. lensCenterOffset: number;
  101059. /**
  101060. * Define if the current vr camera should compensate the distortion of the lense or not.
  101061. */
  101062. compensateDistortion: boolean;
  101063. /**
  101064. * Defines if multiview should be enabled when rendering (Default: false)
  101065. */
  101066. multiviewEnabled: boolean;
  101067. /**
  101068. * Gets the rendering aspect ratio based on the provided resolutions.
  101069. */
  101070. readonly aspectRatio: number;
  101071. /**
  101072. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101073. */
  101074. readonly aspectRatioFov: number;
  101075. /**
  101076. * @hidden
  101077. */
  101078. readonly leftHMatrix: Matrix;
  101079. /**
  101080. * @hidden
  101081. */
  101082. readonly rightHMatrix: Matrix;
  101083. /**
  101084. * @hidden
  101085. */
  101086. readonly leftPreViewMatrix: Matrix;
  101087. /**
  101088. * @hidden
  101089. */
  101090. readonly rightPreViewMatrix: Matrix;
  101091. /**
  101092. * Get the default VRMetrics based on the most generic setup.
  101093. * @returns the default vr metrics
  101094. */
  101095. static GetDefault(): VRCameraMetrics;
  101096. }
  101097. }
  101098. declare module BABYLON {
  101099. /** @hidden */
  101100. export var vrDistortionCorrectionPixelShader: {
  101101. name: string;
  101102. shader: string;
  101103. };
  101104. }
  101105. declare module BABYLON {
  101106. /**
  101107. * VRDistortionCorrectionPostProcess used for mobile VR
  101108. */
  101109. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101110. private _isRightEye;
  101111. private _distortionFactors;
  101112. private _postProcessScaleFactor;
  101113. private _lensCenterOffset;
  101114. private _scaleIn;
  101115. private _scaleFactor;
  101116. private _lensCenter;
  101117. /**
  101118. * Initializes the VRDistortionCorrectionPostProcess
  101119. * @param name The name of the effect.
  101120. * @param camera The camera to apply the render pass to.
  101121. * @param isRightEye If this is for the right eye distortion
  101122. * @param vrMetrics All the required metrics for the VR camera
  101123. */
  101124. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101125. }
  101126. }
  101127. declare module BABYLON {
  101128. /**
  101129. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101130. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101131. */
  101132. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101133. /**
  101134. * Creates a new VRDeviceOrientationArcRotateCamera
  101135. * @param name defines camera name
  101136. * @param alpha defines the camera rotation along the logitudinal axis
  101137. * @param beta defines the camera rotation along the latitudinal axis
  101138. * @param radius defines the camera distance from its target
  101139. * @param target defines the camera target
  101140. * @param scene defines the scene the camera belongs to
  101141. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101142. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101143. */
  101144. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101145. /**
  101146. * Gets camera class name
  101147. * @returns VRDeviceOrientationArcRotateCamera
  101148. */
  101149. getClassName(): string;
  101150. }
  101151. }
  101152. declare module BABYLON {
  101153. /**
  101154. * Camera used to simulate VR rendering (based on FreeCamera)
  101155. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101156. */
  101157. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101158. /**
  101159. * Creates a new VRDeviceOrientationFreeCamera
  101160. * @param name defines camera name
  101161. * @param position defines the start position of the camera
  101162. * @param scene defines the scene the camera belongs to
  101163. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101164. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101165. */
  101166. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101167. /**
  101168. * Gets camera class name
  101169. * @returns VRDeviceOrientationFreeCamera
  101170. */
  101171. getClassName(): string;
  101172. }
  101173. }
  101174. declare module BABYLON {
  101175. /**
  101176. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101177. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101178. */
  101179. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101180. /**
  101181. * Creates a new VRDeviceOrientationGamepadCamera
  101182. * @param name defines camera name
  101183. * @param position defines the start position of the camera
  101184. * @param scene defines the scene the camera belongs to
  101185. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101186. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101187. */
  101188. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101189. /**
  101190. * Gets camera class name
  101191. * @returns VRDeviceOrientationGamepadCamera
  101192. */
  101193. getClassName(): string;
  101194. }
  101195. }
  101196. declare module BABYLON {
  101197. /**
  101198. * Base class of materials working in push mode in babylon JS
  101199. * @hidden
  101200. */
  101201. export class PushMaterial extends Material {
  101202. protected _activeEffect: Effect;
  101203. protected _normalMatrix: Matrix;
  101204. /**
  101205. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101206. * This means that the material can keep using a previous shader while a new one is being compiled.
  101207. * This is mostly used when shader parallel compilation is supported (true by default)
  101208. */
  101209. allowShaderHotSwapping: boolean;
  101210. constructor(name: string, scene: Scene);
  101211. getEffect(): Effect;
  101212. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101213. /**
  101214. * Binds the given world matrix to the active effect
  101215. *
  101216. * @param world the matrix to bind
  101217. */
  101218. bindOnlyWorldMatrix(world: Matrix): void;
  101219. /**
  101220. * Binds the given normal matrix to the active effect
  101221. *
  101222. * @param normalMatrix the matrix to bind
  101223. */
  101224. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101225. bind(world: Matrix, mesh?: Mesh): void;
  101226. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101227. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101228. }
  101229. }
  101230. declare module BABYLON {
  101231. /**
  101232. * This groups all the flags used to control the materials channel.
  101233. */
  101234. export class MaterialFlags {
  101235. private static _DiffuseTextureEnabled;
  101236. /**
  101237. * Are diffuse textures enabled in the application.
  101238. */
  101239. static DiffuseTextureEnabled: boolean;
  101240. private static _AmbientTextureEnabled;
  101241. /**
  101242. * Are ambient textures enabled in the application.
  101243. */
  101244. static AmbientTextureEnabled: boolean;
  101245. private static _OpacityTextureEnabled;
  101246. /**
  101247. * Are opacity textures enabled in the application.
  101248. */
  101249. static OpacityTextureEnabled: boolean;
  101250. private static _ReflectionTextureEnabled;
  101251. /**
  101252. * Are reflection textures enabled in the application.
  101253. */
  101254. static ReflectionTextureEnabled: boolean;
  101255. private static _EmissiveTextureEnabled;
  101256. /**
  101257. * Are emissive textures enabled in the application.
  101258. */
  101259. static EmissiveTextureEnabled: boolean;
  101260. private static _SpecularTextureEnabled;
  101261. /**
  101262. * Are specular textures enabled in the application.
  101263. */
  101264. static SpecularTextureEnabled: boolean;
  101265. private static _BumpTextureEnabled;
  101266. /**
  101267. * Are bump textures enabled in the application.
  101268. */
  101269. static BumpTextureEnabled: boolean;
  101270. private static _LightmapTextureEnabled;
  101271. /**
  101272. * Are lightmap textures enabled in the application.
  101273. */
  101274. static LightmapTextureEnabled: boolean;
  101275. private static _RefractionTextureEnabled;
  101276. /**
  101277. * Are refraction textures enabled in the application.
  101278. */
  101279. static RefractionTextureEnabled: boolean;
  101280. private static _ColorGradingTextureEnabled;
  101281. /**
  101282. * Are color grading textures enabled in the application.
  101283. */
  101284. static ColorGradingTextureEnabled: boolean;
  101285. private static _FresnelEnabled;
  101286. /**
  101287. * Are fresnels enabled in the application.
  101288. */
  101289. static FresnelEnabled: boolean;
  101290. private static _ClearCoatTextureEnabled;
  101291. /**
  101292. * Are clear coat textures enabled in the application.
  101293. */
  101294. static ClearCoatTextureEnabled: boolean;
  101295. private static _ClearCoatBumpTextureEnabled;
  101296. /**
  101297. * Are clear coat bump textures enabled in the application.
  101298. */
  101299. static ClearCoatBumpTextureEnabled: boolean;
  101300. private static _ClearCoatTintTextureEnabled;
  101301. /**
  101302. * Are clear coat tint textures enabled in the application.
  101303. */
  101304. static ClearCoatTintTextureEnabled: boolean;
  101305. private static _SheenTextureEnabled;
  101306. /**
  101307. * Are sheen textures enabled in the application.
  101308. */
  101309. static SheenTextureEnabled: boolean;
  101310. private static _AnisotropicTextureEnabled;
  101311. /**
  101312. * Are anisotropic textures enabled in the application.
  101313. */
  101314. static AnisotropicTextureEnabled: boolean;
  101315. private static _ThicknessTextureEnabled;
  101316. /**
  101317. * Are thickness textures enabled in the application.
  101318. */
  101319. static ThicknessTextureEnabled: boolean;
  101320. }
  101321. }
  101322. declare module BABYLON {
  101323. /** @hidden */
  101324. export var defaultFragmentDeclaration: {
  101325. name: string;
  101326. shader: string;
  101327. };
  101328. }
  101329. declare module BABYLON {
  101330. /** @hidden */
  101331. export var defaultUboDeclaration: {
  101332. name: string;
  101333. shader: string;
  101334. };
  101335. }
  101336. declare module BABYLON {
  101337. /** @hidden */
  101338. export var lightFragmentDeclaration: {
  101339. name: string;
  101340. shader: string;
  101341. };
  101342. }
  101343. declare module BABYLON {
  101344. /** @hidden */
  101345. export var lightUboDeclaration: {
  101346. name: string;
  101347. shader: string;
  101348. };
  101349. }
  101350. declare module BABYLON {
  101351. /** @hidden */
  101352. export var lightsFragmentFunctions: {
  101353. name: string;
  101354. shader: string;
  101355. };
  101356. }
  101357. declare module BABYLON {
  101358. /** @hidden */
  101359. export var shadowsFragmentFunctions: {
  101360. name: string;
  101361. shader: string;
  101362. };
  101363. }
  101364. declare module BABYLON {
  101365. /** @hidden */
  101366. export var fresnelFunction: {
  101367. name: string;
  101368. shader: string;
  101369. };
  101370. }
  101371. declare module BABYLON {
  101372. /** @hidden */
  101373. export var reflectionFunction: {
  101374. name: string;
  101375. shader: string;
  101376. };
  101377. }
  101378. declare module BABYLON {
  101379. /** @hidden */
  101380. export var bumpFragmentFunctions: {
  101381. name: string;
  101382. shader: string;
  101383. };
  101384. }
  101385. declare module BABYLON {
  101386. /** @hidden */
  101387. export var logDepthDeclaration: {
  101388. name: string;
  101389. shader: string;
  101390. };
  101391. }
  101392. declare module BABYLON {
  101393. /** @hidden */
  101394. export var bumpFragment: {
  101395. name: string;
  101396. shader: string;
  101397. };
  101398. }
  101399. declare module BABYLON {
  101400. /** @hidden */
  101401. export var depthPrePass: {
  101402. name: string;
  101403. shader: string;
  101404. };
  101405. }
  101406. declare module BABYLON {
  101407. /** @hidden */
  101408. export var lightFragment: {
  101409. name: string;
  101410. shader: string;
  101411. };
  101412. }
  101413. declare module BABYLON {
  101414. /** @hidden */
  101415. export var logDepthFragment: {
  101416. name: string;
  101417. shader: string;
  101418. };
  101419. }
  101420. declare module BABYLON {
  101421. /** @hidden */
  101422. export var defaultPixelShader: {
  101423. name: string;
  101424. shader: string;
  101425. };
  101426. }
  101427. declare module BABYLON {
  101428. /** @hidden */
  101429. export var defaultVertexDeclaration: {
  101430. name: string;
  101431. shader: string;
  101432. };
  101433. }
  101434. declare module BABYLON {
  101435. /** @hidden */
  101436. export var bumpVertexDeclaration: {
  101437. name: string;
  101438. shader: string;
  101439. };
  101440. }
  101441. declare module BABYLON {
  101442. /** @hidden */
  101443. export var bumpVertex: {
  101444. name: string;
  101445. shader: string;
  101446. };
  101447. }
  101448. declare module BABYLON {
  101449. /** @hidden */
  101450. export var fogVertex: {
  101451. name: string;
  101452. shader: string;
  101453. };
  101454. }
  101455. declare module BABYLON {
  101456. /** @hidden */
  101457. export var shadowsVertex: {
  101458. name: string;
  101459. shader: string;
  101460. };
  101461. }
  101462. declare module BABYLON {
  101463. /** @hidden */
  101464. export var pointCloudVertex: {
  101465. name: string;
  101466. shader: string;
  101467. };
  101468. }
  101469. declare module BABYLON {
  101470. /** @hidden */
  101471. export var logDepthVertex: {
  101472. name: string;
  101473. shader: string;
  101474. };
  101475. }
  101476. declare module BABYLON {
  101477. /** @hidden */
  101478. export var defaultVertexShader: {
  101479. name: string;
  101480. shader: string;
  101481. };
  101482. }
  101483. declare module BABYLON {
  101484. /** @hidden */
  101485. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101486. MAINUV1: boolean;
  101487. MAINUV2: boolean;
  101488. DIFFUSE: boolean;
  101489. DIFFUSEDIRECTUV: number;
  101490. AMBIENT: boolean;
  101491. AMBIENTDIRECTUV: number;
  101492. OPACITY: boolean;
  101493. OPACITYDIRECTUV: number;
  101494. OPACITYRGB: boolean;
  101495. REFLECTION: boolean;
  101496. EMISSIVE: boolean;
  101497. EMISSIVEDIRECTUV: number;
  101498. SPECULAR: boolean;
  101499. SPECULARDIRECTUV: number;
  101500. BUMP: boolean;
  101501. BUMPDIRECTUV: number;
  101502. PARALLAX: boolean;
  101503. PARALLAXOCCLUSION: boolean;
  101504. SPECULAROVERALPHA: boolean;
  101505. CLIPPLANE: boolean;
  101506. CLIPPLANE2: boolean;
  101507. CLIPPLANE3: boolean;
  101508. CLIPPLANE4: boolean;
  101509. ALPHATEST: boolean;
  101510. DEPTHPREPASS: boolean;
  101511. ALPHAFROMDIFFUSE: boolean;
  101512. POINTSIZE: boolean;
  101513. FOG: boolean;
  101514. SPECULARTERM: boolean;
  101515. DIFFUSEFRESNEL: boolean;
  101516. OPACITYFRESNEL: boolean;
  101517. REFLECTIONFRESNEL: boolean;
  101518. REFRACTIONFRESNEL: boolean;
  101519. EMISSIVEFRESNEL: boolean;
  101520. FRESNEL: boolean;
  101521. NORMAL: boolean;
  101522. UV1: boolean;
  101523. UV2: boolean;
  101524. VERTEXCOLOR: boolean;
  101525. VERTEXALPHA: boolean;
  101526. NUM_BONE_INFLUENCERS: number;
  101527. BonesPerMesh: number;
  101528. BONETEXTURE: boolean;
  101529. INSTANCES: boolean;
  101530. GLOSSINESS: boolean;
  101531. ROUGHNESS: boolean;
  101532. EMISSIVEASILLUMINATION: boolean;
  101533. LINKEMISSIVEWITHDIFFUSE: boolean;
  101534. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101535. LIGHTMAP: boolean;
  101536. LIGHTMAPDIRECTUV: number;
  101537. OBJECTSPACE_NORMALMAP: boolean;
  101538. USELIGHTMAPASSHADOWMAP: boolean;
  101539. REFLECTIONMAP_3D: boolean;
  101540. REFLECTIONMAP_SPHERICAL: boolean;
  101541. REFLECTIONMAP_PLANAR: boolean;
  101542. REFLECTIONMAP_CUBIC: boolean;
  101543. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101544. REFLECTIONMAP_PROJECTION: boolean;
  101545. REFLECTIONMAP_SKYBOX: boolean;
  101546. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101547. REFLECTIONMAP_EXPLICIT: boolean;
  101548. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101549. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101550. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101551. INVERTCUBICMAP: boolean;
  101552. LOGARITHMICDEPTH: boolean;
  101553. REFRACTION: boolean;
  101554. REFRACTIONMAP_3D: boolean;
  101555. REFLECTIONOVERALPHA: boolean;
  101556. TWOSIDEDLIGHTING: boolean;
  101557. SHADOWFLOAT: boolean;
  101558. MORPHTARGETS: boolean;
  101559. MORPHTARGETS_NORMAL: boolean;
  101560. MORPHTARGETS_TANGENT: boolean;
  101561. NUM_MORPH_INFLUENCERS: number;
  101562. NONUNIFORMSCALING: boolean;
  101563. PREMULTIPLYALPHA: boolean;
  101564. IMAGEPROCESSING: boolean;
  101565. VIGNETTE: boolean;
  101566. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101567. VIGNETTEBLENDMODEOPAQUE: boolean;
  101568. TONEMAPPING: boolean;
  101569. TONEMAPPING_ACES: boolean;
  101570. CONTRAST: boolean;
  101571. COLORCURVES: boolean;
  101572. COLORGRADING: boolean;
  101573. COLORGRADING3D: boolean;
  101574. SAMPLER3DGREENDEPTH: boolean;
  101575. SAMPLER3DBGRMAP: boolean;
  101576. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101577. MULTIVIEW: boolean;
  101578. /**
  101579. * If the reflection texture on this material is in linear color space
  101580. * @hidden
  101581. */
  101582. IS_REFLECTION_LINEAR: boolean;
  101583. /**
  101584. * If the refraction texture on this material is in linear color space
  101585. * @hidden
  101586. */
  101587. IS_REFRACTION_LINEAR: boolean;
  101588. EXPOSURE: boolean;
  101589. constructor();
  101590. setReflectionMode(modeToEnable: string): void;
  101591. }
  101592. /**
  101593. * This is the default material used in Babylon. It is the best trade off between quality
  101594. * and performances.
  101595. * @see http://doc.babylonjs.com/babylon101/materials
  101596. */
  101597. export class StandardMaterial extends PushMaterial {
  101598. private _diffuseTexture;
  101599. /**
  101600. * The basic texture of the material as viewed under a light.
  101601. */
  101602. diffuseTexture: Nullable<BaseTexture>;
  101603. private _ambientTexture;
  101604. /**
  101605. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101606. */
  101607. ambientTexture: Nullable<BaseTexture>;
  101608. private _opacityTexture;
  101609. /**
  101610. * Define the transparency of the material from a texture.
  101611. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101612. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101613. */
  101614. opacityTexture: Nullable<BaseTexture>;
  101615. private _reflectionTexture;
  101616. /**
  101617. * Define the texture used to display the reflection.
  101618. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101619. */
  101620. reflectionTexture: Nullable<BaseTexture>;
  101621. private _emissiveTexture;
  101622. /**
  101623. * Define texture of the material as if self lit.
  101624. * This will be mixed in the final result even in the absence of light.
  101625. */
  101626. emissiveTexture: Nullable<BaseTexture>;
  101627. private _specularTexture;
  101628. /**
  101629. * Define how the color and intensity of the highlight given by the light in the material.
  101630. */
  101631. specularTexture: Nullable<BaseTexture>;
  101632. private _bumpTexture;
  101633. /**
  101634. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101635. * 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.
  101636. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101637. */
  101638. bumpTexture: Nullable<BaseTexture>;
  101639. private _lightmapTexture;
  101640. /**
  101641. * Complex lighting can be computationally expensive to compute at runtime.
  101642. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101643. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101644. */
  101645. lightmapTexture: Nullable<BaseTexture>;
  101646. private _refractionTexture;
  101647. /**
  101648. * Define the texture used to display the refraction.
  101649. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101650. */
  101651. refractionTexture: Nullable<BaseTexture>;
  101652. /**
  101653. * The color of the material lit by the environmental background lighting.
  101654. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101655. */
  101656. ambientColor: Color3;
  101657. /**
  101658. * The basic color of the material as viewed under a light.
  101659. */
  101660. diffuseColor: Color3;
  101661. /**
  101662. * Define how the color and intensity of the highlight given by the light in the material.
  101663. */
  101664. specularColor: Color3;
  101665. /**
  101666. * Define the color of the material as if self lit.
  101667. * This will be mixed in the final result even in the absence of light.
  101668. */
  101669. emissiveColor: Color3;
  101670. /**
  101671. * Defines how sharp are the highlights in the material.
  101672. * The bigger the value the sharper giving a more glossy feeling to the result.
  101673. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101674. */
  101675. specularPower: number;
  101676. private _useAlphaFromDiffuseTexture;
  101677. /**
  101678. * Does the transparency come from the diffuse texture alpha channel.
  101679. */
  101680. useAlphaFromDiffuseTexture: boolean;
  101681. private _useEmissiveAsIllumination;
  101682. /**
  101683. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101684. */
  101685. useEmissiveAsIllumination: boolean;
  101686. private _linkEmissiveWithDiffuse;
  101687. /**
  101688. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101689. * the emissive level when the final color is close to one.
  101690. */
  101691. linkEmissiveWithDiffuse: boolean;
  101692. private _useSpecularOverAlpha;
  101693. /**
  101694. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101695. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101696. */
  101697. useSpecularOverAlpha: boolean;
  101698. private _useReflectionOverAlpha;
  101699. /**
  101700. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101701. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101702. */
  101703. useReflectionOverAlpha: boolean;
  101704. private _disableLighting;
  101705. /**
  101706. * Does lights from the scene impacts this material.
  101707. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101708. */
  101709. disableLighting: boolean;
  101710. private _useObjectSpaceNormalMap;
  101711. /**
  101712. * Allows using an object space normal map (instead of tangent space).
  101713. */
  101714. useObjectSpaceNormalMap: boolean;
  101715. private _useParallax;
  101716. /**
  101717. * Is parallax enabled or not.
  101718. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101719. */
  101720. useParallax: boolean;
  101721. private _useParallaxOcclusion;
  101722. /**
  101723. * Is parallax occlusion enabled or not.
  101724. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101725. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101726. */
  101727. useParallaxOcclusion: boolean;
  101728. /**
  101729. * 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.
  101730. */
  101731. parallaxScaleBias: number;
  101732. private _roughness;
  101733. /**
  101734. * Helps to define how blurry the reflections should appears in the material.
  101735. */
  101736. roughness: number;
  101737. /**
  101738. * In case of refraction, define the value of the index of refraction.
  101739. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101740. */
  101741. indexOfRefraction: number;
  101742. /**
  101743. * Invert the refraction texture alongside the y axis.
  101744. * It can be useful with procedural textures or probe for instance.
  101745. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101746. */
  101747. invertRefractionY: boolean;
  101748. /**
  101749. * Defines the alpha limits in alpha test mode.
  101750. */
  101751. alphaCutOff: number;
  101752. private _useLightmapAsShadowmap;
  101753. /**
  101754. * In case of light mapping, define whether the map contains light or shadow informations.
  101755. */
  101756. useLightmapAsShadowmap: boolean;
  101757. private _diffuseFresnelParameters;
  101758. /**
  101759. * Define the diffuse fresnel parameters of the material.
  101760. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101761. */
  101762. diffuseFresnelParameters: FresnelParameters;
  101763. private _opacityFresnelParameters;
  101764. /**
  101765. * Define the opacity fresnel parameters of the material.
  101766. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101767. */
  101768. opacityFresnelParameters: FresnelParameters;
  101769. private _reflectionFresnelParameters;
  101770. /**
  101771. * Define the reflection fresnel parameters of the material.
  101772. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101773. */
  101774. reflectionFresnelParameters: FresnelParameters;
  101775. private _refractionFresnelParameters;
  101776. /**
  101777. * Define the refraction fresnel parameters of the material.
  101778. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101779. */
  101780. refractionFresnelParameters: FresnelParameters;
  101781. private _emissiveFresnelParameters;
  101782. /**
  101783. * Define the emissive fresnel parameters of the material.
  101784. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101785. */
  101786. emissiveFresnelParameters: FresnelParameters;
  101787. private _useReflectionFresnelFromSpecular;
  101788. /**
  101789. * If true automatically deducts the fresnels values from the material specularity.
  101790. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101791. */
  101792. useReflectionFresnelFromSpecular: boolean;
  101793. private _useGlossinessFromSpecularMapAlpha;
  101794. /**
  101795. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101796. */
  101797. useGlossinessFromSpecularMapAlpha: boolean;
  101798. private _maxSimultaneousLights;
  101799. /**
  101800. * Defines the maximum number of lights that can be used in the material
  101801. */
  101802. maxSimultaneousLights: number;
  101803. private _invertNormalMapX;
  101804. /**
  101805. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101806. */
  101807. invertNormalMapX: boolean;
  101808. private _invertNormalMapY;
  101809. /**
  101810. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101811. */
  101812. invertNormalMapY: boolean;
  101813. private _twoSidedLighting;
  101814. /**
  101815. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101816. */
  101817. twoSidedLighting: boolean;
  101818. /**
  101819. * Default configuration related to image processing available in the standard Material.
  101820. */
  101821. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101822. /**
  101823. * Gets the image processing configuration used either in this material.
  101824. */
  101825. /**
  101826. * Sets the Default image processing configuration used either in the this material.
  101827. *
  101828. * If sets to null, the scene one is in use.
  101829. */
  101830. imageProcessingConfiguration: ImageProcessingConfiguration;
  101831. /**
  101832. * Keep track of the image processing observer to allow dispose and replace.
  101833. */
  101834. private _imageProcessingObserver;
  101835. /**
  101836. * Attaches a new image processing configuration to the Standard Material.
  101837. * @param configuration
  101838. */
  101839. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101840. /**
  101841. * Gets wether the color curves effect is enabled.
  101842. */
  101843. /**
  101844. * Sets wether the color curves effect is enabled.
  101845. */
  101846. cameraColorCurvesEnabled: boolean;
  101847. /**
  101848. * Gets wether the color grading effect is enabled.
  101849. */
  101850. /**
  101851. * Gets wether the color grading effect is enabled.
  101852. */
  101853. cameraColorGradingEnabled: boolean;
  101854. /**
  101855. * Gets wether tonemapping is enabled or not.
  101856. */
  101857. /**
  101858. * Sets wether tonemapping is enabled or not
  101859. */
  101860. cameraToneMappingEnabled: boolean;
  101861. /**
  101862. * The camera exposure used on this material.
  101863. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101864. * This corresponds to a photographic exposure.
  101865. */
  101866. /**
  101867. * The camera exposure used on this material.
  101868. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101869. * This corresponds to a photographic exposure.
  101870. */
  101871. cameraExposure: number;
  101872. /**
  101873. * Gets The camera contrast used on this material.
  101874. */
  101875. /**
  101876. * Sets The camera contrast used on this material.
  101877. */
  101878. cameraContrast: number;
  101879. /**
  101880. * Gets the Color Grading 2D Lookup Texture.
  101881. */
  101882. /**
  101883. * Sets the Color Grading 2D Lookup Texture.
  101884. */
  101885. cameraColorGradingTexture: Nullable<BaseTexture>;
  101886. /**
  101887. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101888. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101889. * 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;
  101890. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101891. */
  101892. /**
  101893. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101894. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101895. * 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;
  101896. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101897. */
  101898. cameraColorCurves: Nullable<ColorCurves>;
  101899. /**
  101900. * Custom callback helping to override the default shader used in the material.
  101901. */
  101902. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  101903. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101904. protected _worldViewProjectionMatrix: Matrix;
  101905. protected _globalAmbientColor: Color3;
  101906. protected _useLogarithmicDepth: boolean;
  101907. /**
  101908. * Instantiates a new standard material.
  101909. * This is the default material used in Babylon. It is the best trade off between quality
  101910. * and performances.
  101911. * @see http://doc.babylonjs.com/babylon101/materials
  101912. * @param name Define the name of the material in the scene
  101913. * @param scene Define the scene the material belong to
  101914. */
  101915. constructor(name: string, scene: Scene);
  101916. /**
  101917. * Gets a boolean indicating that current material needs to register RTT
  101918. */
  101919. readonly hasRenderTargetTextures: boolean;
  101920. /**
  101921. * Gets the current class name of the material e.g. "StandardMaterial"
  101922. * Mainly use in serialization.
  101923. * @returns the class name
  101924. */
  101925. getClassName(): string;
  101926. /**
  101927. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101928. * You can try switching to logarithmic depth.
  101929. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101930. */
  101931. useLogarithmicDepth: boolean;
  101932. /**
  101933. * Specifies if the material will require alpha blending
  101934. * @returns a boolean specifying if alpha blending is needed
  101935. */
  101936. needAlphaBlending(): boolean;
  101937. /**
  101938. * Specifies if this material should be rendered in alpha test mode
  101939. * @returns a boolean specifying if an alpha test is needed.
  101940. */
  101941. needAlphaTesting(): boolean;
  101942. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101943. /**
  101944. * Get the texture used for alpha test purpose.
  101945. * @returns the diffuse texture in case of the standard material.
  101946. */
  101947. getAlphaTestTexture(): Nullable<BaseTexture>;
  101948. /**
  101949. * Get if the submesh is ready to be used and all its information available.
  101950. * Child classes can use it to update shaders
  101951. * @param mesh defines the mesh to check
  101952. * @param subMesh defines which submesh to check
  101953. * @param useInstances specifies that instances should be used
  101954. * @returns a boolean indicating that the submesh is ready or not
  101955. */
  101956. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101957. /**
  101958. * Builds the material UBO layouts.
  101959. * Used internally during the effect preparation.
  101960. */
  101961. buildUniformLayout(): void;
  101962. /**
  101963. * Unbinds the material from the mesh
  101964. */
  101965. unbind(): void;
  101966. /**
  101967. * Binds the submesh to this material by preparing the effect and shader to draw
  101968. * @param world defines the world transformation matrix
  101969. * @param mesh defines the mesh containing the submesh
  101970. * @param subMesh defines the submesh to bind the material to
  101971. */
  101972. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101973. /**
  101974. * Get the list of animatables in the material.
  101975. * @returns the list of animatables object used in the material
  101976. */
  101977. getAnimatables(): IAnimatable[];
  101978. /**
  101979. * Gets the active textures from the material
  101980. * @returns an array of textures
  101981. */
  101982. getActiveTextures(): BaseTexture[];
  101983. /**
  101984. * Specifies if the material uses a texture
  101985. * @param texture defines the texture to check against the material
  101986. * @returns a boolean specifying if the material uses the texture
  101987. */
  101988. hasTexture(texture: BaseTexture): boolean;
  101989. /**
  101990. * Disposes the material
  101991. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101992. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101993. */
  101994. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101995. /**
  101996. * Makes a duplicate of the material, and gives it a new name
  101997. * @param name defines the new name for the duplicated material
  101998. * @returns the cloned material
  101999. */
  102000. clone(name: string): StandardMaterial;
  102001. /**
  102002. * Serializes this material in a JSON representation
  102003. * @returns the serialized material object
  102004. */
  102005. serialize(): any;
  102006. /**
  102007. * Creates a standard material from parsed material data
  102008. * @param source defines the JSON representation of the material
  102009. * @param scene defines the hosting scene
  102010. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102011. * @returns a new standard material
  102012. */
  102013. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102014. /**
  102015. * Are diffuse textures enabled in the application.
  102016. */
  102017. static DiffuseTextureEnabled: boolean;
  102018. /**
  102019. * Are ambient textures enabled in the application.
  102020. */
  102021. static AmbientTextureEnabled: boolean;
  102022. /**
  102023. * Are opacity textures enabled in the application.
  102024. */
  102025. static OpacityTextureEnabled: boolean;
  102026. /**
  102027. * Are reflection textures enabled in the application.
  102028. */
  102029. static ReflectionTextureEnabled: boolean;
  102030. /**
  102031. * Are emissive textures enabled in the application.
  102032. */
  102033. static EmissiveTextureEnabled: boolean;
  102034. /**
  102035. * Are specular textures enabled in the application.
  102036. */
  102037. static SpecularTextureEnabled: boolean;
  102038. /**
  102039. * Are bump textures enabled in the application.
  102040. */
  102041. static BumpTextureEnabled: boolean;
  102042. /**
  102043. * Are lightmap textures enabled in the application.
  102044. */
  102045. static LightmapTextureEnabled: boolean;
  102046. /**
  102047. * Are refraction textures enabled in the application.
  102048. */
  102049. static RefractionTextureEnabled: boolean;
  102050. /**
  102051. * Are color grading textures enabled in the application.
  102052. */
  102053. static ColorGradingTextureEnabled: boolean;
  102054. /**
  102055. * Are fresnels enabled in the application.
  102056. */
  102057. static FresnelEnabled: boolean;
  102058. }
  102059. }
  102060. declare module BABYLON {
  102061. /**
  102062. * A class extending Texture allowing drawing on a texture
  102063. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102064. */
  102065. export class DynamicTexture extends Texture {
  102066. private _generateMipMaps;
  102067. private _canvas;
  102068. private _context;
  102069. private _engine;
  102070. /**
  102071. * Creates a DynamicTexture
  102072. * @param name defines the name of the texture
  102073. * @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
  102074. * @param scene defines the scene where you want the texture
  102075. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102076. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102077. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102078. */
  102079. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102080. /**
  102081. * Get the current class name of the texture useful for serialization or dynamic coding.
  102082. * @returns "DynamicTexture"
  102083. */
  102084. getClassName(): string;
  102085. /**
  102086. * Gets the current state of canRescale
  102087. */
  102088. readonly canRescale: boolean;
  102089. private _recreate;
  102090. /**
  102091. * Scales the texture
  102092. * @param ratio the scale factor to apply to both width and height
  102093. */
  102094. scale(ratio: number): void;
  102095. /**
  102096. * Resizes the texture
  102097. * @param width the new width
  102098. * @param height the new height
  102099. */
  102100. scaleTo(width: number, height: number): void;
  102101. /**
  102102. * Gets the context of the canvas used by the texture
  102103. * @returns the canvas context of the dynamic texture
  102104. */
  102105. getContext(): CanvasRenderingContext2D;
  102106. /**
  102107. * Clears the texture
  102108. */
  102109. clear(): void;
  102110. /**
  102111. * Updates the texture
  102112. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102113. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102114. */
  102115. update(invertY?: boolean, premulAlpha?: boolean): void;
  102116. /**
  102117. * Draws text onto the texture
  102118. * @param text defines the text to be drawn
  102119. * @param x defines the placement of the text from the left
  102120. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102121. * @param font defines the font to be used with font-style, font-size, font-name
  102122. * @param color defines the color used for the text
  102123. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102124. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102125. * @param update defines whether texture is immediately update (default is true)
  102126. */
  102127. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102128. /**
  102129. * Clones the texture
  102130. * @returns the clone of the texture.
  102131. */
  102132. clone(): DynamicTexture;
  102133. /**
  102134. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102135. * @returns a serialized dynamic texture object
  102136. */
  102137. serialize(): any;
  102138. /** @hidden */
  102139. _rebuild(): void;
  102140. }
  102141. }
  102142. declare module BABYLON {
  102143. /** @hidden */
  102144. export var imageProcessingPixelShader: {
  102145. name: string;
  102146. shader: string;
  102147. };
  102148. }
  102149. declare module BABYLON {
  102150. /**
  102151. * ImageProcessingPostProcess
  102152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102153. */
  102154. export class ImageProcessingPostProcess extends PostProcess {
  102155. /**
  102156. * Default configuration related to image processing available in the PBR Material.
  102157. */
  102158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102159. /**
  102160. * Gets the image processing configuration used either in this material.
  102161. */
  102162. /**
  102163. * Sets the Default image processing configuration used either in the this material.
  102164. *
  102165. * If sets to null, the scene one is in use.
  102166. */
  102167. imageProcessingConfiguration: ImageProcessingConfiguration;
  102168. /**
  102169. * Keep track of the image processing observer to allow dispose and replace.
  102170. */
  102171. private _imageProcessingObserver;
  102172. /**
  102173. * Attaches a new image processing configuration to the PBR Material.
  102174. * @param configuration
  102175. */
  102176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102177. /**
  102178. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102179. */
  102180. /**
  102181. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102182. */
  102183. colorCurves: Nullable<ColorCurves>;
  102184. /**
  102185. * Gets wether the color curves effect is enabled.
  102186. */
  102187. /**
  102188. * Sets wether the color curves effect is enabled.
  102189. */
  102190. colorCurvesEnabled: boolean;
  102191. /**
  102192. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102193. */
  102194. /**
  102195. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102196. */
  102197. colorGradingTexture: Nullable<BaseTexture>;
  102198. /**
  102199. * Gets wether the color grading effect is enabled.
  102200. */
  102201. /**
  102202. * Gets wether the color grading effect is enabled.
  102203. */
  102204. colorGradingEnabled: boolean;
  102205. /**
  102206. * Gets exposure used in the effect.
  102207. */
  102208. /**
  102209. * Sets exposure used in the effect.
  102210. */
  102211. exposure: number;
  102212. /**
  102213. * Gets wether tonemapping is enabled or not.
  102214. */
  102215. /**
  102216. * Sets wether tonemapping is enabled or not
  102217. */
  102218. toneMappingEnabled: boolean;
  102219. /**
  102220. * Gets the type of tone mapping effect.
  102221. */
  102222. /**
  102223. * Sets the type of tone mapping effect.
  102224. */
  102225. toneMappingType: number;
  102226. /**
  102227. * Gets contrast used in the effect.
  102228. */
  102229. /**
  102230. * Sets contrast used in the effect.
  102231. */
  102232. contrast: number;
  102233. /**
  102234. * Gets Vignette stretch size.
  102235. */
  102236. /**
  102237. * Sets Vignette stretch size.
  102238. */
  102239. vignetteStretch: number;
  102240. /**
  102241. * Gets Vignette centre X Offset.
  102242. */
  102243. /**
  102244. * Sets Vignette centre X Offset.
  102245. */
  102246. vignetteCentreX: number;
  102247. /**
  102248. * Gets Vignette centre Y Offset.
  102249. */
  102250. /**
  102251. * Sets Vignette centre Y Offset.
  102252. */
  102253. vignetteCentreY: number;
  102254. /**
  102255. * Gets Vignette weight or intensity of the vignette effect.
  102256. */
  102257. /**
  102258. * Sets Vignette weight or intensity of the vignette effect.
  102259. */
  102260. vignetteWeight: number;
  102261. /**
  102262. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102263. * if vignetteEnabled is set to true.
  102264. */
  102265. /**
  102266. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102267. * if vignetteEnabled is set to true.
  102268. */
  102269. vignetteColor: Color4;
  102270. /**
  102271. * Gets Camera field of view used by the Vignette effect.
  102272. */
  102273. /**
  102274. * Sets Camera field of view used by the Vignette effect.
  102275. */
  102276. vignetteCameraFov: number;
  102277. /**
  102278. * Gets the vignette blend mode allowing different kind of effect.
  102279. */
  102280. /**
  102281. * Sets the vignette blend mode allowing different kind of effect.
  102282. */
  102283. vignetteBlendMode: number;
  102284. /**
  102285. * Gets wether the vignette effect is enabled.
  102286. */
  102287. /**
  102288. * Sets wether the vignette effect is enabled.
  102289. */
  102290. vignetteEnabled: boolean;
  102291. private _fromLinearSpace;
  102292. /**
  102293. * Gets wether the input of the processing is in Gamma or Linear Space.
  102294. */
  102295. /**
  102296. * Sets wether the input of the processing is in Gamma or Linear Space.
  102297. */
  102298. fromLinearSpace: boolean;
  102299. /**
  102300. * Defines cache preventing GC.
  102301. */
  102302. private _defines;
  102303. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102304. /**
  102305. * "ImageProcessingPostProcess"
  102306. * @returns "ImageProcessingPostProcess"
  102307. */
  102308. getClassName(): string;
  102309. protected _updateParameters(): void;
  102310. dispose(camera?: Camera): void;
  102311. }
  102312. }
  102313. declare module BABYLON {
  102314. /**
  102315. * Class containing static functions to help procedurally build meshes
  102316. */
  102317. export class GroundBuilder {
  102318. /**
  102319. * Creates a ground mesh
  102320. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102321. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102323. * @param name defines the name of the mesh
  102324. * @param options defines the options used to create the mesh
  102325. * @param scene defines the hosting scene
  102326. * @returns the ground mesh
  102327. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102328. */
  102329. static CreateGround(name: string, options: {
  102330. width?: number;
  102331. height?: number;
  102332. subdivisions?: number;
  102333. subdivisionsX?: number;
  102334. subdivisionsY?: number;
  102335. updatable?: boolean;
  102336. }, scene: any): Mesh;
  102337. /**
  102338. * Creates a tiled ground mesh
  102339. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102340. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102341. * * 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
  102342. * * 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
  102343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102344. * @param name defines the name of the mesh
  102345. * @param options defines the options used to create the mesh
  102346. * @param scene defines the hosting scene
  102347. * @returns the tiled ground mesh
  102348. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102349. */
  102350. static CreateTiledGround(name: string, options: {
  102351. xmin: number;
  102352. zmin: number;
  102353. xmax: number;
  102354. zmax: number;
  102355. subdivisions?: {
  102356. w: number;
  102357. h: number;
  102358. };
  102359. precision?: {
  102360. w: number;
  102361. h: number;
  102362. };
  102363. updatable?: boolean;
  102364. }, scene?: Nullable<Scene>): Mesh;
  102365. /**
  102366. * Creates a ground mesh from a height map
  102367. * * The parameter `url` sets the URL of the height map image resource.
  102368. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102369. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102370. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102371. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102372. * * 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.
  102373. * * 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).
  102374. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102376. * @param name defines the name of the mesh
  102377. * @param url defines the url to the height map
  102378. * @param options defines the options used to create the mesh
  102379. * @param scene defines the hosting scene
  102380. * @returns the ground mesh
  102381. * @see https://doc.babylonjs.com/babylon101/height_map
  102382. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102383. */
  102384. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102385. width?: number;
  102386. height?: number;
  102387. subdivisions?: number;
  102388. minHeight?: number;
  102389. maxHeight?: number;
  102390. colorFilter?: Color3;
  102391. alphaFilter?: number;
  102392. updatable?: boolean;
  102393. onReady?: (mesh: GroundMesh) => void;
  102394. }, scene?: Nullable<Scene>): GroundMesh;
  102395. }
  102396. }
  102397. declare module BABYLON {
  102398. /**
  102399. * Class containing static functions to help procedurally build meshes
  102400. */
  102401. export class TorusBuilder {
  102402. /**
  102403. * Creates a torus mesh
  102404. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102405. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102406. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102410. * @param name defines the name of the mesh
  102411. * @param options defines the options used to create the mesh
  102412. * @param scene defines the hosting scene
  102413. * @returns the torus mesh
  102414. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102415. */
  102416. static CreateTorus(name: string, options: {
  102417. diameter?: number;
  102418. thickness?: number;
  102419. tessellation?: number;
  102420. updatable?: boolean;
  102421. sideOrientation?: number;
  102422. frontUVs?: Vector4;
  102423. backUVs?: Vector4;
  102424. }, scene: any): Mesh;
  102425. }
  102426. }
  102427. declare module BABYLON {
  102428. /**
  102429. * Class containing static functions to help procedurally build meshes
  102430. */
  102431. export class CylinderBuilder {
  102432. /**
  102433. * Creates a cylinder or a cone mesh
  102434. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102435. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102436. * * 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.
  102437. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102438. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102439. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102440. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102441. * * 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).
  102442. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102443. * * 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).
  102444. * * 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
  102445. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102446. * * 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
  102447. * * 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.
  102448. * * If `enclose` is false, a ring surface is one element.
  102449. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102450. * * 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
  102451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102454. * @param name defines the name of the mesh
  102455. * @param options defines the options used to create the mesh
  102456. * @param scene defines the hosting scene
  102457. * @returns the cylinder mesh
  102458. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102459. */
  102460. static CreateCylinder(name: string, options: {
  102461. height?: number;
  102462. diameterTop?: number;
  102463. diameterBottom?: number;
  102464. diameter?: number;
  102465. tessellation?: number;
  102466. subdivisions?: number;
  102467. arc?: number;
  102468. faceColors?: Color4[];
  102469. faceUV?: Vector4[];
  102470. updatable?: boolean;
  102471. hasRings?: boolean;
  102472. enclose?: boolean;
  102473. cap?: number;
  102474. sideOrientation?: number;
  102475. frontUVs?: Vector4;
  102476. backUVs?: Vector4;
  102477. }, scene: any): Mesh;
  102478. }
  102479. }
  102480. declare module BABYLON {
  102481. /**
  102482. * Options to modify the vr teleportation behavior.
  102483. */
  102484. export interface VRTeleportationOptions {
  102485. /**
  102486. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102487. */
  102488. floorMeshName?: string;
  102489. /**
  102490. * A list of meshes to be used as the teleportation floor. (default: empty)
  102491. */
  102492. floorMeshes?: Mesh[];
  102493. }
  102494. /**
  102495. * Options to modify the vr experience helper's behavior.
  102496. */
  102497. export interface VRExperienceHelperOptions extends WebVROptions {
  102498. /**
  102499. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102500. */
  102501. createDeviceOrientationCamera?: boolean;
  102502. /**
  102503. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102504. */
  102505. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102506. /**
  102507. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102508. */
  102509. laserToggle?: boolean;
  102510. /**
  102511. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102512. */
  102513. floorMeshes?: Mesh[];
  102514. /**
  102515. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102516. */
  102517. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102518. }
  102519. /**
  102520. * Event containing information after VR has been entered
  102521. */
  102522. export class OnAfterEnteringVRObservableEvent {
  102523. /**
  102524. * If entering vr was successful
  102525. */
  102526. success: boolean;
  102527. }
  102528. /**
  102529. * Helps to quickly add VR support to an existing scene.
  102530. * See http://doc.babylonjs.com/how_to/webvr_helper
  102531. */
  102532. export class VRExperienceHelper {
  102533. /** Options to modify the vr experience helper's behavior. */
  102534. webVROptions: VRExperienceHelperOptions;
  102535. private _scene;
  102536. private _position;
  102537. private _btnVR;
  102538. private _btnVRDisplayed;
  102539. private _webVRsupported;
  102540. private _webVRready;
  102541. private _webVRrequesting;
  102542. private _webVRpresenting;
  102543. private _hasEnteredVR;
  102544. private _fullscreenVRpresenting;
  102545. private _canvas;
  102546. private _webVRCamera;
  102547. private _vrDeviceOrientationCamera;
  102548. private _deviceOrientationCamera;
  102549. private _existingCamera;
  102550. private _onKeyDown;
  102551. private _onVrDisplayPresentChange;
  102552. private _onVRDisplayChanged;
  102553. private _onVRRequestPresentStart;
  102554. private _onVRRequestPresentComplete;
  102555. /**
  102556. * Observable raised right before entering VR.
  102557. */
  102558. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102559. /**
  102560. * Observable raised when entering VR has completed.
  102561. */
  102562. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102563. /**
  102564. * Observable raised when exiting VR.
  102565. */
  102566. onExitingVRObservable: Observable<VRExperienceHelper>;
  102567. /**
  102568. * Observable raised when controller mesh is loaded.
  102569. */
  102570. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102571. /** Return this.onEnteringVRObservable
  102572. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102573. */
  102574. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102575. /** Return this.onExitingVRObservable
  102576. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102577. */
  102578. readonly onExitingVR: Observable<VRExperienceHelper>;
  102579. /** Return this.onControllerMeshLoadedObservable
  102580. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102581. */
  102582. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102583. private _rayLength;
  102584. private _useCustomVRButton;
  102585. private _teleportationRequested;
  102586. private _teleportActive;
  102587. private _floorMeshName;
  102588. private _floorMeshesCollection;
  102589. private _rotationAllowed;
  102590. private _teleportBackwardsVector;
  102591. private _teleportationTarget;
  102592. private _isDefaultTeleportationTarget;
  102593. private _postProcessMove;
  102594. private _teleportationFillColor;
  102595. private _teleportationBorderColor;
  102596. private _rotationAngle;
  102597. private _haloCenter;
  102598. private _cameraGazer;
  102599. private _padSensibilityUp;
  102600. private _padSensibilityDown;
  102601. private _leftController;
  102602. private _rightController;
  102603. /**
  102604. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102605. */
  102606. onNewMeshSelected: Observable<AbstractMesh>;
  102607. /**
  102608. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102609. */
  102610. onNewMeshPicked: Observable<PickingInfo>;
  102611. private _circleEase;
  102612. /**
  102613. * Observable raised before camera teleportation
  102614. */
  102615. onBeforeCameraTeleport: Observable<Vector3>;
  102616. /**
  102617. * Observable raised after camera teleportation
  102618. */
  102619. onAfterCameraTeleport: Observable<Vector3>;
  102620. /**
  102621. * Observable raised when current selected mesh gets unselected
  102622. */
  102623. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102624. private _raySelectionPredicate;
  102625. /**
  102626. * To be optionaly changed by user to define custom ray selection
  102627. */
  102628. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102629. /**
  102630. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102631. */
  102632. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102633. /**
  102634. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102635. */
  102636. teleportationEnabled: boolean;
  102637. private _defaultHeight;
  102638. private _teleportationInitialized;
  102639. private _interactionsEnabled;
  102640. private _interactionsRequested;
  102641. private _displayGaze;
  102642. private _displayLaserPointer;
  102643. /**
  102644. * The mesh used to display where the user is going to teleport.
  102645. */
  102646. /**
  102647. * Sets the mesh to be used to display where the user is going to teleport.
  102648. */
  102649. teleportationTarget: Mesh;
  102650. /**
  102651. * 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
  102652. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102653. * See http://doc.babylonjs.com/resources/baking_transformations
  102654. */
  102655. gazeTrackerMesh: Mesh;
  102656. /**
  102657. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102658. */
  102659. updateGazeTrackerScale: boolean;
  102660. /**
  102661. * If the gaze trackers color should be updated when selecting meshes
  102662. */
  102663. updateGazeTrackerColor: boolean;
  102664. /**
  102665. * The gaze tracking mesh corresponding to the left controller
  102666. */
  102667. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102668. /**
  102669. * The gaze tracking mesh corresponding to the right controller
  102670. */
  102671. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102672. /**
  102673. * If the ray of the gaze should be displayed.
  102674. */
  102675. /**
  102676. * Sets if the ray of the gaze should be displayed.
  102677. */
  102678. displayGaze: boolean;
  102679. /**
  102680. * If the ray of the LaserPointer should be displayed.
  102681. */
  102682. /**
  102683. * Sets if the ray of the LaserPointer should be displayed.
  102684. */
  102685. displayLaserPointer: boolean;
  102686. /**
  102687. * The deviceOrientationCamera used as the camera when not in VR.
  102688. */
  102689. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102690. /**
  102691. * Based on the current WebVR support, returns the current VR camera used.
  102692. */
  102693. readonly currentVRCamera: Nullable<Camera>;
  102694. /**
  102695. * The webVRCamera which is used when in VR.
  102696. */
  102697. readonly webVRCamera: WebVRFreeCamera;
  102698. /**
  102699. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102700. */
  102701. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102702. private readonly _teleportationRequestInitiated;
  102703. /**
  102704. * Defines wether or not Pointer lock should be requested when switching to
  102705. * full screen.
  102706. */
  102707. requestPointerLockOnFullScreen: boolean;
  102708. /**
  102709. * Instantiates a VRExperienceHelper.
  102710. * Helps to quickly add VR support to an existing scene.
  102711. * @param scene The scene the VRExperienceHelper belongs to.
  102712. * @param webVROptions Options to modify the vr experience helper's behavior.
  102713. */
  102714. constructor(scene: Scene,
  102715. /** Options to modify the vr experience helper's behavior. */
  102716. webVROptions?: VRExperienceHelperOptions);
  102717. private _onDefaultMeshLoaded;
  102718. private _onResize;
  102719. private _onFullscreenChange;
  102720. /**
  102721. * Gets a value indicating if we are currently in VR mode.
  102722. */
  102723. readonly isInVRMode: boolean;
  102724. private onVrDisplayPresentChange;
  102725. private onVRDisplayChanged;
  102726. private moveButtonToBottomRight;
  102727. private displayVRButton;
  102728. private updateButtonVisibility;
  102729. private _cachedAngularSensibility;
  102730. /**
  102731. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  102732. * Otherwise, will use the fullscreen API.
  102733. */
  102734. enterVR(): void;
  102735. /**
  102736. * Attempt to exit VR, or fullscreen.
  102737. */
  102738. exitVR(): void;
  102739. /**
  102740. * The position of the vr experience helper.
  102741. */
  102742. /**
  102743. * Sets the position of the vr experience helper.
  102744. */
  102745. position: Vector3;
  102746. /**
  102747. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  102748. */
  102749. enableInteractions(): void;
  102750. private readonly _noControllerIsActive;
  102751. private beforeRender;
  102752. private _isTeleportationFloor;
  102753. /**
  102754. * Adds a floor mesh to be used for teleportation.
  102755. * @param floorMesh the mesh to be used for teleportation.
  102756. */
  102757. addFloorMesh(floorMesh: Mesh): void;
  102758. /**
  102759. * Removes a floor mesh from being used for teleportation.
  102760. * @param floorMesh the mesh to be removed.
  102761. */
  102762. removeFloorMesh(floorMesh: Mesh): void;
  102763. /**
  102764. * Enables interactions and teleportation using the VR controllers and gaze.
  102765. * @param vrTeleportationOptions options to modify teleportation behavior.
  102766. */
  102767. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  102768. private _onNewGamepadConnected;
  102769. private _tryEnableInteractionOnController;
  102770. private _onNewGamepadDisconnected;
  102771. private _enableInteractionOnController;
  102772. private _checkTeleportWithRay;
  102773. private _checkRotate;
  102774. private _checkTeleportBackwards;
  102775. private _enableTeleportationOnController;
  102776. private _createTeleportationCircles;
  102777. private _displayTeleportationTarget;
  102778. private _hideTeleportationTarget;
  102779. private _rotateCamera;
  102780. private _moveTeleportationSelectorTo;
  102781. private _workingVector;
  102782. private _workingQuaternion;
  102783. private _workingMatrix;
  102784. /**
  102785. * Teleports the users feet to the desired location
  102786. * @param location The location where the user's feet should be placed
  102787. */
  102788. teleportCamera(location: Vector3): void;
  102789. private _convertNormalToDirectionOfRay;
  102790. private _castRayAndSelectObject;
  102791. private _notifySelectedMeshUnselected;
  102792. /**
  102793. * Sets the color of the laser ray from the vr controllers.
  102794. * @param color new color for the ray.
  102795. */
  102796. changeLaserColor(color: Color3): void;
  102797. /**
  102798. * Sets the color of the ray from the vr headsets gaze.
  102799. * @param color new color for the ray.
  102800. */
  102801. changeGazeColor(color: Color3): void;
  102802. /**
  102803. * Exits VR and disposes of the vr experience helper
  102804. */
  102805. dispose(): void;
  102806. /**
  102807. * Gets the name of the VRExperienceHelper class
  102808. * @returns "VRExperienceHelper"
  102809. */
  102810. getClassName(): string;
  102811. }
  102812. }
  102813. declare module BABYLON {
  102814. /**
  102815. * Manages an XRSession
  102816. * @see https://doc.babylonjs.com/how_to/webxr
  102817. */
  102818. export class WebXRSessionManager implements IDisposable {
  102819. private scene;
  102820. /**
  102821. * Fires every time a new xrFrame arrives which can be used to update the camera
  102822. */
  102823. onXRFrameObservable: Observable<any>;
  102824. /**
  102825. * Fires when the xr session is ended either by the device or manually done
  102826. */
  102827. onXRSessionEnded: Observable<any>;
  102828. /** @hidden */
  102829. _xrSession: XRSession;
  102830. /** @hidden */
  102831. _frameOfReference: XRFrameOfReference;
  102832. /** @hidden */
  102833. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  102834. /** @hidden */
  102835. _currentXRFrame: Nullable<XRFrame>;
  102836. private _xrNavigator;
  102837. private _xrDevice;
  102838. private _tmpMatrix;
  102839. /**
  102840. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  102841. * @param scene The scene which the session should be created for
  102842. */
  102843. constructor(scene: Scene);
  102844. /**
  102845. * Initializes the manager
  102846. * After initialization enterXR can be called to start an XR session
  102847. * @returns Promise which resolves after it is initialized
  102848. */
  102849. initializeAsync(): Promise<void>;
  102850. /**
  102851. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  102852. * @param sessionCreationOptions xr options to create the session with
  102853. * @param frameOfReferenceType option to configure how the xr pose is expressed
  102854. * @returns Promise which resolves after it enters XR
  102855. */
  102856. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  102857. /**
  102858. * Stops the xrSession and restores the renderloop
  102859. * @returns Promise which resolves after it exits XR
  102860. */
  102861. exitXRAsync(): Promise<void>;
  102862. /**
  102863. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102864. * @param ray ray to cast into the environment
  102865. * @returns Promise which resolves with a collision point in the environment if it exists
  102866. */
  102867. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102868. /**
  102869. * Checks if a session would be supported for the creation options specified
  102870. * @param options creation options to check if they are supported
  102871. * @returns true if supported
  102872. */
  102873. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102874. /**
  102875. * @hidden
  102876. * Converts the render layer of xrSession to a render target
  102877. * @param session session to create render target for
  102878. * @param scene scene the new render target should be created for
  102879. */
  102880. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  102881. /**
  102882. * Disposes of the session manager
  102883. */
  102884. dispose(): void;
  102885. }
  102886. }
  102887. declare module BABYLON {
  102888. /**
  102889. * WebXR Camera which holds the views for the xrSession
  102890. * @see https://doc.babylonjs.com/how_to/webxr
  102891. */
  102892. export class WebXRCamera extends FreeCamera {
  102893. private static _TmpMatrix;
  102894. /**
  102895. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  102896. * @param name the name of the camera
  102897. * @param scene the scene to add the camera to
  102898. */
  102899. constructor(name: string, scene: Scene);
  102900. private _updateNumberOfRigCameras;
  102901. /** @hidden */
  102902. _updateForDualEyeDebugging(pupilDistance?: number): void;
  102903. /**
  102904. * Updates the cameras position from the current pose information of the XR session
  102905. * @param xrSessionManager the session containing pose information
  102906. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  102907. */
  102908. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  102909. }
  102910. }
  102911. declare module BABYLON {
  102912. /**
  102913. * States of the webXR experience
  102914. */
  102915. export enum WebXRState {
  102916. /**
  102917. * Transitioning to being in XR mode
  102918. */
  102919. ENTERING_XR = 0,
  102920. /**
  102921. * Transitioning to non XR mode
  102922. */
  102923. EXITING_XR = 1,
  102924. /**
  102925. * In XR mode and presenting
  102926. */
  102927. IN_XR = 2,
  102928. /**
  102929. * Not entered XR mode
  102930. */
  102931. NOT_IN_XR = 3
  102932. }
  102933. /**
  102934. * Helper class used to enable XR
  102935. * @see https://doc.babylonjs.com/how_to/webxr
  102936. */
  102937. export class WebXRExperienceHelper implements IDisposable {
  102938. private scene;
  102939. /**
  102940. * 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
  102941. */
  102942. container: AbstractMesh;
  102943. /**
  102944. * Camera used to render xr content
  102945. */
  102946. camera: WebXRCamera;
  102947. /**
  102948. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  102949. */
  102950. state: WebXRState;
  102951. private _setState;
  102952. private static _TmpVector;
  102953. /**
  102954. * Fires when the state of the experience helper has changed
  102955. */
  102956. onStateChangedObservable: Observable<WebXRState>;
  102957. /** @hidden */
  102958. _sessionManager: WebXRSessionManager;
  102959. private _nonVRCamera;
  102960. private _originalSceneAutoClear;
  102961. private _supported;
  102962. /**
  102963. * Creates the experience helper
  102964. * @param scene the scene to attach the experience helper to
  102965. * @returns a promise for the experience helper
  102966. */
  102967. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  102968. /**
  102969. * Creates a WebXRExperienceHelper
  102970. * @param scene The scene the helper should be created in
  102971. */
  102972. private constructor();
  102973. /**
  102974. * Exits XR mode and returns the scene to its original state
  102975. * @returns promise that resolves after xr mode has exited
  102976. */
  102977. exitXRAsync(): Promise<void>;
  102978. /**
  102979. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  102980. * @param sessionCreationOptions options for the XR session
  102981. * @param frameOfReference frame of reference of the XR session
  102982. * @returns promise that resolves after xr mode has entered
  102983. */
  102984. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  102985. /**
  102986. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102987. * @param ray ray to cast into the environment
  102988. * @returns Promise which resolves with a collision point in the environment if it exists
  102989. */
  102990. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102991. /**
  102992. * Updates the global position of the camera by moving the camera's container
  102993. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  102994. * @param position The desired global position of the camera
  102995. */
  102996. setPositionOfCameraUsingContainer(position: Vector3): void;
  102997. /**
  102998. * Rotates the xr camera by rotating the camera's container around the camera's position
  102999. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103000. * @param rotation the desired quaternion rotation to apply to the camera
  103001. */
  103002. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103003. /**
  103004. * Checks if the creation options are supported by the xr session
  103005. * @param options creation options
  103006. * @returns true if supported
  103007. */
  103008. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103009. /**
  103010. * Disposes of the experience helper
  103011. */
  103012. dispose(): void;
  103013. }
  103014. }
  103015. declare module BABYLON {
  103016. /**
  103017. * Button which can be used to enter a different mode of XR
  103018. */
  103019. export class WebXREnterExitUIButton {
  103020. /** button element */
  103021. element: HTMLElement;
  103022. /** XR initialization options for the button */
  103023. initializationOptions: XRSessionCreationOptions;
  103024. /**
  103025. * Creates a WebXREnterExitUIButton
  103026. * @param element button element
  103027. * @param initializationOptions XR initialization options for the button
  103028. */
  103029. constructor(
  103030. /** button element */
  103031. element: HTMLElement,
  103032. /** XR initialization options for the button */
  103033. initializationOptions: XRSessionCreationOptions);
  103034. /**
  103035. * Overwritable function which can be used to update the button's visuals when the state changes
  103036. * @param activeButton the current active button in the UI
  103037. */
  103038. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103039. }
  103040. /**
  103041. * Options to create the webXR UI
  103042. */
  103043. export class WebXREnterExitUIOptions {
  103044. /**
  103045. * Context to enter xr with
  103046. */
  103047. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  103048. /**
  103049. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103050. */
  103051. customButtons?: Array<WebXREnterExitUIButton>;
  103052. }
  103053. /**
  103054. * UI to allow the user to enter/exit XR mode
  103055. */
  103056. export class WebXREnterExitUI implements IDisposable {
  103057. private scene;
  103058. private _overlay;
  103059. private _buttons;
  103060. private _activeButton;
  103061. /**
  103062. * Fired every time the active button is changed.
  103063. *
  103064. * When xr is entered via a button that launches xr that button will be the callback parameter
  103065. *
  103066. * When exiting xr the callback parameter will be null)
  103067. */
  103068. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103069. /**
  103070. * Creates UI to allow the user to enter/exit XR mode
  103071. * @param scene the scene to add the ui to
  103072. * @param helper the xr experience helper to enter/exit xr with
  103073. * @param options options to configure the UI
  103074. * @returns the created ui
  103075. */
  103076. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103077. private constructor();
  103078. private _updateButtons;
  103079. /**
  103080. * Disposes of the object
  103081. */
  103082. dispose(): void;
  103083. }
  103084. }
  103085. declare module BABYLON {
  103086. /**
  103087. * Represents an XR input
  103088. */
  103089. export class WebXRController {
  103090. /**
  103091. * 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
  103092. */
  103093. grip?: AbstractMesh;
  103094. /**
  103095. * Pointer which can be used to select objects or attach a visible laser to
  103096. */
  103097. pointer: AbstractMesh;
  103098. /**
  103099. * Creates the controller
  103100. * @see https://doc.babylonjs.com/how_to/webxr
  103101. * @param scene the scene which the controller should be associated to
  103102. */
  103103. constructor(scene: Scene);
  103104. /**
  103105. * Disposes of the object
  103106. */
  103107. dispose(): void;
  103108. }
  103109. /**
  103110. * XR input used to track XR inputs such as controllers/rays
  103111. */
  103112. export class WebXRInput implements IDisposable {
  103113. private helper;
  103114. /**
  103115. * XR controllers being tracked
  103116. */
  103117. controllers: Array<WebXRController>;
  103118. private _tmpMatrix;
  103119. private _frameObserver;
  103120. /**
  103121. * Initializes the WebXRInput
  103122. * @param helper experience helper which the input should be created for
  103123. */
  103124. constructor(helper: WebXRExperienceHelper);
  103125. /**
  103126. * Disposes of the object
  103127. */
  103128. dispose(): void;
  103129. }
  103130. }
  103131. declare module BABYLON {
  103132. /**
  103133. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103134. */
  103135. export class WebXRManagedOutputCanvas implements IDisposable {
  103136. private _canvas;
  103137. /**
  103138. * xrpresent context of the canvas which can be used to display/mirror xr content
  103139. */
  103140. canvasContext: Nullable<WebGLRenderingContext>;
  103141. /**
  103142. * Initializes the canvas to be added/removed upon entering/exiting xr
  103143. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103144. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103145. */
  103146. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103147. /**
  103148. * Disposes of the object
  103149. */
  103150. dispose(): void;
  103151. private _setManagedOutputCanvas;
  103152. private _addCanvas;
  103153. private _removeCanvas;
  103154. }
  103155. }
  103156. declare module BABYLON {
  103157. /**
  103158. * Contains an array of blocks representing the octree
  103159. */
  103160. export interface IOctreeContainer<T> {
  103161. /**
  103162. * Blocks within the octree
  103163. */
  103164. blocks: Array<OctreeBlock<T>>;
  103165. }
  103166. /**
  103167. * Class used to store a cell in an octree
  103168. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103169. */
  103170. export class OctreeBlock<T> {
  103171. /**
  103172. * Gets the content of the current block
  103173. */
  103174. entries: T[];
  103175. /**
  103176. * Gets the list of block children
  103177. */
  103178. blocks: Array<OctreeBlock<T>>;
  103179. private _depth;
  103180. private _maxDepth;
  103181. private _capacity;
  103182. private _minPoint;
  103183. private _maxPoint;
  103184. private _boundingVectors;
  103185. private _creationFunc;
  103186. /**
  103187. * Creates a new block
  103188. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103189. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103190. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103191. * @param depth defines the current depth of this block in the octree
  103192. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103193. * @param creationFunc defines a callback to call when an element is added to the block
  103194. */
  103195. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103196. /**
  103197. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103198. */
  103199. readonly capacity: number;
  103200. /**
  103201. * Gets the minimum vector (in world space) of the block's bounding box
  103202. */
  103203. readonly minPoint: Vector3;
  103204. /**
  103205. * Gets the maximum vector (in world space) of the block's bounding box
  103206. */
  103207. readonly maxPoint: Vector3;
  103208. /**
  103209. * Add a new element to this block
  103210. * @param entry defines the element to add
  103211. */
  103212. addEntry(entry: T): void;
  103213. /**
  103214. * Remove an element from this block
  103215. * @param entry defines the element to remove
  103216. */
  103217. removeEntry(entry: T): void;
  103218. /**
  103219. * Add an array of elements to this block
  103220. * @param entries defines the array of elements to add
  103221. */
  103222. addEntries(entries: T[]): void;
  103223. /**
  103224. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103225. * @param frustumPlanes defines the frustum planes to test
  103226. * @param selection defines the array to store current content if selection is positive
  103227. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103228. */
  103229. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103230. /**
  103231. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103232. * @param sphereCenter defines the bounding sphere center
  103233. * @param sphereRadius defines the bounding sphere radius
  103234. * @param selection defines the array to store current content if selection is positive
  103235. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103236. */
  103237. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103238. /**
  103239. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103240. * @param ray defines the ray to test with
  103241. * @param selection defines the array to store current content if selection is positive
  103242. */
  103243. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103244. /**
  103245. * Subdivide the content into child blocks (this block will then be empty)
  103246. */
  103247. createInnerBlocks(): void;
  103248. /**
  103249. * @hidden
  103250. */
  103251. 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;
  103252. }
  103253. }
  103254. declare module BABYLON {
  103255. /**
  103256. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103257. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103258. */
  103259. export class Octree<T> {
  103260. /** 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.) */
  103261. maxDepth: number;
  103262. /**
  103263. * Blocks within the octree containing objects
  103264. */
  103265. blocks: Array<OctreeBlock<T>>;
  103266. /**
  103267. * Content stored in the octree
  103268. */
  103269. dynamicContent: T[];
  103270. private _maxBlockCapacity;
  103271. private _selectionContent;
  103272. private _creationFunc;
  103273. /**
  103274. * Creates a octree
  103275. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103276. * @param creationFunc function to be used to instatiate the octree
  103277. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103278. * @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.)
  103279. */
  103280. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103281. /** 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.) */
  103282. maxDepth?: number);
  103283. /**
  103284. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103285. * @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);
  103286. * @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);
  103287. * @param entries meshes to be added to the octree blocks
  103288. */
  103289. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103290. /**
  103291. * Adds a mesh to the octree
  103292. * @param entry Mesh to add to the octree
  103293. */
  103294. addMesh(entry: T): void;
  103295. /**
  103296. * Remove an element from the octree
  103297. * @param entry defines the element to remove
  103298. */
  103299. removeMesh(entry: T): void;
  103300. /**
  103301. * Selects an array of meshes within the frustum
  103302. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103303. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103304. * @returns array of meshes within the frustum
  103305. */
  103306. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103307. /**
  103308. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103309. * @param sphereCenter defines the bounding sphere center
  103310. * @param sphereRadius defines the bounding sphere radius
  103311. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103312. * @returns an array of objects that intersect the sphere
  103313. */
  103314. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103315. /**
  103316. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103317. * @param ray defines the ray to test with
  103318. * @returns array of intersected objects
  103319. */
  103320. intersectsRay(ray: Ray): SmartArray<T>;
  103321. /**
  103322. * Adds a mesh into the octree block if it intersects the block
  103323. */
  103324. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103325. /**
  103326. * Adds a submesh into the octree block if it intersects the block
  103327. */
  103328. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103329. }
  103330. }
  103331. declare module BABYLON {
  103332. interface Scene {
  103333. /**
  103334. * @hidden
  103335. * Backing Filed
  103336. */
  103337. _selectionOctree: Octree<AbstractMesh>;
  103338. /**
  103339. * Gets the octree used to boost mesh selection (picking)
  103340. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103341. */
  103342. selectionOctree: Octree<AbstractMesh>;
  103343. /**
  103344. * Creates or updates the octree used to boost selection (picking)
  103345. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103346. * @param maxCapacity defines the maximum capacity per leaf
  103347. * @param maxDepth defines the maximum depth of the octree
  103348. * @returns an octree of AbstractMesh
  103349. */
  103350. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103351. }
  103352. interface AbstractMesh {
  103353. /**
  103354. * @hidden
  103355. * Backing Field
  103356. */
  103357. _submeshesOctree: Octree<SubMesh>;
  103358. /**
  103359. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103360. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103361. * @param maxCapacity defines the maximum size of each block (64 by default)
  103362. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103363. * @returns the new octree
  103364. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103366. */
  103367. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103368. }
  103369. /**
  103370. * Defines the octree scene component responsible to manage any octrees
  103371. * in a given scene.
  103372. */
  103373. export class OctreeSceneComponent {
  103374. /**
  103375. * The component name help to identify the component in the list of scene components.
  103376. */
  103377. readonly name: string;
  103378. /**
  103379. * The scene the component belongs to.
  103380. */
  103381. scene: Scene;
  103382. /**
  103383. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103384. */
  103385. readonly checksIsEnabled: boolean;
  103386. /**
  103387. * Creates a new instance of the component for the given scene
  103388. * @param scene Defines the scene to register the component in
  103389. */
  103390. constructor(scene: Scene);
  103391. /**
  103392. * Registers the component in a given scene
  103393. */
  103394. register(): void;
  103395. /**
  103396. * Return the list of active meshes
  103397. * @returns the list of active meshes
  103398. */
  103399. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103400. /**
  103401. * Return the list of active sub meshes
  103402. * @param mesh The mesh to get the candidates sub meshes from
  103403. * @returns the list of active sub meshes
  103404. */
  103405. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103406. private _tempRay;
  103407. /**
  103408. * Return the list of sub meshes intersecting with a given local ray
  103409. * @param mesh defines the mesh to find the submesh for
  103410. * @param localRay defines the ray in local space
  103411. * @returns the list of intersecting sub meshes
  103412. */
  103413. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103414. /**
  103415. * Return the list of sub meshes colliding with a collider
  103416. * @param mesh defines the mesh to find the submesh for
  103417. * @param collider defines the collider to evaluate the collision against
  103418. * @returns the list of colliding sub meshes
  103419. */
  103420. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103421. /**
  103422. * Rebuilds the elements related to this component in case of
  103423. * context lost for instance.
  103424. */
  103425. rebuild(): void;
  103426. /**
  103427. * Disposes the component and the associated ressources.
  103428. */
  103429. dispose(): void;
  103430. }
  103431. }
  103432. declare module BABYLON {
  103433. /**
  103434. * Renders a layer on top of an existing scene
  103435. */
  103436. export class UtilityLayerRenderer implements IDisposable {
  103437. /** the original scene that will be rendered on top of */
  103438. originalScene: Scene;
  103439. private _pointerCaptures;
  103440. private _lastPointerEvents;
  103441. private static _DefaultUtilityLayer;
  103442. private static _DefaultKeepDepthUtilityLayer;
  103443. private _sharedGizmoLight;
  103444. private _renderCamera;
  103445. /**
  103446. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103447. * @returns the camera that is used when rendering the utility layer
  103448. */
  103449. getRenderCamera(): Nullable<Camera>;
  103450. /**
  103451. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  103452. * @param cam the camera that should be used when rendering the utility layer
  103453. */
  103454. setRenderCamera(cam: Nullable<Camera>): void;
  103455. /**
  103456. * @hidden
  103457. * Light which used by gizmos to get light shading
  103458. */
  103459. _getSharedGizmoLight(): HemisphericLight;
  103460. /**
  103461. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103462. */
  103463. pickUtilitySceneFirst: boolean;
  103464. /**
  103465. * 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)
  103466. */
  103467. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103468. /**
  103469. * 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)
  103470. */
  103471. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103472. /**
  103473. * The scene that is rendered on top of the original scene
  103474. */
  103475. utilityLayerScene: Scene;
  103476. /**
  103477. * If the utility layer should automatically be rendered on top of existing scene
  103478. */
  103479. shouldRender: boolean;
  103480. /**
  103481. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103482. */
  103483. onlyCheckPointerDownEvents: boolean;
  103484. /**
  103485. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103486. */
  103487. processAllEvents: boolean;
  103488. /**
  103489. * Observable raised when the pointer move from the utility layer scene to the main scene
  103490. */
  103491. onPointerOutObservable: Observable<number>;
  103492. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103493. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103494. private _afterRenderObserver;
  103495. private _sceneDisposeObserver;
  103496. private _originalPointerObserver;
  103497. /**
  103498. * Instantiates a UtilityLayerRenderer
  103499. * @param originalScene the original scene that will be rendered on top of
  103500. * @param handleEvents boolean indicating if the utility layer should handle events
  103501. */
  103502. constructor(
  103503. /** the original scene that will be rendered on top of */
  103504. originalScene: Scene, handleEvents?: boolean);
  103505. private _notifyObservers;
  103506. /**
  103507. * Renders the utility layers scene on top of the original scene
  103508. */
  103509. render(): void;
  103510. /**
  103511. * Disposes of the renderer
  103512. */
  103513. dispose(): void;
  103514. private _updateCamera;
  103515. }
  103516. }
  103517. declare module BABYLON {
  103518. /**
  103519. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103520. */
  103521. export class Gizmo implements IDisposable {
  103522. /** The utility layer the gizmo will be added to */
  103523. gizmoLayer: UtilityLayerRenderer;
  103524. /**
  103525. * The root mesh of the gizmo
  103526. */
  103527. _rootMesh: Mesh;
  103528. private _attachedMesh;
  103529. /**
  103530. * Ratio for the scale of the gizmo (Default: 1)
  103531. */
  103532. scaleRatio: number;
  103533. /**
  103534. * If a custom mesh has been set (Default: false)
  103535. */
  103536. protected _customMeshSet: boolean;
  103537. /**
  103538. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103539. * * When set, interactions will be enabled
  103540. */
  103541. attachedMesh: Nullable<AbstractMesh>;
  103542. /**
  103543. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103544. * @param mesh The mesh to replace the default mesh of the gizmo
  103545. */
  103546. setCustomMesh(mesh: Mesh): void;
  103547. /**
  103548. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103549. */
  103550. updateGizmoRotationToMatchAttachedMesh: boolean;
  103551. /**
  103552. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103553. */
  103554. updateGizmoPositionToMatchAttachedMesh: boolean;
  103555. /**
  103556. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103557. */
  103558. protected _updateScale: boolean;
  103559. protected _interactionsEnabled: boolean;
  103560. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103561. private _beforeRenderObserver;
  103562. private _tempVector;
  103563. /**
  103564. * Creates a gizmo
  103565. * @param gizmoLayer The utility layer the gizmo will be added to
  103566. */
  103567. constructor(
  103568. /** The utility layer the gizmo will be added to */
  103569. gizmoLayer?: UtilityLayerRenderer);
  103570. /**
  103571. * Updates the gizmo to match the attached mesh's position/rotation
  103572. */
  103573. protected _update(): void;
  103574. /**
  103575. * Disposes of the gizmo
  103576. */
  103577. dispose(): void;
  103578. }
  103579. }
  103580. declare module BABYLON {
  103581. /**
  103582. * Single plane drag gizmo
  103583. */
  103584. export class PlaneDragGizmo extends Gizmo {
  103585. /**
  103586. * Drag behavior responsible for the gizmos dragging interactions
  103587. */
  103588. dragBehavior: PointerDragBehavior;
  103589. private _pointerObserver;
  103590. /**
  103591. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103592. */
  103593. snapDistance: number;
  103594. /**
  103595. * Event that fires each time the gizmo snaps to a new location.
  103596. * * snapDistance is the the change in distance
  103597. */
  103598. onSnapObservable: Observable<{
  103599. snapDistance: number;
  103600. }>;
  103601. private _plane;
  103602. private _coloredMaterial;
  103603. private _hoverMaterial;
  103604. private _isEnabled;
  103605. private _parent;
  103606. /** @hidden */
  103607. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103608. /** @hidden */
  103609. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103610. /**
  103611. * Creates a PlaneDragGizmo
  103612. * @param gizmoLayer The utility layer the gizmo will be added to
  103613. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  103614. * @param color The color of the gizmo
  103615. */
  103616. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103617. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103618. /**
  103619. * If the gizmo is enabled
  103620. */
  103621. isEnabled: boolean;
  103622. /**
  103623. * Disposes of the gizmo
  103624. */
  103625. dispose(): void;
  103626. }
  103627. }
  103628. declare module BABYLON {
  103629. /**
  103630. * Gizmo that enables dragging a mesh along 3 axis
  103631. */
  103632. export class PositionGizmo extends Gizmo {
  103633. /**
  103634. * Internal gizmo used for interactions on the x axis
  103635. */
  103636. xGizmo: AxisDragGizmo;
  103637. /**
  103638. * Internal gizmo used for interactions on the y axis
  103639. */
  103640. yGizmo: AxisDragGizmo;
  103641. /**
  103642. * Internal gizmo used for interactions on the z axis
  103643. */
  103644. zGizmo: AxisDragGizmo;
  103645. /**
  103646. * Internal gizmo used for interactions on the yz plane
  103647. */
  103648. xPlaneGizmo: PlaneDragGizmo;
  103649. /**
  103650. * Internal gizmo used for interactions on the xz plane
  103651. */
  103652. yPlaneGizmo: PlaneDragGizmo;
  103653. /**
  103654. * Internal gizmo used for interactions on the xy plane
  103655. */
  103656. zPlaneGizmo: PlaneDragGizmo;
  103657. /**
  103658. * private variables
  103659. */
  103660. private _meshAttached;
  103661. private _updateGizmoRotationToMatchAttachedMesh;
  103662. private _snapDistance;
  103663. private _scaleRatio;
  103664. /** Fires an event when any of it's sub gizmos are dragged */
  103665. onDragStartObservable: Observable<{}>;
  103666. /** Fires an event when any of it's sub gizmos are released from dragging */
  103667. onDragEndObservable: Observable<{}>;
  103668. /**
  103669. * If set to true, planar drag is enabled
  103670. */
  103671. private _planarGizmoEnabled;
  103672. attachedMesh: Nullable<AbstractMesh>;
  103673. /**
  103674. * Creates a PositionGizmo
  103675. * @param gizmoLayer The utility layer the gizmo will be added to
  103676. */
  103677. constructor(gizmoLayer?: UtilityLayerRenderer);
  103678. /**
  103679. * If the planar drag gizmo is enabled
  103680. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  103681. */
  103682. planarGizmoEnabled: boolean;
  103683. updateGizmoRotationToMatchAttachedMesh: boolean;
  103684. /**
  103685. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103686. */
  103687. snapDistance: number;
  103688. /**
  103689. * Ratio for the scale of the gizmo (Default: 1)
  103690. */
  103691. scaleRatio: number;
  103692. /**
  103693. * Disposes of the gizmo
  103694. */
  103695. dispose(): void;
  103696. /**
  103697. * CustomMeshes are not supported by this gizmo
  103698. * @param mesh The mesh to replace the default mesh of the gizmo
  103699. */
  103700. setCustomMesh(mesh: Mesh): void;
  103701. }
  103702. }
  103703. declare module BABYLON {
  103704. /**
  103705. * Single axis drag gizmo
  103706. */
  103707. export class AxisDragGizmo extends Gizmo {
  103708. /**
  103709. * Drag behavior responsible for the gizmos dragging interactions
  103710. */
  103711. dragBehavior: PointerDragBehavior;
  103712. private _pointerObserver;
  103713. /**
  103714. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103715. */
  103716. snapDistance: number;
  103717. /**
  103718. * Event that fires each time the gizmo snaps to a new location.
  103719. * * snapDistance is the the change in distance
  103720. */
  103721. onSnapObservable: Observable<{
  103722. snapDistance: number;
  103723. }>;
  103724. private _isEnabled;
  103725. private _parent;
  103726. private _arrow;
  103727. private _coloredMaterial;
  103728. private _hoverMaterial;
  103729. /** @hidden */
  103730. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  103731. /** @hidden */
  103732. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103733. /**
  103734. * Creates an AxisDragGizmo
  103735. * @param gizmoLayer The utility layer the gizmo will be added to
  103736. * @param dragAxis The axis which the gizmo will be able to drag on
  103737. * @param color The color of the gizmo
  103738. */
  103739. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103740. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103741. /**
  103742. * If the gizmo is enabled
  103743. */
  103744. isEnabled: boolean;
  103745. /**
  103746. * Disposes of the gizmo
  103747. */
  103748. dispose(): void;
  103749. }
  103750. }
  103751. declare module BABYLON.Debug {
  103752. /**
  103753. * The Axes viewer will show 3 axes in a specific point in space
  103754. */
  103755. export class AxesViewer {
  103756. private _xAxis;
  103757. private _yAxis;
  103758. private _zAxis;
  103759. private _scaleLinesFactor;
  103760. private _instanced;
  103761. /**
  103762. * Gets the hosting scene
  103763. */
  103764. scene: Scene;
  103765. /**
  103766. * Gets or sets a number used to scale line length
  103767. */
  103768. scaleLines: number;
  103769. /** Gets the node hierarchy used to render x-axis */
  103770. readonly xAxis: TransformNode;
  103771. /** Gets the node hierarchy used to render y-axis */
  103772. readonly yAxis: TransformNode;
  103773. /** Gets the node hierarchy used to render z-axis */
  103774. readonly zAxis: TransformNode;
  103775. /**
  103776. * Creates a new AxesViewer
  103777. * @param scene defines the hosting scene
  103778. * @param scaleLines defines a number used to scale line length (1 by default)
  103779. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  103780. * @param xAxis defines the node hierarchy used to render the x-axis
  103781. * @param yAxis defines the node hierarchy used to render the y-axis
  103782. * @param zAxis defines the node hierarchy used to render the z-axis
  103783. */
  103784. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  103785. /**
  103786. * Force the viewer to update
  103787. * @param position defines the position of the viewer
  103788. * @param xaxis defines the x axis of the viewer
  103789. * @param yaxis defines the y axis of the viewer
  103790. * @param zaxis defines the z axis of the viewer
  103791. */
  103792. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  103793. /**
  103794. * Creates an instance of this axes viewer.
  103795. * @returns a new axes viewer with instanced meshes
  103796. */
  103797. createInstance(): AxesViewer;
  103798. /** Releases resources */
  103799. dispose(): void;
  103800. private static _SetRenderingGroupId;
  103801. }
  103802. }
  103803. declare module BABYLON.Debug {
  103804. /**
  103805. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  103806. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  103807. */
  103808. export class BoneAxesViewer extends AxesViewer {
  103809. /**
  103810. * Gets or sets the target mesh where to display the axes viewer
  103811. */
  103812. mesh: Nullable<Mesh>;
  103813. /**
  103814. * Gets or sets the target bone where to display the axes viewer
  103815. */
  103816. bone: Nullable<Bone>;
  103817. /** Gets current position */
  103818. pos: Vector3;
  103819. /** Gets direction of X axis */
  103820. xaxis: Vector3;
  103821. /** Gets direction of Y axis */
  103822. yaxis: Vector3;
  103823. /** Gets direction of Z axis */
  103824. zaxis: Vector3;
  103825. /**
  103826. * Creates a new BoneAxesViewer
  103827. * @param scene defines the hosting scene
  103828. * @param bone defines the target bone
  103829. * @param mesh defines the target mesh
  103830. * @param scaleLines defines a scaling factor for line length (1 by default)
  103831. */
  103832. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  103833. /**
  103834. * Force the viewer to update
  103835. */
  103836. update(): void;
  103837. /** Releases resources */
  103838. dispose(): void;
  103839. }
  103840. }
  103841. declare module BABYLON {
  103842. /**
  103843. * Interface used to define scene explorer extensibility option
  103844. */
  103845. export interface IExplorerExtensibilityOption {
  103846. /**
  103847. * Define the option label
  103848. */
  103849. label: string;
  103850. /**
  103851. * Defines the action to execute on click
  103852. */
  103853. action: (entity: any) => void;
  103854. }
  103855. /**
  103856. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  103857. */
  103858. export interface IExplorerExtensibilityGroup {
  103859. /**
  103860. * Defines a predicate to test if a given type mut be extended
  103861. */
  103862. predicate: (entity: any) => boolean;
  103863. /**
  103864. * Gets the list of options added to a type
  103865. */
  103866. entries: IExplorerExtensibilityOption[];
  103867. }
  103868. /**
  103869. * Interface used to define the options to use to create the Inspector
  103870. */
  103871. export interface IInspectorOptions {
  103872. /**
  103873. * Display in overlay mode (default: false)
  103874. */
  103875. overlay?: boolean;
  103876. /**
  103877. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  103878. */
  103879. globalRoot?: HTMLElement;
  103880. /**
  103881. * Display the Scene explorer
  103882. */
  103883. showExplorer?: boolean;
  103884. /**
  103885. * Display the property inspector
  103886. */
  103887. showInspector?: boolean;
  103888. /**
  103889. * Display in embed mode (both panes on the right)
  103890. */
  103891. embedMode?: boolean;
  103892. /**
  103893. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  103894. */
  103895. handleResize?: boolean;
  103896. /**
  103897. * Allow the panes to popup (default: true)
  103898. */
  103899. enablePopup?: boolean;
  103900. /**
  103901. * Allow the panes to be closed by users (default: true)
  103902. */
  103903. enableClose?: boolean;
  103904. /**
  103905. * Optional list of extensibility entries
  103906. */
  103907. explorerExtensibility?: IExplorerExtensibilityGroup[];
  103908. /**
  103909. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  103910. */
  103911. inspectorURL?: string;
  103912. }
  103913. interface Scene {
  103914. /**
  103915. * @hidden
  103916. * Backing field
  103917. */
  103918. _debugLayer: DebugLayer;
  103919. /**
  103920. * Gets the debug layer (aka Inspector) associated with the scene
  103921. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103922. */
  103923. debugLayer: DebugLayer;
  103924. }
  103925. /**
  103926. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103927. * what is happening in your scene
  103928. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103929. */
  103930. export class DebugLayer {
  103931. /**
  103932. * Define the url to get the inspector script from.
  103933. * By default it uses the babylonjs CDN.
  103934. * @ignoreNaming
  103935. */
  103936. static InspectorURL: string;
  103937. private _scene;
  103938. private BJSINSPECTOR;
  103939. /**
  103940. * Observable triggered when a property is changed through the inspector.
  103941. */
  103942. onPropertyChangedObservable: Observable<{
  103943. object: any;
  103944. property: string;
  103945. value: any;
  103946. initialValue: any;
  103947. }>;
  103948. /**
  103949. * Instantiates a new debug layer.
  103950. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103951. * what is happening in your scene
  103952. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103953. * @param scene Defines the scene to inspect
  103954. */
  103955. constructor(scene: Scene);
  103956. /** Creates the inspector window. */
  103957. private _createInspector;
  103958. /**
  103959. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  103960. * @param entity defines the entity to select
  103961. * @param lineContainerTitle defines the specific block to highlight
  103962. */
  103963. select(entity: any, lineContainerTitle?: string): void;
  103964. /** Get the inspector from bundle or global */
  103965. private _getGlobalInspector;
  103966. /**
  103967. * Get if the inspector is visible or not.
  103968. * @returns true if visible otherwise, false
  103969. */
  103970. isVisible(): boolean;
  103971. /**
  103972. * Hide the inspector and close its window.
  103973. */
  103974. hide(): void;
  103975. /**
  103976. * Launch the debugLayer.
  103977. * @param config Define the configuration of the inspector
  103978. * @return a promise fulfilled when the debug layer is visible
  103979. */
  103980. show(config?: IInspectorOptions): Promise<DebugLayer>;
  103981. }
  103982. }
  103983. declare module BABYLON {
  103984. /**
  103985. * Class containing static functions to help procedurally build meshes
  103986. */
  103987. export class BoxBuilder {
  103988. /**
  103989. * Creates a box mesh
  103990. * * The parameter `size` sets the size (float) of each box side (default 1)
  103991. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103992. * * 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)
  103993. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103997. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103998. * @param name defines the name of the mesh
  103999. * @param options defines the options used to create the mesh
  104000. * @param scene defines the hosting scene
  104001. * @returns the box mesh
  104002. */
  104003. static CreateBox(name: string, options: {
  104004. size?: number;
  104005. width?: number;
  104006. height?: number;
  104007. depth?: number;
  104008. faceUV?: Vector4[];
  104009. faceColors?: Color4[];
  104010. sideOrientation?: number;
  104011. frontUVs?: Vector4;
  104012. backUVs?: Vector4;
  104013. wrap?: boolean;
  104014. topBaseAt?: number;
  104015. bottomBaseAt?: number;
  104016. updatable?: boolean;
  104017. }, scene?: Nullable<Scene>): Mesh;
  104018. }
  104019. }
  104020. declare module BABYLON {
  104021. /**
  104022. * Class containing static functions to help procedurally build meshes
  104023. */
  104024. export class SphereBuilder {
  104025. /**
  104026. * Creates a sphere mesh
  104027. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104028. * * 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`)
  104029. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104030. * * 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
  104031. * * 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)
  104032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104035. * @param name defines the name of the mesh
  104036. * @param options defines the options used to create the mesh
  104037. * @param scene defines the hosting scene
  104038. * @returns the sphere mesh
  104039. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104040. */
  104041. static CreateSphere(name: string, options: {
  104042. segments?: number;
  104043. diameter?: number;
  104044. diameterX?: number;
  104045. diameterY?: number;
  104046. diameterZ?: number;
  104047. arc?: number;
  104048. slice?: number;
  104049. sideOrientation?: number;
  104050. frontUVs?: Vector4;
  104051. backUVs?: Vector4;
  104052. updatable?: boolean;
  104053. }, scene: any): Mesh;
  104054. }
  104055. }
  104056. declare module BABYLON.Debug {
  104057. /**
  104058. * Used to show the physics impostor around the specific mesh
  104059. */
  104060. export class PhysicsViewer {
  104061. /** @hidden */
  104062. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104063. /** @hidden */
  104064. protected _meshes: Array<Nullable<AbstractMesh>>;
  104065. /** @hidden */
  104066. protected _scene: Nullable<Scene>;
  104067. /** @hidden */
  104068. protected _numMeshes: number;
  104069. /** @hidden */
  104070. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104071. private _renderFunction;
  104072. private _utilityLayer;
  104073. private _debugBoxMesh;
  104074. private _debugSphereMesh;
  104075. private _debugCylinderMesh;
  104076. private _debugMaterial;
  104077. private _debugMeshMeshes;
  104078. /**
  104079. * Creates a new PhysicsViewer
  104080. * @param scene defines the hosting scene
  104081. */
  104082. constructor(scene: Scene);
  104083. /** @hidden */
  104084. protected _updateDebugMeshes(): void;
  104085. /**
  104086. * Renders a specified physic impostor
  104087. * @param impostor defines the impostor to render
  104088. * @param targetMesh defines the mesh represented by the impostor
  104089. * @returns the new debug mesh used to render the impostor
  104090. */
  104091. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104092. /**
  104093. * Hides a specified physic impostor
  104094. * @param impostor defines the impostor to hide
  104095. */
  104096. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104097. private _getDebugMaterial;
  104098. private _getDebugBoxMesh;
  104099. private _getDebugSphereMesh;
  104100. private _getDebugCylinderMesh;
  104101. private _getDebugMeshMesh;
  104102. private _getDebugMesh;
  104103. /** Releases all resources */
  104104. dispose(): void;
  104105. }
  104106. }
  104107. declare module BABYLON {
  104108. /**
  104109. * Class containing static functions to help procedurally build meshes
  104110. */
  104111. export class LinesBuilder {
  104112. /**
  104113. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104114. * * 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
  104115. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104116. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104117. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104118. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104119. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104120. * * 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
  104121. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104124. * @param name defines the name of the new line system
  104125. * @param options defines the options used to create the line system
  104126. * @param scene defines the hosting scene
  104127. * @returns a new line system mesh
  104128. */
  104129. static CreateLineSystem(name: string, options: {
  104130. lines: Vector3[][];
  104131. updatable?: boolean;
  104132. instance?: Nullable<LinesMesh>;
  104133. colors?: Nullable<Color4[][]>;
  104134. useVertexAlpha?: boolean;
  104135. }, scene: Nullable<Scene>): LinesMesh;
  104136. /**
  104137. * Creates a line mesh
  104138. * 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
  104139. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104140. * * The parameter `points` is an array successive Vector3
  104141. * * 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
  104142. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104143. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104144. * * When updating an instance, remember that only point positions can change, not the number of points
  104145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104146. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104147. * @param name defines the name of the new line system
  104148. * @param options defines the options used to create the line system
  104149. * @param scene defines the hosting scene
  104150. * @returns a new line mesh
  104151. */
  104152. static CreateLines(name: string, options: {
  104153. points: Vector3[];
  104154. updatable?: boolean;
  104155. instance?: Nullable<LinesMesh>;
  104156. colors?: Color4[];
  104157. useVertexAlpha?: boolean;
  104158. }, scene?: Nullable<Scene>): LinesMesh;
  104159. /**
  104160. * Creates a dashed line mesh
  104161. * * 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
  104162. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104163. * * The parameter `points` is an array successive Vector3
  104164. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104165. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104166. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104167. * * 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
  104168. * * When updating an instance, remember that only point positions can change, not the number of points
  104169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104170. * @param name defines the name of the mesh
  104171. * @param options defines the options used to create the mesh
  104172. * @param scene defines the hosting scene
  104173. * @returns the dashed line mesh
  104174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104175. */
  104176. static CreateDashedLines(name: string, options: {
  104177. points: Vector3[];
  104178. dashSize?: number;
  104179. gapSize?: number;
  104180. dashNb?: number;
  104181. updatable?: boolean;
  104182. instance?: LinesMesh;
  104183. }, scene?: Nullable<Scene>): LinesMesh;
  104184. }
  104185. }
  104186. declare module BABYLON {
  104187. /**
  104188. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104189. * in order to better appreciate the issue one might have.
  104190. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104191. */
  104192. export class RayHelper {
  104193. /**
  104194. * Defines the ray we are currently tryin to visualize.
  104195. */
  104196. ray: Nullable<Ray>;
  104197. private _renderPoints;
  104198. private _renderLine;
  104199. private _renderFunction;
  104200. private _scene;
  104201. private _updateToMeshFunction;
  104202. private _attachedToMesh;
  104203. private _meshSpaceDirection;
  104204. private _meshSpaceOrigin;
  104205. /**
  104206. * Helper function to create a colored helper in a scene in one line.
  104207. * @param ray Defines the ray we are currently tryin to visualize
  104208. * @param scene Defines the scene the ray is used in
  104209. * @param color Defines the color we want to see the ray in
  104210. * @returns The newly created ray helper.
  104211. */
  104212. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104213. /**
  104214. * Instantiate a new ray helper.
  104215. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104216. * in order to better appreciate the issue one might have.
  104217. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104218. * @param ray Defines the ray we are currently tryin to visualize
  104219. */
  104220. constructor(ray: Ray);
  104221. /**
  104222. * Shows the ray we are willing to debug.
  104223. * @param scene Defines the scene the ray needs to be rendered in
  104224. * @param color Defines the color the ray needs to be rendered in
  104225. */
  104226. show(scene: Scene, color?: Color3): void;
  104227. /**
  104228. * Hides the ray we are debugging.
  104229. */
  104230. hide(): void;
  104231. private _render;
  104232. /**
  104233. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104234. * @param mesh Defines the mesh we want the helper attached to
  104235. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104236. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104237. * @param length Defines the length of the ray
  104238. */
  104239. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104240. /**
  104241. * Detach the ray helper from the mesh it has previously been attached to.
  104242. */
  104243. detachFromMesh(): void;
  104244. private _updateToMesh;
  104245. /**
  104246. * Dispose the helper and release its associated resources.
  104247. */
  104248. dispose(): void;
  104249. }
  104250. }
  104251. declare module BABYLON.Debug {
  104252. /**
  104253. * Class used to render a debug view of a given skeleton
  104254. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104255. */
  104256. export class SkeletonViewer {
  104257. /** defines the skeleton to render */
  104258. skeleton: Skeleton;
  104259. /** defines the mesh attached to the skeleton */
  104260. mesh: AbstractMesh;
  104261. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104262. autoUpdateBonesMatrices: boolean;
  104263. /** defines the rendering group id to use with the viewer */
  104264. renderingGroupId: number;
  104265. /** Gets or sets the color used to render the skeleton */
  104266. color: Color3;
  104267. private _scene;
  104268. private _debugLines;
  104269. private _debugMesh;
  104270. private _isEnabled;
  104271. private _renderFunction;
  104272. private _utilityLayer;
  104273. /**
  104274. * Returns the mesh used to render the bones
  104275. */
  104276. readonly debugMesh: Nullable<LinesMesh>;
  104277. /**
  104278. * Creates a new SkeletonViewer
  104279. * @param skeleton defines the skeleton to render
  104280. * @param mesh defines the mesh attached to the skeleton
  104281. * @param scene defines the hosting scene
  104282. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104283. * @param renderingGroupId defines the rendering group id to use with the viewer
  104284. */
  104285. constructor(
  104286. /** defines the skeleton to render */
  104287. skeleton: Skeleton,
  104288. /** defines the mesh attached to the skeleton */
  104289. mesh: AbstractMesh, scene: Scene,
  104290. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104291. autoUpdateBonesMatrices?: boolean,
  104292. /** defines the rendering group id to use with the viewer */
  104293. renderingGroupId?: number);
  104294. /** Gets or sets a boolean indicating if the viewer is enabled */
  104295. isEnabled: boolean;
  104296. private _getBonePosition;
  104297. private _getLinesForBonesWithLength;
  104298. private _getLinesForBonesNoLength;
  104299. /** Update the viewer to sync with current skeleton state */
  104300. update(): void;
  104301. /** Release associated resources */
  104302. dispose(): void;
  104303. }
  104304. }
  104305. declare module BABYLON {
  104306. /**
  104307. * Options to create the null engine
  104308. */
  104309. export class NullEngineOptions {
  104310. /**
  104311. * Render width (Default: 512)
  104312. */
  104313. renderWidth: number;
  104314. /**
  104315. * Render height (Default: 256)
  104316. */
  104317. renderHeight: number;
  104318. /**
  104319. * Texture size (Default: 512)
  104320. */
  104321. textureSize: number;
  104322. /**
  104323. * If delta time between frames should be constant
  104324. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104325. */
  104326. deterministicLockstep: boolean;
  104327. /**
  104328. * Maximum about of steps between frames (Default: 4)
  104329. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104330. */
  104331. lockstepMaxSteps: number;
  104332. }
  104333. /**
  104334. * The null engine class provides support for headless version of babylon.js.
  104335. * This can be used in server side scenario or for testing purposes
  104336. */
  104337. export class NullEngine extends Engine {
  104338. private _options;
  104339. /**
  104340. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104341. */
  104342. isDeterministicLockStep(): boolean;
  104343. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104344. getLockstepMaxSteps(): number;
  104345. /**
  104346. * Sets hardware scaling, used to save performance if needed
  104347. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104348. */
  104349. getHardwareScalingLevel(): number;
  104350. constructor(options?: NullEngineOptions);
  104351. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104352. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104353. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104354. getRenderWidth(useScreen?: boolean): number;
  104355. getRenderHeight(useScreen?: boolean): number;
  104356. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104357. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104358. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104359. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104360. bindSamplers(effect: Effect): void;
  104361. enableEffect(effect: Effect): void;
  104362. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104363. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104364. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104365. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104366. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104367. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104368. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104369. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104370. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104371. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104372. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104373. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104374. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104375. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104376. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104377. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104378. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104379. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104380. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104381. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104382. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104383. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104384. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104385. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104386. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104387. bindBuffers(vertexBuffers: {
  104388. [key: string]: VertexBuffer;
  104389. }, indexBuffer: DataBuffer, effect: Effect): void;
  104390. wipeCaches(bruteForce?: boolean): void;
  104391. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104392. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104393. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104394. /** @hidden */
  104395. _createTexture(): WebGLTexture;
  104396. /** @hidden */
  104397. _releaseTexture(texture: InternalTexture): void;
  104398. 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;
  104399. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104400. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104401. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104402. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104403. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104404. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104405. areAllEffectsReady(): boolean;
  104406. /**
  104407. * @hidden
  104408. * Get the current error code of the webGL context
  104409. * @returns the error code
  104410. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104411. */
  104412. getError(): number;
  104413. /** @hidden */
  104414. _getUnpackAlignement(): number;
  104415. /** @hidden */
  104416. _unpackFlipY(value: boolean): void;
  104417. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104418. /**
  104419. * Updates a dynamic vertex buffer.
  104420. * @param vertexBuffer the vertex buffer to update
  104421. * @param data the data used to update the vertex buffer
  104422. * @param byteOffset the byte offset of the data (optional)
  104423. * @param byteLength the byte length of the data (optional)
  104424. */
  104425. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104426. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104427. /** @hidden */
  104428. _bindTexture(channel: number, texture: InternalTexture): void;
  104429. /** @hidden */
  104430. _releaseBuffer(buffer: DataBuffer): boolean;
  104431. releaseEffects(): void;
  104432. displayLoadingUI(): void;
  104433. hideLoadingUI(): void;
  104434. /** @hidden */
  104435. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104436. /** @hidden */
  104437. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104438. /** @hidden */
  104439. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104440. /** @hidden */
  104441. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104442. }
  104443. }
  104444. declare module BABYLON {
  104445. /** @hidden */
  104446. export class _OcclusionDataStorage {
  104447. /** @hidden */
  104448. occlusionInternalRetryCounter: number;
  104449. /** @hidden */
  104450. isOcclusionQueryInProgress: boolean;
  104451. /** @hidden */
  104452. isOccluded: boolean;
  104453. /** @hidden */
  104454. occlusionRetryCount: number;
  104455. /** @hidden */
  104456. occlusionType: number;
  104457. /** @hidden */
  104458. occlusionQueryAlgorithmType: number;
  104459. }
  104460. interface Engine {
  104461. /**
  104462. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104463. * @return the new query
  104464. */
  104465. createQuery(): WebGLQuery;
  104466. /**
  104467. * Delete and release a webGL query
  104468. * @param query defines the query to delete
  104469. * @return the current engine
  104470. */
  104471. deleteQuery(query: WebGLQuery): Engine;
  104472. /**
  104473. * Check if a given query has resolved and got its value
  104474. * @param query defines the query to check
  104475. * @returns true if the query got its value
  104476. */
  104477. isQueryResultAvailable(query: WebGLQuery): boolean;
  104478. /**
  104479. * Gets the value of a given query
  104480. * @param query defines the query to check
  104481. * @returns the value of the query
  104482. */
  104483. getQueryResult(query: WebGLQuery): number;
  104484. /**
  104485. * Initiates an occlusion query
  104486. * @param algorithmType defines the algorithm to use
  104487. * @param query defines the query to use
  104488. * @returns the current engine
  104489. * @see http://doc.babylonjs.com/features/occlusionquery
  104490. */
  104491. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104492. /**
  104493. * Ends an occlusion query
  104494. * @see http://doc.babylonjs.com/features/occlusionquery
  104495. * @param algorithmType defines the algorithm to use
  104496. * @returns the current engine
  104497. */
  104498. endOcclusionQuery(algorithmType: number): Engine;
  104499. /**
  104500. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104501. * Please note that only one query can be issued at a time
  104502. * @returns a time token used to track the time span
  104503. */
  104504. startTimeQuery(): Nullable<_TimeToken>;
  104505. /**
  104506. * Ends a time query
  104507. * @param token defines the token used to measure the time span
  104508. * @returns the time spent (in ns)
  104509. */
  104510. endTimeQuery(token: _TimeToken): int;
  104511. /** @hidden */
  104512. _currentNonTimestampToken: Nullable<_TimeToken>;
  104513. /** @hidden */
  104514. _createTimeQuery(): WebGLQuery;
  104515. /** @hidden */
  104516. _deleteTimeQuery(query: WebGLQuery): void;
  104517. /** @hidden */
  104518. _getGlAlgorithmType(algorithmType: number): number;
  104519. /** @hidden */
  104520. _getTimeQueryResult(query: WebGLQuery): any;
  104521. /** @hidden */
  104522. _getTimeQueryAvailability(query: WebGLQuery): any;
  104523. }
  104524. interface AbstractMesh {
  104525. /**
  104526. * Backing filed
  104527. * @hidden
  104528. */
  104529. __occlusionDataStorage: _OcclusionDataStorage;
  104530. /**
  104531. * Access property
  104532. * @hidden
  104533. */
  104534. _occlusionDataStorage: _OcclusionDataStorage;
  104535. /**
  104536. * 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.
  104537. * The default value is -1 which means don't break the query and wait till the result
  104538. * @see http://doc.babylonjs.com/features/occlusionquery
  104539. */
  104540. occlusionRetryCount: number;
  104541. /**
  104542. * 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:
  104543. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104544. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104545. * * 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.
  104546. * @see http://doc.babylonjs.com/features/occlusionquery
  104547. */
  104548. occlusionType: number;
  104549. /**
  104550. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104551. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104552. * * 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.
  104553. * @see http://doc.babylonjs.com/features/occlusionquery
  104554. */
  104555. occlusionQueryAlgorithmType: number;
  104556. /**
  104557. * 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
  104558. * @see http://doc.babylonjs.com/features/occlusionquery
  104559. */
  104560. isOccluded: boolean;
  104561. /**
  104562. * Flag to check the progress status of the query
  104563. * @see http://doc.babylonjs.com/features/occlusionquery
  104564. */
  104565. isOcclusionQueryInProgress: boolean;
  104566. }
  104567. }
  104568. declare module BABYLON {
  104569. /** @hidden */
  104570. export var _forceTransformFeedbackToBundle: boolean;
  104571. interface Engine {
  104572. /**
  104573. * Creates a webGL transform feedback object
  104574. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104575. * @returns the webGL transform feedback object
  104576. */
  104577. createTransformFeedback(): WebGLTransformFeedback;
  104578. /**
  104579. * Delete a webGL transform feedback object
  104580. * @param value defines the webGL transform feedback object to delete
  104581. */
  104582. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104583. /**
  104584. * Bind a webGL transform feedback object to the webgl context
  104585. * @param value defines the webGL transform feedback object to bind
  104586. */
  104587. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104588. /**
  104589. * Begins a transform feedback operation
  104590. * @param usePoints defines if points or triangles must be used
  104591. */
  104592. beginTransformFeedback(usePoints: boolean): void;
  104593. /**
  104594. * Ends a transform feedback operation
  104595. */
  104596. endTransformFeedback(): void;
  104597. /**
  104598. * Specify the varyings to use with transform feedback
  104599. * @param program defines the associated webGL program
  104600. * @param value defines the list of strings representing the varying names
  104601. */
  104602. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104603. /**
  104604. * Bind a webGL buffer for a transform feedback operation
  104605. * @param value defines the webGL buffer to bind
  104606. */
  104607. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104608. }
  104609. }
  104610. declare module BABYLON {
  104611. /**
  104612. * Creation options of the multi render target texture.
  104613. */
  104614. export interface IMultiRenderTargetOptions {
  104615. /**
  104616. * Define if the texture needs to create mip maps after render.
  104617. */
  104618. generateMipMaps?: boolean;
  104619. /**
  104620. * Define the types of all the draw buffers we want to create
  104621. */
  104622. types?: number[];
  104623. /**
  104624. * Define the sampling modes of all the draw buffers we want to create
  104625. */
  104626. samplingModes?: number[];
  104627. /**
  104628. * Define if a depth buffer is required
  104629. */
  104630. generateDepthBuffer?: boolean;
  104631. /**
  104632. * Define if a stencil buffer is required
  104633. */
  104634. generateStencilBuffer?: boolean;
  104635. /**
  104636. * Define if a depth texture is required instead of a depth buffer
  104637. */
  104638. generateDepthTexture?: boolean;
  104639. /**
  104640. * Define the number of desired draw buffers
  104641. */
  104642. textureCount?: number;
  104643. /**
  104644. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104645. */
  104646. doNotChangeAspectRatio?: boolean;
  104647. /**
  104648. * Define the default type of the buffers we are creating
  104649. */
  104650. defaultType?: number;
  104651. }
  104652. /**
  104653. * A multi render target, like a render target provides the ability to render to a texture.
  104654. * Unlike the render target, it can render to several draw buffers in one draw.
  104655. * This is specially interesting in deferred rendering or for any effects requiring more than
  104656. * just one color from a single pass.
  104657. */
  104658. export class MultiRenderTarget extends RenderTargetTexture {
  104659. private _internalTextures;
  104660. private _textures;
  104661. private _multiRenderTargetOptions;
  104662. /**
  104663. * Get if draw buffers are currently supported by the used hardware and browser.
  104664. */
  104665. readonly isSupported: boolean;
  104666. /**
  104667. * Get the list of textures generated by the multi render target.
  104668. */
  104669. readonly textures: Texture[];
  104670. /**
  104671. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104672. */
  104673. readonly depthTexture: Texture;
  104674. /**
  104675. * Set the wrapping mode on U of all the textures we are rendering to.
  104676. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104677. */
  104678. wrapU: number;
  104679. /**
  104680. * Set the wrapping mode on V of all the textures we are rendering to.
  104681. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104682. */
  104683. wrapV: number;
  104684. /**
  104685. * Instantiate a new multi render target texture.
  104686. * A multi render target, like a render target provides the ability to render to a texture.
  104687. * Unlike the render target, it can render to several draw buffers in one draw.
  104688. * This is specially interesting in deferred rendering or for any effects requiring more than
  104689. * just one color from a single pass.
  104690. * @param name Define the name of the texture
  104691. * @param size Define the size of the buffers to render to
  104692. * @param count Define the number of target we are rendering into
  104693. * @param scene Define the scene the texture belongs to
  104694. * @param options Define the options used to create the multi render target
  104695. */
  104696. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104697. /** @hidden */
  104698. _rebuild(): void;
  104699. private _createInternalTextures;
  104700. private _createTextures;
  104701. /**
  104702. * Define the number of samples used if MSAA is enabled.
  104703. */
  104704. samples: number;
  104705. /**
  104706. * Resize all the textures in the multi render target.
  104707. * Be carrefull as it will recreate all the data in the new texture.
  104708. * @param size Define the new size
  104709. */
  104710. resize(size: any): void;
  104711. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104712. /**
  104713. * Dispose the render targets and their associated resources
  104714. */
  104715. dispose(): void;
  104716. /**
  104717. * Release all the underlying texture used as draw buffers.
  104718. */
  104719. releaseInternalTextures(): void;
  104720. }
  104721. }
  104722. declare module BABYLON {
  104723. interface Engine {
  104724. /**
  104725. * Unbind a list of render target textures from the webGL context
  104726. * This is used only when drawBuffer extension or webGL2 are active
  104727. * @param textures defines the render target textures to unbind
  104728. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104729. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104730. */
  104731. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104732. /**
  104733. * Create a multi render target texture
  104734. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  104735. * @param size defines the size of the texture
  104736. * @param options defines the creation options
  104737. * @returns the cube texture as an InternalTexture
  104738. */
  104739. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104740. /**
  104741. * Update the sample count for a given multiple render target texture
  104742. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104743. * @param textures defines the textures to update
  104744. * @param samples defines the sample count to set
  104745. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104746. */
  104747. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104748. }
  104749. }
  104750. declare module BABYLON {
  104751. /**
  104752. * Gather the list of clipboard event types as constants.
  104753. */
  104754. export class ClipboardEventTypes {
  104755. /**
  104756. * The clipboard event is fired when a copy command is active (pressed).
  104757. */
  104758. static readonly COPY: number;
  104759. /**
  104760. * The clipboard event is fired when a cut command is active (pressed).
  104761. */
  104762. static readonly CUT: number;
  104763. /**
  104764. * The clipboard event is fired when a paste command is active (pressed).
  104765. */
  104766. static readonly PASTE: number;
  104767. }
  104768. /**
  104769. * This class is used to store clipboard related info for the onClipboardObservable event.
  104770. */
  104771. export class ClipboardInfo {
  104772. /**
  104773. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104774. */
  104775. type: number;
  104776. /**
  104777. * Defines the related dom event
  104778. */
  104779. event: ClipboardEvent;
  104780. /**
  104781. *Creates an instance of ClipboardInfo.
  104782. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  104783. * @param event Defines the related dom event
  104784. */
  104785. constructor(
  104786. /**
  104787. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104788. */
  104789. type: number,
  104790. /**
  104791. * Defines the related dom event
  104792. */
  104793. event: ClipboardEvent);
  104794. /**
  104795. * Get the clipboard event's type from the keycode.
  104796. * @param keyCode Defines the keyCode for the current keyboard event.
  104797. * @return {number}
  104798. */
  104799. static GetTypeFromCharacter(keyCode: number): number;
  104800. }
  104801. }
  104802. declare module BABYLON {
  104803. /**
  104804. * Class used to represent data loading progression
  104805. */
  104806. export class SceneLoaderProgressEvent {
  104807. /** defines if data length to load can be evaluated */
  104808. readonly lengthComputable: boolean;
  104809. /** defines the loaded data length */
  104810. readonly loaded: number;
  104811. /** defines the data length to load */
  104812. readonly total: number;
  104813. /**
  104814. * Create a new progress event
  104815. * @param lengthComputable defines if data length to load can be evaluated
  104816. * @param loaded defines the loaded data length
  104817. * @param total defines the data length to load
  104818. */
  104819. constructor(
  104820. /** defines if data length to load can be evaluated */
  104821. lengthComputable: boolean,
  104822. /** defines the loaded data length */
  104823. loaded: number,
  104824. /** defines the data length to load */
  104825. total: number);
  104826. /**
  104827. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104828. * @param event defines the source event
  104829. * @returns a new SceneLoaderProgressEvent
  104830. */
  104831. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104832. }
  104833. /**
  104834. * Interface used by SceneLoader plugins to define supported file extensions
  104835. */
  104836. export interface ISceneLoaderPluginExtensions {
  104837. /**
  104838. * Defines the list of supported extensions
  104839. */
  104840. [extension: string]: {
  104841. isBinary: boolean;
  104842. };
  104843. }
  104844. /**
  104845. * Interface used by SceneLoader plugin factory
  104846. */
  104847. export interface ISceneLoaderPluginFactory {
  104848. /**
  104849. * Defines the name of the factory
  104850. */
  104851. name: string;
  104852. /**
  104853. * Function called to create a new plugin
  104854. * @return the new plugin
  104855. */
  104856. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104857. /**
  104858. * Boolean indicating if the plugin can direct load specific data
  104859. */
  104860. canDirectLoad?: (data: string) => boolean;
  104861. }
  104862. /**
  104863. * Interface used to define a SceneLoader plugin
  104864. */
  104865. export interface ISceneLoaderPlugin {
  104866. /**
  104867. * The friendly name of this plugin.
  104868. */
  104869. name: string;
  104870. /**
  104871. * The file extensions supported by this plugin.
  104872. */
  104873. extensions: string | ISceneLoaderPluginExtensions;
  104874. /**
  104875. * Import meshes into a scene.
  104876. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104877. * @param scene The scene to import into
  104878. * @param data The data to import
  104879. * @param rootUrl The root url for scene and resources
  104880. * @param meshes The meshes array to import into
  104881. * @param particleSystems The particle systems array to import into
  104882. * @param skeletons The skeletons array to import into
  104883. * @param onError The callback when import fails
  104884. * @returns True if successful or false otherwise
  104885. */
  104886. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  104887. /**
  104888. * Load into a scene.
  104889. * @param scene The scene to load into
  104890. * @param data The data to import
  104891. * @param rootUrl The root url for scene and resources
  104892. * @param onError The callback when import fails
  104893. * @returns true if successful or false otherwise
  104894. */
  104895. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  104896. /**
  104897. * The callback that returns true if the data can be directly loaded.
  104898. */
  104899. canDirectLoad?: (data: string) => boolean;
  104900. /**
  104901. * The callback that allows custom handling of the root url based on the response url.
  104902. */
  104903. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104904. /**
  104905. * Load into an asset container.
  104906. * @param scene The scene to load into
  104907. * @param data The data to import
  104908. * @param rootUrl The root url for scene and resources
  104909. * @param onError The callback when import fails
  104910. * @returns The loaded asset container
  104911. */
  104912. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  104913. }
  104914. /**
  104915. * Interface used to define an async SceneLoader plugin
  104916. */
  104917. export interface ISceneLoaderPluginAsync {
  104918. /**
  104919. * The friendly name of this plugin.
  104920. */
  104921. name: string;
  104922. /**
  104923. * The file extensions supported by this plugin.
  104924. */
  104925. extensions: string | ISceneLoaderPluginExtensions;
  104926. /**
  104927. * Import meshes into a scene.
  104928. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104929. * @param scene The scene to import into
  104930. * @param data The data to import
  104931. * @param rootUrl The root url for scene and resources
  104932. * @param onProgress The callback when the load progresses
  104933. * @param fileName Defines the name of the file to load
  104934. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  104935. */
  104936. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  104937. meshes: AbstractMesh[];
  104938. particleSystems: IParticleSystem[];
  104939. skeletons: Skeleton[];
  104940. animationGroups: AnimationGroup[];
  104941. }>;
  104942. /**
  104943. * Load into a scene.
  104944. * @param scene The scene to load into
  104945. * @param data The data to import
  104946. * @param rootUrl The root url for scene and resources
  104947. * @param onProgress The callback when the load progresses
  104948. * @param fileName Defines the name of the file to load
  104949. * @returns Nothing
  104950. */
  104951. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  104952. /**
  104953. * The callback that returns true if the data can be directly loaded.
  104954. */
  104955. canDirectLoad?: (data: string) => boolean;
  104956. /**
  104957. * The callback that allows custom handling of the root url based on the response url.
  104958. */
  104959. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104960. /**
  104961. * Load into an asset container.
  104962. * @param scene The scene to load into
  104963. * @param data The data to import
  104964. * @param rootUrl The root url for scene and resources
  104965. * @param onProgress The callback when the load progresses
  104966. * @param fileName Defines the name of the file to load
  104967. * @returns The loaded asset container
  104968. */
  104969. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  104970. }
  104971. /**
  104972. * Class used to load scene from various file formats using registered plugins
  104973. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  104974. */
  104975. export class SceneLoader {
  104976. /**
  104977. * No logging while loading
  104978. */
  104979. static readonly NO_LOGGING: number;
  104980. /**
  104981. * Minimal logging while loading
  104982. */
  104983. static readonly MINIMAL_LOGGING: number;
  104984. /**
  104985. * Summary logging while loading
  104986. */
  104987. static readonly SUMMARY_LOGGING: number;
  104988. /**
  104989. * Detailled logging while loading
  104990. */
  104991. static readonly DETAILED_LOGGING: number;
  104992. /**
  104993. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104994. */
  104995. static ForceFullSceneLoadingForIncremental: boolean;
  104996. /**
  104997. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104998. */
  104999. static ShowLoadingScreen: boolean;
  105000. /**
  105001. * Defines the current logging level (while loading the scene)
  105002. * @ignorenaming
  105003. */
  105004. static loggingLevel: number;
  105005. /**
  105006. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105007. */
  105008. static CleanBoneMatrixWeights: boolean;
  105009. /**
  105010. * Event raised when a plugin is used to load a scene
  105011. */
  105012. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105013. private static _registeredPlugins;
  105014. private static _getDefaultPlugin;
  105015. private static _getPluginForExtension;
  105016. private static _getPluginForDirectLoad;
  105017. private static _getPluginForFilename;
  105018. private static _getDirectLoad;
  105019. private static _loadData;
  105020. private static _getFileInfo;
  105021. /**
  105022. * Gets a plugin that can load the given extension
  105023. * @param extension defines the extension to load
  105024. * @returns a plugin or null if none works
  105025. */
  105026. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105027. /**
  105028. * Gets a boolean indicating that the given extension can be loaded
  105029. * @param extension defines the extension to load
  105030. * @returns true if the extension is supported
  105031. */
  105032. static IsPluginForExtensionAvailable(extension: string): boolean;
  105033. /**
  105034. * Adds a new plugin to the list of registered plugins
  105035. * @param plugin defines the plugin to add
  105036. */
  105037. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105038. /**
  105039. * Import meshes into a scene
  105040. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105041. * @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)
  105042. * @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)
  105043. * @param scene the instance of BABYLON.Scene to append to
  105044. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105045. * @param onProgress a callback with a progress event for each file being loaded
  105046. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105047. * @param pluginExtension the extension used to determine the plugin
  105048. * @returns The loaded plugin
  105049. */
  105050. 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>;
  105051. /**
  105052. * Import meshes into a scene
  105053. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105054. * @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)
  105055. * @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)
  105056. * @param scene the instance of BABYLON.Scene to append to
  105057. * @param onProgress a callback with a progress event for each file being loaded
  105058. * @param pluginExtension the extension used to determine the plugin
  105059. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105060. */
  105061. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105062. meshes: AbstractMesh[];
  105063. particleSystems: IParticleSystem[];
  105064. skeletons: Skeleton[];
  105065. animationGroups: AnimationGroup[];
  105066. }>;
  105067. /**
  105068. * Load a scene
  105069. * @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)
  105070. * @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)
  105071. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105072. * @param onSuccess a callback with the scene when import succeeds
  105073. * @param onProgress a callback with a progress event for each file being loaded
  105074. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105075. * @param pluginExtension the extension used to determine the plugin
  105076. * @returns The loaded plugin
  105077. */
  105078. 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>;
  105079. /**
  105080. * Load a scene
  105081. * @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)
  105082. * @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)
  105083. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105084. * @param onProgress a callback with a progress event for each file being loaded
  105085. * @param pluginExtension the extension used to determine the plugin
  105086. * @returns The loaded scene
  105087. */
  105088. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105089. /**
  105090. * Append a scene
  105091. * @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)
  105092. * @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)
  105093. * @param scene is the instance of BABYLON.Scene to append to
  105094. * @param onSuccess a callback with the scene when import succeeds
  105095. * @param onProgress a callback with a progress event for each file being loaded
  105096. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105097. * @param pluginExtension the extension used to determine the plugin
  105098. * @returns The loaded plugin
  105099. */
  105100. 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>;
  105101. /**
  105102. * Append a scene
  105103. * @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)
  105104. * @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)
  105105. * @param scene is the instance of BABYLON.Scene to append to
  105106. * @param onProgress a callback with a progress event for each file being loaded
  105107. * @param pluginExtension the extension used to determine the plugin
  105108. * @returns The given scene
  105109. */
  105110. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105111. /**
  105112. * Load a scene into an asset container
  105113. * @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)
  105114. * @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)
  105115. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105116. * @param onSuccess a callback with the scene when import succeeds
  105117. * @param onProgress a callback with a progress event for each file being loaded
  105118. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105119. * @param pluginExtension the extension used to determine the plugin
  105120. * @returns The loaded plugin
  105121. */
  105122. 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>;
  105123. /**
  105124. * Load a scene into an asset container
  105125. * @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)
  105126. * @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)
  105127. * @param scene is the instance of Scene to append to
  105128. * @param onProgress a callback with a progress event for each file being loaded
  105129. * @param pluginExtension the extension used to determine the plugin
  105130. * @returns The loaded asset container
  105131. */
  105132. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105133. }
  105134. }
  105135. declare module BABYLON {
  105136. /**
  105137. * Google Daydream controller
  105138. */
  105139. export class DaydreamController extends WebVRController {
  105140. /**
  105141. * Base Url for the controller model.
  105142. */
  105143. static MODEL_BASE_URL: string;
  105144. /**
  105145. * File name for the controller model.
  105146. */
  105147. static MODEL_FILENAME: string;
  105148. /**
  105149. * Gamepad Id prefix used to identify Daydream Controller.
  105150. */
  105151. static readonly GAMEPAD_ID_PREFIX: string;
  105152. /**
  105153. * Creates a new DaydreamController from a gamepad
  105154. * @param vrGamepad the gamepad that the controller should be created from
  105155. */
  105156. constructor(vrGamepad: any);
  105157. /**
  105158. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105159. * @param scene scene in which to add meshes
  105160. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105161. */
  105162. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105163. /**
  105164. * Called once for each button that changed state since the last frame
  105165. * @param buttonIdx Which button index changed
  105166. * @param state New state of the button
  105167. * @param changes Which properties on the state changed since last frame
  105168. */
  105169. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105170. }
  105171. }
  105172. declare module BABYLON {
  105173. /**
  105174. * Gear VR Controller
  105175. */
  105176. export class GearVRController extends WebVRController {
  105177. /**
  105178. * Base Url for the controller model.
  105179. */
  105180. static MODEL_BASE_URL: string;
  105181. /**
  105182. * File name for the controller model.
  105183. */
  105184. static MODEL_FILENAME: string;
  105185. /**
  105186. * Gamepad Id prefix used to identify this controller.
  105187. */
  105188. static readonly GAMEPAD_ID_PREFIX: string;
  105189. private readonly _buttonIndexToObservableNameMap;
  105190. /**
  105191. * Creates a new GearVRController from a gamepad
  105192. * @param vrGamepad the gamepad that the controller should be created from
  105193. */
  105194. constructor(vrGamepad: any);
  105195. /**
  105196. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105197. * @param scene scene in which to add meshes
  105198. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105199. */
  105200. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105201. /**
  105202. * Called once for each button that changed state since the last frame
  105203. * @param buttonIdx Which button index changed
  105204. * @param state New state of the button
  105205. * @param changes Which properties on the state changed since last frame
  105206. */
  105207. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105208. }
  105209. }
  105210. declare module BABYLON {
  105211. /**
  105212. * Generic Controller
  105213. */
  105214. export class GenericController extends WebVRController {
  105215. /**
  105216. * Base Url for the controller model.
  105217. */
  105218. static readonly MODEL_BASE_URL: string;
  105219. /**
  105220. * File name for the controller model.
  105221. */
  105222. static readonly MODEL_FILENAME: string;
  105223. /**
  105224. * Creates a new GenericController from a gamepad
  105225. * @param vrGamepad the gamepad that the controller should be created from
  105226. */
  105227. constructor(vrGamepad: any);
  105228. /**
  105229. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105230. * @param scene scene in which to add meshes
  105231. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105232. */
  105233. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105234. /**
  105235. * Called once for each button that changed state since the last frame
  105236. * @param buttonIdx Which button index changed
  105237. * @param state New state of the button
  105238. * @param changes Which properties on the state changed since last frame
  105239. */
  105240. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105241. }
  105242. }
  105243. declare module BABYLON {
  105244. /**
  105245. * Oculus Touch Controller
  105246. */
  105247. export class OculusTouchController extends WebVRController {
  105248. /**
  105249. * Base Url for the controller model.
  105250. */
  105251. static MODEL_BASE_URL: string;
  105252. /**
  105253. * File name for the left controller model.
  105254. */
  105255. static MODEL_LEFT_FILENAME: string;
  105256. /**
  105257. * File name for the right controller model.
  105258. */
  105259. static MODEL_RIGHT_FILENAME: string;
  105260. /**
  105261. * Fired when the secondary trigger on this controller is modified
  105262. */
  105263. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105264. /**
  105265. * Fired when the thumb rest on this controller is modified
  105266. */
  105267. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105268. /**
  105269. * Creates a new OculusTouchController from a gamepad
  105270. * @param vrGamepad the gamepad that the controller should be created from
  105271. */
  105272. constructor(vrGamepad: any);
  105273. /**
  105274. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105275. * @param scene scene in which to add meshes
  105276. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105277. */
  105278. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105279. /**
  105280. * Fired when the A button on this controller is modified
  105281. */
  105282. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105283. /**
  105284. * Fired when the B button on this controller is modified
  105285. */
  105286. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105287. /**
  105288. * Fired when the X button on this controller is modified
  105289. */
  105290. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105291. /**
  105292. * Fired when the Y button on this controller is modified
  105293. */
  105294. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105295. /**
  105296. * Called once for each button that changed state since the last frame
  105297. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105298. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105299. * 2) secondary trigger (same)
  105300. * 3) A (right) X (left), touch, pressed = value
  105301. * 4) B / Y
  105302. * 5) thumb rest
  105303. * @param buttonIdx Which button index changed
  105304. * @param state New state of the button
  105305. * @param changes Which properties on the state changed since last frame
  105306. */
  105307. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105308. }
  105309. }
  105310. declare module BABYLON {
  105311. /**
  105312. * Vive Controller
  105313. */
  105314. export class ViveController extends WebVRController {
  105315. /**
  105316. * Base Url for the controller model.
  105317. */
  105318. static MODEL_BASE_URL: string;
  105319. /**
  105320. * File name for the controller model.
  105321. */
  105322. static MODEL_FILENAME: string;
  105323. /**
  105324. * Creates a new ViveController from a gamepad
  105325. * @param vrGamepad the gamepad that the controller should be created from
  105326. */
  105327. constructor(vrGamepad: any);
  105328. /**
  105329. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105330. * @param scene scene in which to add meshes
  105331. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105332. */
  105333. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105334. /**
  105335. * Fired when the left button on this controller is modified
  105336. */
  105337. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105338. /**
  105339. * Fired when the right button on this controller is modified
  105340. */
  105341. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105342. /**
  105343. * Fired when the menu button on this controller is modified
  105344. */
  105345. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105346. /**
  105347. * Called once for each button that changed state since the last frame
  105348. * Vive mapping:
  105349. * 0: touchpad
  105350. * 1: trigger
  105351. * 2: left AND right buttons
  105352. * 3: menu button
  105353. * @param buttonIdx Which button index changed
  105354. * @param state New state of the button
  105355. * @param changes Which properties on the state changed since last frame
  105356. */
  105357. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105358. }
  105359. }
  105360. declare module BABYLON {
  105361. /**
  105362. * Defines the WindowsMotionController object that the state of the windows motion controller
  105363. */
  105364. export class WindowsMotionController extends WebVRController {
  105365. /**
  105366. * The base url used to load the left and right controller models
  105367. */
  105368. static MODEL_BASE_URL: string;
  105369. /**
  105370. * The name of the left controller model file
  105371. */
  105372. static MODEL_LEFT_FILENAME: string;
  105373. /**
  105374. * The name of the right controller model file
  105375. */
  105376. static MODEL_RIGHT_FILENAME: string;
  105377. /**
  105378. * The controller name prefix for this controller type
  105379. */
  105380. static readonly GAMEPAD_ID_PREFIX: string;
  105381. /**
  105382. * The controller id pattern for this controller type
  105383. */
  105384. private static readonly GAMEPAD_ID_PATTERN;
  105385. private _loadedMeshInfo;
  105386. private readonly _mapping;
  105387. /**
  105388. * Fired when the trackpad on this controller is clicked
  105389. */
  105390. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105391. /**
  105392. * Fired when the trackpad on this controller is modified
  105393. */
  105394. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105395. /**
  105396. * The current x and y values of this controller's trackpad
  105397. */
  105398. trackpad: StickValues;
  105399. /**
  105400. * Creates a new WindowsMotionController from a gamepad
  105401. * @param vrGamepad the gamepad that the controller should be created from
  105402. */
  105403. constructor(vrGamepad: any);
  105404. /**
  105405. * Fired when the trigger on this controller is modified
  105406. */
  105407. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105408. /**
  105409. * Fired when the menu button on this controller is modified
  105410. */
  105411. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105412. /**
  105413. * Fired when the grip button on this controller is modified
  105414. */
  105415. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105416. /**
  105417. * Fired when the thumbstick button on this controller is modified
  105418. */
  105419. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105420. /**
  105421. * Fired when the touchpad button on this controller is modified
  105422. */
  105423. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105424. /**
  105425. * Fired when the touchpad values on this controller are modified
  105426. */
  105427. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105428. private _updateTrackpad;
  105429. /**
  105430. * Called once per frame by the engine.
  105431. */
  105432. update(): void;
  105433. /**
  105434. * Called once for each button that changed state since the last frame
  105435. * @param buttonIdx Which button index changed
  105436. * @param state New state of the button
  105437. * @param changes Which properties on the state changed since last frame
  105438. */
  105439. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105440. /**
  105441. * Moves the buttons on the controller mesh based on their current state
  105442. * @param buttonName the name of the button to move
  105443. * @param buttonValue the value of the button which determines the buttons new position
  105444. */
  105445. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105446. /**
  105447. * Moves the axis on the controller mesh based on its current state
  105448. * @param axis the index of the axis
  105449. * @param axisValue the value of the axis which determines the meshes new position
  105450. * @hidden
  105451. */
  105452. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105453. /**
  105454. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105455. * @param scene scene in which to add meshes
  105456. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105457. */
  105458. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105459. /**
  105460. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105461. * can be transformed by button presses and axes values, based on this._mapping.
  105462. *
  105463. * @param scene scene in which the meshes exist
  105464. * @param meshes list of meshes that make up the controller model to process
  105465. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105466. */
  105467. private processModel;
  105468. private createMeshInfo;
  105469. /**
  105470. * Gets the ray of the controller in the direction the controller is pointing
  105471. * @param length the length the resulting ray should be
  105472. * @returns a ray in the direction the controller is pointing
  105473. */
  105474. getForwardRay(length?: number): Ray;
  105475. /**
  105476. * Disposes of the controller
  105477. */
  105478. dispose(): void;
  105479. }
  105480. }
  105481. declare module BABYLON {
  105482. /**
  105483. * Class containing static functions to help procedurally build meshes
  105484. */
  105485. export class PolyhedronBuilder {
  105486. /**
  105487. * Creates a polyhedron mesh
  105488. * * 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
  105489. * * The parameter `size` (positive float, default 1) sets the polygon size
  105490. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105491. * * 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`
  105492. * * 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
  105493. * * 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)`)
  105494. * * 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
  105495. * * 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
  105496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105499. * @param name defines the name of the mesh
  105500. * @param options defines the options used to create the mesh
  105501. * @param scene defines the hosting scene
  105502. * @returns the polyhedron mesh
  105503. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105504. */
  105505. static CreatePolyhedron(name: string, options: {
  105506. type?: number;
  105507. size?: number;
  105508. sizeX?: number;
  105509. sizeY?: number;
  105510. sizeZ?: number;
  105511. custom?: any;
  105512. faceUV?: Vector4[];
  105513. faceColors?: Color4[];
  105514. flat?: boolean;
  105515. updatable?: boolean;
  105516. sideOrientation?: number;
  105517. frontUVs?: Vector4;
  105518. backUVs?: Vector4;
  105519. }, scene?: Nullable<Scene>): Mesh;
  105520. }
  105521. }
  105522. declare module BABYLON {
  105523. /**
  105524. * Gizmo that enables scaling a mesh along 3 axis
  105525. */
  105526. export class ScaleGizmo extends Gizmo {
  105527. /**
  105528. * Internal gizmo used for interactions on the x axis
  105529. */
  105530. xGizmo: AxisScaleGizmo;
  105531. /**
  105532. * Internal gizmo used for interactions on the y axis
  105533. */
  105534. yGizmo: AxisScaleGizmo;
  105535. /**
  105536. * Internal gizmo used for interactions on the z axis
  105537. */
  105538. zGizmo: AxisScaleGizmo;
  105539. /**
  105540. * Internal gizmo used to scale all axis equally
  105541. */
  105542. uniformScaleGizmo: AxisScaleGizmo;
  105543. private _meshAttached;
  105544. private _updateGizmoRotationToMatchAttachedMesh;
  105545. private _snapDistance;
  105546. private _scaleRatio;
  105547. private _uniformScalingMesh;
  105548. private _octahedron;
  105549. /** Fires an event when any of it's sub gizmos are dragged */
  105550. onDragStartObservable: Observable<{}>;
  105551. /** Fires an event when any of it's sub gizmos are released from dragging */
  105552. onDragEndObservable: Observable<{}>;
  105553. attachedMesh: Nullable<AbstractMesh>;
  105554. /**
  105555. * Creates a ScaleGizmo
  105556. * @param gizmoLayer The utility layer the gizmo will be added to
  105557. */
  105558. constructor(gizmoLayer?: UtilityLayerRenderer);
  105559. updateGizmoRotationToMatchAttachedMesh: boolean;
  105560. /**
  105561. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105562. */
  105563. snapDistance: number;
  105564. /**
  105565. * Ratio for the scale of the gizmo (Default: 1)
  105566. */
  105567. scaleRatio: number;
  105568. /**
  105569. * Disposes of the gizmo
  105570. */
  105571. dispose(): void;
  105572. }
  105573. }
  105574. declare module BABYLON {
  105575. /**
  105576. * Single axis scale gizmo
  105577. */
  105578. export class AxisScaleGizmo extends Gizmo {
  105579. /**
  105580. * Drag behavior responsible for the gizmos dragging interactions
  105581. */
  105582. dragBehavior: PointerDragBehavior;
  105583. private _pointerObserver;
  105584. /**
  105585. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105586. */
  105587. snapDistance: number;
  105588. /**
  105589. * Event that fires each time the gizmo snaps to a new location.
  105590. * * snapDistance is the the change in distance
  105591. */
  105592. onSnapObservable: Observable<{
  105593. snapDistance: number;
  105594. }>;
  105595. /**
  105596. * If the scaling operation should be done on all axis (default: false)
  105597. */
  105598. uniformScaling: boolean;
  105599. private _isEnabled;
  105600. private _parent;
  105601. private _arrow;
  105602. private _coloredMaterial;
  105603. private _hoverMaterial;
  105604. /**
  105605. * Creates an AxisScaleGizmo
  105606. * @param gizmoLayer The utility layer the gizmo will be added to
  105607. * @param dragAxis The axis which the gizmo will be able to scale on
  105608. * @param color The color of the gizmo
  105609. */
  105610. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  105611. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105612. /**
  105613. * If the gizmo is enabled
  105614. */
  105615. isEnabled: boolean;
  105616. /**
  105617. * Disposes of the gizmo
  105618. */
  105619. dispose(): void;
  105620. /**
  105621. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105622. * @param mesh The mesh to replace the default mesh of the gizmo
  105623. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  105624. */
  105625. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  105626. }
  105627. }
  105628. declare module BABYLON {
  105629. /**
  105630. * Bounding box gizmo
  105631. */
  105632. export class BoundingBoxGizmo extends Gizmo {
  105633. private _lineBoundingBox;
  105634. private _rotateSpheresParent;
  105635. private _scaleBoxesParent;
  105636. private _boundingDimensions;
  105637. private _renderObserver;
  105638. private _pointerObserver;
  105639. private _scaleDragSpeed;
  105640. private _tmpQuaternion;
  105641. private _tmpVector;
  105642. private _tmpRotationMatrix;
  105643. /**
  105644. * 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)
  105645. */
  105646. ignoreChildren: boolean;
  105647. /**
  105648. * 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)
  105649. */
  105650. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  105651. /**
  105652. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  105653. */
  105654. rotationSphereSize: number;
  105655. /**
  105656. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  105657. */
  105658. scaleBoxSize: number;
  105659. /**
  105660. * 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)
  105661. */
  105662. fixedDragMeshScreenSize: boolean;
  105663. /**
  105664. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105665. */
  105666. fixedDragMeshScreenSizeDistanceFactor: number;
  105667. /**
  105668. * Fired when a rotation sphere or scale box is dragged
  105669. */
  105670. onDragStartObservable: Observable<{}>;
  105671. /**
  105672. * Fired when a scale box is dragged
  105673. */
  105674. onScaleBoxDragObservable: Observable<{}>;
  105675. /**
  105676. * Fired when a scale box drag is ended
  105677. */
  105678. onScaleBoxDragEndObservable: Observable<{}>;
  105679. /**
  105680. * Fired when a rotation sphere is dragged
  105681. */
  105682. onRotationSphereDragObservable: Observable<{}>;
  105683. /**
  105684. * Fired when a rotation sphere drag is ended
  105685. */
  105686. onRotationSphereDragEndObservable: Observable<{}>;
  105687. /**
  105688. * 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)
  105689. */
  105690. scalePivot: Nullable<Vector3>;
  105691. /**
  105692. * Mesh used as a pivot to rotate the attached mesh
  105693. */
  105694. private _anchorMesh;
  105695. private _existingMeshScale;
  105696. private _dragMesh;
  105697. private pointerDragBehavior;
  105698. private coloredMaterial;
  105699. private hoverColoredMaterial;
  105700. /**
  105701. * Sets the color of the bounding box gizmo
  105702. * @param color the color to set
  105703. */
  105704. setColor(color: Color3): void;
  105705. /**
  105706. * Creates an BoundingBoxGizmo
  105707. * @param gizmoLayer The utility layer the gizmo will be added to
  105708. * @param color The color of the gizmo
  105709. */
  105710. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  105711. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105712. private _selectNode;
  105713. /**
  105714. * Updates the bounding box information for the Gizmo
  105715. */
  105716. updateBoundingBox(): void;
  105717. private _updateRotationSpheres;
  105718. private _updateScaleBoxes;
  105719. /**
  105720. * Enables rotation on the specified axis and disables rotation on the others
  105721. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  105722. */
  105723. setEnabledRotationAxis(axis: string): void;
  105724. /**
  105725. * Enables/disables scaling
  105726. * @param enable if scaling should be enabled
  105727. */
  105728. setEnabledScaling(enable: boolean): void;
  105729. private _updateDummy;
  105730. /**
  105731. * Enables a pointer drag behavior on the bounding box of the gizmo
  105732. */
  105733. enableDragBehavior(): void;
  105734. /**
  105735. * Disposes of the gizmo
  105736. */
  105737. dispose(): void;
  105738. /**
  105739. * 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)
  105740. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  105741. * @returns the bounding box mesh with the passed in mesh as a child
  105742. */
  105743. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  105744. /**
  105745. * CustomMeshes are not supported by this gizmo
  105746. * @param mesh The mesh to replace the default mesh of the gizmo
  105747. */
  105748. setCustomMesh(mesh: Mesh): void;
  105749. }
  105750. }
  105751. declare module BABYLON {
  105752. /**
  105753. * Single plane rotation gizmo
  105754. */
  105755. export class PlaneRotationGizmo extends Gizmo {
  105756. /**
  105757. * Drag behavior responsible for the gizmos dragging interactions
  105758. */
  105759. dragBehavior: PointerDragBehavior;
  105760. private _pointerObserver;
  105761. /**
  105762. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  105763. */
  105764. snapDistance: number;
  105765. /**
  105766. * Event that fires each time the gizmo snaps to a new location.
  105767. * * snapDistance is the the change in distance
  105768. */
  105769. onSnapObservable: Observable<{
  105770. snapDistance: number;
  105771. }>;
  105772. private _isEnabled;
  105773. private _parent;
  105774. /**
  105775. * Creates a PlaneRotationGizmo
  105776. * @param gizmoLayer The utility layer the gizmo will be added to
  105777. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  105778. * @param color The color of the gizmo
  105779. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105780. */
  105781. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  105782. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105783. /**
  105784. * If the gizmo is enabled
  105785. */
  105786. isEnabled: boolean;
  105787. /**
  105788. * Disposes of the gizmo
  105789. */
  105790. dispose(): void;
  105791. }
  105792. }
  105793. declare module BABYLON {
  105794. /**
  105795. * Gizmo that enables rotating a mesh along 3 axis
  105796. */
  105797. export class RotationGizmo extends Gizmo {
  105798. /**
  105799. * Internal gizmo used for interactions on the x axis
  105800. */
  105801. xGizmo: PlaneRotationGizmo;
  105802. /**
  105803. * Internal gizmo used for interactions on the y axis
  105804. */
  105805. yGizmo: PlaneRotationGizmo;
  105806. /**
  105807. * Internal gizmo used for interactions on the z axis
  105808. */
  105809. zGizmo: PlaneRotationGizmo;
  105810. /** Fires an event when any of it's sub gizmos are dragged */
  105811. onDragStartObservable: Observable<{}>;
  105812. /** Fires an event when any of it's sub gizmos are released from dragging */
  105813. onDragEndObservable: Observable<{}>;
  105814. private _meshAttached;
  105815. attachedMesh: Nullable<AbstractMesh>;
  105816. /**
  105817. * Creates a RotationGizmo
  105818. * @param gizmoLayer The utility layer the gizmo will be added to
  105819. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105820. */
  105821. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  105822. updateGizmoRotationToMatchAttachedMesh: boolean;
  105823. /**
  105824. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105825. */
  105826. snapDistance: number;
  105827. /**
  105828. * Ratio for the scale of the gizmo (Default: 1)
  105829. */
  105830. scaleRatio: number;
  105831. /**
  105832. * Disposes of the gizmo
  105833. */
  105834. dispose(): void;
  105835. /**
  105836. * CustomMeshes are not supported by this gizmo
  105837. * @param mesh The mesh to replace the default mesh of the gizmo
  105838. */
  105839. setCustomMesh(mesh: Mesh): void;
  105840. }
  105841. }
  105842. declare module BABYLON {
  105843. /**
  105844. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  105845. */
  105846. export class GizmoManager implements IDisposable {
  105847. private scene;
  105848. /**
  105849. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  105850. */
  105851. gizmos: {
  105852. positionGizmo: Nullable<PositionGizmo>;
  105853. rotationGizmo: Nullable<RotationGizmo>;
  105854. scaleGizmo: Nullable<ScaleGizmo>;
  105855. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  105856. };
  105857. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  105858. clearGizmoOnEmptyPointerEvent: boolean;
  105859. /** Fires an event when the manager is attached to a mesh */
  105860. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  105861. private _gizmosEnabled;
  105862. private _pointerObserver;
  105863. private _attachedMesh;
  105864. private _boundingBoxColor;
  105865. private _defaultUtilityLayer;
  105866. private _defaultKeepDepthUtilityLayer;
  105867. /**
  105868. * When bounding box gizmo is enabled, this can be used to track drag/end events
  105869. */
  105870. boundingBoxDragBehavior: SixDofDragBehavior;
  105871. /**
  105872. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  105873. */
  105874. attachableMeshes: Nullable<Array<AbstractMesh>>;
  105875. /**
  105876. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  105877. */
  105878. usePointerToAttachGizmos: boolean;
  105879. /**
  105880. * Utility layer that the bounding box gizmo belongs to
  105881. */
  105882. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  105883. /**
  105884. * Utility layer that all gizmos besides bounding box belong to
  105885. */
  105886. readonly utilityLayer: UtilityLayerRenderer;
  105887. /**
  105888. * Instatiates a gizmo manager
  105889. * @param scene the scene to overlay the gizmos on top of
  105890. */
  105891. constructor(scene: Scene);
  105892. /**
  105893. * Attaches a set of gizmos to the specified mesh
  105894. * @param mesh The mesh the gizmo's should be attached to
  105895. */
  105896. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105897. /**
  105898. * If the position gizmo is enabled
  105899. */
  105900. positionGizmoEnabled: boolean;
  105901. /**
  105902. * If the rotation gizmo is enabled
  105903. */
  105904. rotationGizmoEnabled: boolean;
  105905. /**
  105906. * If the scale gizmo is enabled
  105907. */
  105908. scaleGizmoEnabled: boolean;
  105909. /**
  105910. * If the boundingBox gizmo is enabled
  105911. */
  105912. boundingBoxGizmoEnabled: boolean;
  105913. /**
  105914. * Disposes of the gizmo manager
  105915. */
  105916. dispose(): void;
  105917. }
  105918. }
  105919. declare module BABYLON {
  105920. /**
  105921. * A directional light is defined by a direction (what a surprise!).
  105922. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105923. * 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.
  105924. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105925. */
  105926. export class DirectionalLight extends ShadowLight {
  105927. private _shadowFrustumSize;
  105928. /**
  105929. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105930. */
  105931. /**
  105932. * Specifies a fix frustum size for the shadow generation.
  105933. */
  105934. shadowFrustumSize: number;
  105935. private _shadowOrthoScale;
  105936. /**
  105937. * Gets the shadow projection scale against the optimal computed one.
  105938. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105939. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105940. */
  105941. /**
  105942. * Sets the shadow projection scale against the optimal computed one.
  105943. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105944. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105945. */
  105946. shadowOrthoScale: number;
  105947. /**
  105948. * Automatically compute the projection matrix to best fit (including all the casters)
  105949. * on each frame.
  105950. */
  105951. autoUpdateExtends: boolean;
  105952. private _orthoLeft;
  105953. private _orthoRight;
  105954. private _orthoTop;
  105955. private _orthoBottom;
  105956. /**
  105957. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105958. * The directional light is emitted from everywhere in the given direction.
  105959. * It can cast shadows.
  105960. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105961. * @param name The friendly name of the light
  105962. * @param direction The direction of the light
  105963. * @param scene The scene the light belongs to
  105964. */
  105965. constructor(name: string, direction: Vector3, scene: Scene);
  105966. /**
  105967. * Returns the string "DirectionalLight".
  105968. * @return The class name
  105969. */
  105970. getClassName(): string;
  105971. /**
  105972. * Returns the integer 1.
  105973. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105974. */
  105975. getTypeID(): number;
  105976. /**
  105977. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105978. * Returns the DirectionalLight Shadow projection matrix.
  105979. */
  105980. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105981. /**
  105982. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105983. * Returns the DirectionalLight Shadow projection matrix.
  105984. */
  105985. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105986. /**
  105987. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105988. * Returns the DirectionalLight Shadow projection matrix.
  105989. */
  105990. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105991. protected _buildUniformLayout(): void;
  105992. /**
  105993. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105994. * @param effect The effect to update
  105995. * @param lightIndex The index of the light in the effect to update
  105996. * @returns The directional light
  105997. */
  105998. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105999. /**
  106000. * Gets the minZ used for shadow according to both the scene and the light.
  106001. *
  106002. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106003. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106004. * @param activeCamera The camera we are returning the min for
  106005. * @returns the depth min z
  106006. */
  106007. getDepthMinZ(activeCamera: Camera): number;
  106008. /**
  106009. * Gets the maxZ used for shadow according to both the scene and the light.
  106010. *
  106011. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106012. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106013. * @param activeCamera The camera we are returning the max for
  106014. * @returns the depth max z
  106015. */
  106016. getDepthMaxZ(activeCamera: Camera): number;
  106017. /**
  106018. * Prepares the list of defines specific to the light type.
  106019. * @param defines the list of defines
  106020. * @param lightIndex defines the index of the light for the effect
  106021. */
  106022. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106023. }
  106024. }
  106025. declare module BABYLON {
  106026. /**
  106027. * Class containing static functions to help procedurally build meshes
  106028. */
  106029. export class HemisphereBuilder {
  106030. /**
  106031. * Creates a hemisphere mesh
  106032. * @param name defines the name of the mesh
  106033. * @param options defines the options used to create the mesh
  106034. * @param scene defines the hosting scene
  106035. * @returns the hemisphere mesh
  106036. */
  106037. static CreateHemisphere(name: string, options: {
  106038. segments?: number;
  106039. diameter?: number;
  106040. sideOrientation?: number;
  106041. }, scene: any): Mesh;
  106042. }
  106043. }
  106044. declare module BABYLON {
  106045. /**
  106046. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106047. * These values define a cone of light starting from the position, emitting toward the direction.
  106048. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106049. * and the exponent defines the speed of the decay of the light with distance (reach).
  106050. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106051. */
  106052. export class SpotLight extends ShadowLight {
  106053. private _angle;
  106054. private _innerAngle;
  106055. private _cosHalfAngle;
  106056. private _lightAngleScale;
  106057. private _lightAngleOffset;
  106058. /**
  106059. * Gets the cone angle of the spot light in Radians.
  106060. */
  106061. /**
  106062. * Sets the cone angle of the spot light in Radians.
  106063. */
  106064. angle: number;
  106065. /**
  106066. * Only used in gltf falloff mode, this defines the angle where
  106067. * the directional falloff will start before cutting at angle which could be seen
  106068. * as outer angle.
  106069. */
  106070. /**
  106071. * Only used in gltf falloff mode, this defines the angle where
  106072. * the directional falloff will start before cutting at angle which could be seen
  106073. * as outer angle.
  106074. */
  106075. innerAngle: number;
  106076. private _shadowAngleScale;
  106077. /**
  106078. * Allows scaling the angle of the light for shadow generation only.
  106079. */
  106080. /**
  106081. * Allows scaling the angle of the light for shadow generation only.
  106082. */
  106083. shadowAngleScale: number;
  106084. /**
  106085. * The light decay speed with the distance from the emission spot.
  106086. */
  106087. exponent: number;
  106088. private _projectionTextureMatrix;
  106089. /**
  106090. * Allows reading the projecton texture
  106091. */
  106092. readonly projectionTextureMatrix: Matrix;
  106093. protected _projectionTextureLightNear: number;
  106094. /**
  106095. * Gets the near clip of the Spotlight for texture projection.
  106096. */
  106097. /**
  106098. * Sets the near clip of the Spotlight for texture projection.
  106099. */
  106100. projectionTextureLightNear: number;
  106101. protected _projectionTextureLightFar: number;
  106102. /**
  106103. * Gets the far clip of the Spotlight for texture projection.
  106104. */
  106105. /**
  106106. * Sets the far clip of the Spotlight for texture projection.
  106107. */
  106108. projectionTextureLightFar: number;
  106109. protected _projectionTextureUpDirection: Vector3;
  106110. /**
  106111. * Gets the Up vector of the Spotlight for texture projection.
  106112. */
  106113. /**
  106114. * Sets the Up vector of the Spotlight for texture projection.
  106115. */
  106116. projectionTextureUpDirection: Vector3;
  106117. private _projectionTexture;
  106118. /**
  106119. * Gets the projection texture of the light.
  106120. */
  106121. /**
  106122. * Sets the projection texture of the light.
  106123. */
  106124. projectionTexture: Nullable<BaseTexture>;
  106125. private _projectionTextureViewLightDirty;
  106126. private _projectionTextureProjectionLightDirty;
  106127. private _projectionTextureDirty;
  106128. private _projectionTextureViewTargetVector;
  106129. private _projectionTextureViewLightMatrix;
  106130. private _projectionTextureProjectionLightMatrix;
  106131. private _projectionTextureScalingMatrix;
  106132. /**
  106133. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106134. * It can cast shadows.
  106135. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106136. * @param name The light friendly name
  106137. * @param position The position of the spot light in the scene
  106138. * @param direction The direction of the light in the scene
  106139. * @param angle The cone angle of the light in Radians
  106140. * @param exponent The light decay speed with the distance from the emission spot
  106141. * @param scene The scene the lights belongs to
  106142. */
  106143. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106144. /**
  106145. * Returns the string "SpotLight".
  106146. * @returns the class name
  106147. */
  106148. getClassName(): string;
  106149. /**
  106150. * Returns the integer 2.
  106151. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106152. */
  106153. getTypeID(): number;
  106154. /**
  106155. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106156. */
  106157. protected _setDirection(value: Vector3): void;
  106158. /**
  106159. * Overrides the position setter to recompute the projection texture view light Matrix.
  106160. */
  106161. protected _setPosition(value: Vector3): void;
  106162. /**
  106163. * 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.
  106164. * Returns the SpotLight.
  106165. */
  106166. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106167. protected _computeProjectionTextureViewLightMatrix(): void;
  106168. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106169. /**
  106170. * Main function for light texture projection matrix computing.
  106171. */
  106172. protected _computeProjectionTextureMatrix(): void;
  106173. protected _buildUniformLayout(): void;
  106174. private _computeAngleValues;
  106175. /**
  106176. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106177. * @param effect The effect to update
  106178. * @param lightIndex The index of the light in the effect to update
  106179. * @returns The spot light
  106180. */
  106181. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106182. /**
  106183. * Disposes the light and the associated resources.
  106184. */
  106185. dispose(): void;
  106186. /**
  106187. * Prepares the list of defines specific to the light type.
  106188. * @param defines the list of defines
  106189. * @param lightIndex defines the index of the light for the effect
  106190. */
  106191. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106192. }
  106193. }
  106194. declare module BABYLON {
  106195. /**
  106196. * Gizmo that enables viewing a light
  106197. */
  106198. export class LightGizmo extends Gizmo {
  106199. private _lightMesh;
  106200. private _material;
  106201. private cachedPosition;
  106202. private cachedForward;
  106203. /**
  106204. * Creates a LightGizmo
  106205. * @param gizmoLayer The utility layer the gizmo will be added to
  106206. */
  106207. constructor(gizmoLayer?: UtilityLayerRenderer);
  106208. private _light;
  106209. /**
  106210. * The light that the gizmo is attached to
  106211. */
  106212. light: Nullable<Light>;
  106213. /**
  106214. * @hidden
  106215. * Updates the gizmo to match the attached mesh's position/rotation
  106216. */
  106217. protected _update(): void;
  106218. private static _Scale;
  106219. /**
  106220. * Creates the lines for a light mesh
  106221. */
  106222. private static _createLightLines;
  106223. /**
  106224. * Disposes of the light gizmo
  106225. */
  106226. dispose(): void;
  106227. private static _CreateHemisphericLightMesh;
  106228. private static _CreatePointLightMesh;
  106229. private static _CreateSpotLightMesh;
  106230. private static _CreateDirectionalLightMesh;
  106231. }
  106232. }
  106233. declare module BABYLON {
  106234. /** @hidden */
  106235. export var backgroundFragmentDeclaration: {
  106236. name: string;
  106237. shader: string;
  106238. };
  106239. }
  106240. declare module BABYLON {
  106241. /** @hidden */
  106242. export var backgroundUboDeclaration: {
  106243. name: string;
  106244. shader: string;
  106245. };
  106246. }
  106247. declare module BABYLON {
  106248. /** @hidden */
  106249. export var backgroundPixelShader: {
  106250. name: string;
  106251. shader: string;
  106252. };
  106253. }
  106254. declare module BABYLON {
  106255. /** @hidden */
  106256. export var backgroundVertexDeclaration: {
  106257. name: string;
  106258. shader: string;
  106259. };
  106260. }
  106261. declare module BABYLON {
  106262. /** @hidden */
  106263. export var backgroundVertexShader: {
  106264. name: string;
  106265. shader: string;
  106266. };
  106267. }
  106268. declare module BABYLON {
  106269. /**
  106270. * Background material used to create an efficient environement around your scene.
  106271. */
  106272. export class BackgroundMaterial extends PushMaterial {
  106273. /**
  106274. * Standard reflectance value at parallel view angle.
  106275. */
  106276. static StandardReflectance0: number;
  106277. /**
  106278. * Standard reflectance value at grazing angle.
  106279. */
  106280. static StandardReflectance90: number;
  106281. protected _primaryColor: Color3;
  106282. /**
  106283. * Key light Color (multiply against the environement texture)
  106284. */
  106285. primaryColor: Color3;
  106286. protected __perceptualColor: Nullable<Color3>;
  106287. /**
  106288. * Experimental Internal Use Only.
  106289. *
  106290. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106291. * This acts as a helper to set the primary color to a more "human friendly" value.
  106292. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106293. * output color as close as possible from the chosen value.
  106294. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106295. * part of lighting setup.)
  106296. */
  106297. _perceptualColor: Nullable<Color3>;
  106298. protected _primaryColorShadowLevel: float;
  106299. /**
  106300. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106301. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106302. */
  106303. primaryColorShadowLevel: float;
  106304. protected _primaryColorHighlightLevel: float;
  106305. /**
  106306. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106307. * The primary color is used at the level chosen to define what the white area would look.
  106308. */
  106309. primaryColorHighlightLevel: float;
  106310. protected _reflectionTexture: Nullable<BaseTexture>;
  106311. /**
  106312. * Reflection Texture used in the material.
  106313. * Should be author in a specific way for the best result (refer to the documentation).
  106314. */
  106315. reflectionTexture: Nullable<BaseTexture>;
  106316. protected _reflectionBlur: float;
  106317. /**
  106318. * Reflection Texture level of blur.
  106319. *
  106320. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106321. * texture twice.
  106322. */
  106323. reflectionBlur: float;
  106324. protected _diffuseTexture: Nullable<BaseTexture>;
  106325. /**
  106326. * Diffuse Texture used in the material.
  106327. * Should be author in a specific way for the best result (refer to the documentation).
  106328. */
  106329. diffuseTexture: Nullable<BaseTexture>;
  106330. protected _shadowLights: Nullable<IShadowLight[]>;
  106331. /**
  106332. * Specify the list of lights casting shadow on the material.
  106333. * All scene shadow lights will be included if null.
  106334. */
  106335. shadowLights: Nullable<IShadowLight[]>;
  106336. protected _shadowLevel: float;
  106337. /**
  106338. * Helps adjusting the shadow to a softer level if required.
  106339. * 0 means black shadows and 1 means no shadows.
  106340. */
  106341. shadowLevel: float;
  106342. protected _sceneCenter: Vector3;
  106343. /**
  106344. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106345. * It is usually zero but might be interesting to modify according to your setup.
  106346. */
  106347. sceneCenter: Vector3;
  106348. protected _opacityFresnel: boolean;
  106349. /**
  106350. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106351. * This helps ensuring a nice transition when the camera goes under the ground.
  106352. */
  106353. opacityFresnel: boolean;
  106354. protected _reflectionFresnel: boolean;
  106355. /**
  106356. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106357. * This helps adding a mirror texture on the ground.
  106358. */
  106359. reflectionFresnel: boolean;
  106360. protected _reflectionFalloffDistance: number;
  106361. /**
  106362. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106363. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106364. */
  106365. reflectionFalloffDistance: number;
  106366. protected _reflectionAmount: number;
  106367. /**
  106368. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106369. */
  106370. reflectionAmount: number;
  106371. protected _reflectionReflectance0: number;
  106372. /**
  106373. * This specifies the weight of the reflection at grazing angle.
  106374. */
  106375. reflectionReflectance0: number;
  106376. protected _reflectionReflectance90: number;
  106377. /**
  106378. * This specifies the weight of the reflection at a perpendicular point of view.
  106379. */
  106380. reflectionReflectance90: number;
  106381. /**
  106382. * Sets the reflection reflectance fresnel values according to the default standard
  106383. * empirically know to work well :-)
  106384. */
  106385. reflectionStandardFresnelWeight: number;
  106386. protected _useRGBColor: boolean;
  106387. /**
  106388. * Helps to directly use the maps channels instead of their level.
  106389. */
  106390. useRGBColor: boolean;
  106391. protected _enableNoise: boolean;
  106392. /**
  106393. * This helps reducing the banding effect that could occur on the background.
  106394. */
  106395. enableNoise: boolean;
  106396. /**
  106397. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106398. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106399. * Recommended to be keep at 1.0 except for special cases.
  106400. */
  106401. fovMultiplier: number;
  106402. private _fovMultiplier;
  106403. /**
  106404. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106405. */
  106406. useEquirectangularFOV: boolean;
  106407. private _maxSimultaneousLights;
  106408. /**
  106409. * Number of Simultaneous lights allowed on the material.
  106410. */
  106411. maxSimultaneousLights: int;
  106412. /**
  106413. * Default configuration related to image processing available in the Background Material.
  106414. */
  106415. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106416. /**
  106417. * Keep track of the image processing observer to allow dispose and replace.
  106418. */
  106419. private _imageProcessingObserver;
  106420. /**
  106421. * Attaches a new image processing configuration to the PBR Material.
  106422. * @param configuration (if null the scene configuration will be use)
  106423. */
  106424. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106425. /**
  106426. * Gets the image processing configuration used either in this material.
  106427. */
  106428. /**
  106429. * Sets the Default image processing configuration used either in the this material.
  106430. *
  106431. * If sets to null, the scene one is in use.
  106432. */
  106433. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106434. /**
  106435. * Gets wether the color curves effect is enabled.
  106436. */
  106437. /**
  106438. * Sets wether the color curves effect is enabled.
  106439. */
  106440. cameraColorCurvesEnabled: boolean;
  106441. /**
  106442. * Gets wether the color grading effect is enabled.
  106443. */
  106444. /**
  106445. * Gets wether the color grading effect is enabled.
  106446. */
  106447. cameraColorGradingEnabled: boolean;
  106448. /**
  106449. * Gets wether tonemapping is enabled or not.
  106450. */
  106451. /**
  106452. * Sets wether tonemapping is enabled or not
  106453. */
  106454. cameraToneMappingEnabled: boolean;
  106455. /**
  106456. * The camera exposure used on this material.
  106457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106458. * This corresponds to a photographic exposure.
  106459. */
  106460. /**
  106461. * The camera exposure used on this material.
  106462. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106463. * This corresponds to a photographic exposure.
  106464. */
  106465. cameraExposure: float;
  106466. /**
  106467. * Gets The camera contrast used on this material.
  106468. */
  106469. /**
  106470. * Sets The camera contrast used on this material.
  106471. */
  106472. cameraContrast: float;
  106473. /**
  106474. * Gets the Color Grading 2D Lookup Texture.
  106475. */
  106476. /**
  106477. * Sets the Color Grading 2D Lookup Texture.
  106478. */
  106479. cameraColorGradingTexture: Nullable<BaseTexture>;
  106480. /**
  106481. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106482. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106483. * 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;
  106484. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106485. */
  106486. /**
  106487. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106488. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106489. * 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;
  106490. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106491. */
  106492. cameraColorCurves: Nullable<ColorCurves>;
  106493. /**
  106494. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106495. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106496. */
  106497. switchToBGR: boolean;
  106498. private _renderTargets;
  106499. private _reflectionControls;
  106500. private _white;
  106501. private _primaryShadowColor;
  106502. private _primaryHighlightColor;
  106503. /**
  106504. * Instantiates a Background Material in the given scene
  106505. * @param name The friendly name of the material
  106506. * @param scene The scene to add the material to
  106507. */
  106508. constructor(name: string, scene: Scene);
  106509. /**
  106510. * Gets a boolean indicating that current material needs to register RTT
  106511. */
  106512. readonly hasRenderTargetTextures: boolean;
  106513. /**
  106514. * The entire material has been created in order to prevent overdraw.
  106515. * @returns false
  106516. */
  106517. needAlphaTesting(): boolean;
  106518. /**
  106519. * The entire material has been created in order to prevent overdraw.
  106520. * @returns true if blending is enable
  106521. */
  106522. needAlphaBlending(): boolean;
  106523. /**
  106524. * Checks wether the material is ready to be rendered for a given mesh.
  106525. * @param mesh The mesh to render
  106526. * @param subMesh The submesh to check against
  106527. * @param useInstances Specify wether or not the material is used with instances
  106528. * @returns true if all the dependencies are ready (Textures, Effects...)
  106529. */
  106530. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106531. /**
  106532. * Compute the primary color according to the chosen perceptual color.
  106533. */
  106534. private _computePrimaryColorFromPerceptualColor;
  106535. /**
  106536. * Compute the highlights and shadow colors according to their chosen levels.
  106537. */
  106538. private _computePrimaryColors;
  106539. /**
  106540. * Build the uniform buffer used in the material.
  106541. */
  106542. buildUniformLayout(): void;
  106543. /**
  106544. * Unbind the material.
  106545. */
  106546. unbind(): void;
  106547. /**
  106548. * Bind only the world matrix to the material.
  106549. * @param world The world matrix to bind.
  106550. */
  106551. bindOnlyWorldMatrix(world: Matrix): void;
  106552. /**
  106553. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106554. * @param world The world matrix to bind.
  106555. * @param subMesh The submesh to bind for.
  106556. */
  106557. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106558. /**
  106559. * Dispose the material.
  106560. * @param forceDisposeEffect Force disposal of the associated effect.
  106561. * @param forceDisposeTextures Force disposal of the associated textures.
  106562. */
  106563. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106564. /**
  106565. * Clones the material.
  106566. * @param name The cloned name.
  106567. * @returns The cloned material.
  106568. */
  106569. clone(name: string): BackgroundMaterial;
  106570. /**
  106571. * Serializes the current material to its JSON representation.
  106572. * @returns The JSON representation.
  106573. */
  106574. serialize(): any;
  106575. /**
  106576. * Gets the class name of the material
  106577. * @returns "BackgroundMaterial"
  106578. */
  106579. getClassName(): string;
  106580. /**
  106581. * Parse a JSON input to create back a background material.
  106582. * @param source The JSON data to parse
  106583. * @param scene The scene to create the parsed material in
  106584. * @param rootUrl The root url of the assets the material depends upon
  106585. * @returns the instantiated BackgroundMaterial.
  106586. */
  106587. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106588. }
  106589. }
  106590. declare module BABYLON {
  106591. /**
  106592. * Represents the different options available during the creation of
  106593. * a Environment helper.
  106594. *
  106595. * This can control the default ground, skybox and image processing setup of your scene.
  106596. */
  106597. export interface IEnvironmentHelperOptions {
  106598. /**
  106599. * Specifies wether or not to create a ground.
  106600. * True by default.
  106601. */
  106602. createGround: boolean;
  106603. /**
  106604. * Specifies the ground size.
  106605. * 15 by default.
  106606. */
  106607. groundSize: number;
  106608. /**
  106609. * The texture used on the ground for the main color.
  106610. * Comes from the BabylonJS CDN by default.
  106611. *
  106612. * Remarks: Can be either a texture or a url.
  106613. */
  106614. groundTexture: string | BaseTexture;
  106615. /**
  106616. * The color mixed in the ground texture by default.
  106617. * BabylonJS clearColor by default.
  106618. */
  106619. groundColor: Color3;
  106620. /**
  106621. * Specifies the ground opacity.
  106622. * 1 by default.
  106623. */
  106624. groundOpacity: number;
  106625. /**
  106626. * Enables the ground to receive shadows.
  106627. * True by default.
  106628. */
  106629. enableGroundShadow: boolean;
  106630. /**
  106631. * Helps preventing the shadow to be fully black on the ground.
  106632. * 0.5 by default.
  106633. */
  106634. groundShadowLevel: number;
  106635. /**
  106636. * Creates a mirror texture attach to the ground.
  106637. * false by default.
  106638. */
  106639. enableGroundMirror: boolean;
  106640. /**
  106641. * Specifies the ground mirror size ratio.
  106642. * 0.3 by default as the default kernel is 64.
  106643. */
  106644. groundMirrorSizeRatio: number;
  106645. /**
  106646. * Specifies the ground mirror blur kernel size.
  106647. * 64 by default.
  106648. */
  106649. groundMirrorBlurKernel: number;
  106650. /**
  106651. * Specifies the ground mirror visibility amount.
  106652. * 1 by default
  106653. */
  106654. groundMirrorAmount: number;
  106655. /**
  106656. * Specifies the ground mirror reflectance weight.
  106657. * This uses the standard weight of the background material to setup the fresnel effect
  106658. * of the mirror.
  106659. * 1 by default.
  106660. */
  106661. groundMirrorFresnelWeight: number;
  106662. /**
  106663. * Specifies the ground mirror Falloff distance.
  106664. * This can helps reducing the size of the reflection.
  106665. * 0 by Default.
  106666. */
  106667. groundMirrorFallOffDistance: number;
  106668. /**
  106669. * Specifies the ground mirror texture type.
  106670. * Unsigned Int by Default.
  106671. */
  106672. groundMirrorTextureType: number;
  106673. /**
  106674. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  106675. * the shown objects.
  106676. */
  106677. groundYBias: number;
  106678. /**
  106679. * Specifies wether or not to create a skybox.
  106680. * True by default.
  106681. */
  106682. createSkybox: boolean;
  106683. /**
  106684. * Specifies the skybox size.
  106685. * 20 by default.
  106686. */
  106687. skyboxSize: number;
  106688. /**
  106689. * The texture used on the skybox for the main color.
  106690. * Comes from the BabylonJS CDN by default.
  106691. *
  106692. * Remarks: Can be either a texture or a url.
  106693. */
  106694. skyboxTexture: string | BaseTexture;
  106695. /**
  106696. * The color mixed in the skybox texture by default.
  106697. * BabylonJS clearColor by default.
  106698. */
  106699. skyboxColor: Color3;
  106700. /**
  106701. * The background rotation around the Y axis of the scene.
  106702. * This helps aligning the key lights of your scene with the background.
  106703. * 0 by default.
  106704. */
  106705. backgroundYRotation: number;
  106706. /**
  106707. * Compute automatically the size of the elements to best fit with the scene.
  106708. */
  106709. sizeAuto: boolean;
  106710. /**
  106711. * Default position of the rootMesh if autoSize is not true.
  106712. */
  106713. rootPosition: Vector3;
  106714. /**
  106715. * Sets up the image processing in the scene.
  106716. * true by default.
  106717. */
  106718. setupImageProcessing: boolean;
  106719. /**
  106720. * The texture used as your environment texture in the scene.
  106721. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  106722. *
  106723. * Remarks: Can be either a texture or a url.
  106724. */
  106725. environmentTexture: string | BaseTexture;
  106726. /**
  106727. * The value of the exposure to apply to the scene.
  106728. * 0.6 by default if setupImageProcessing is true.
  106729. */
  106730. cameraExposure: number;
  106731. /**
  106732. * The value of the contrast to apply to the scene.
  106733. * 1.6 by default if setupImageProcessing is true.
  106734. */
  106735. cameraContrast: number;
  106736. /**
  106737. * Specifies wether or not tonemapping should be enabled in the scene.
  106738. * true by default if setupImageProcessing is true.
  106739. */
  106740. toneMappingEnabled: boolean;
  106741. }
  106742. /**
  106743. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  106744. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  106745. * It also helps with the default setup of your imageProcessing configuration.
  106746. */
  106747. export class EnvironmentHelper {
  106748. /**
  106749. * Default ground texture URL.
  106750. */
  106751. private static _groundTextureCDNUrl;
  106752. /**
  106753. * Default skybox texture URL.
  106754. */
  106755. private static _skyboxTextureCDNUrl;
  106756. /**
  106757. * Default environment texture URL.
  106758. */
  106759. private static _environmentTextureCDNUrl;
  106760. /**
  106761. * Creates the default options for the helper.
  106762. */
  106763. private static _getDefaultOptions;
  106764. private _rootMesh;
  106765. /**
  106766. * Gets the root mesh created by the helper.
  106767. */
  106768. readonly rootMesh: Mesh;
  106769. private _skybox;
  106770. /**
  106771. * Gets the skybox created by the helper.
  106772. */
  106773. readonly skybox: Nullable<Mesh>;
  106774. private _skyboxTexture;
  106775. /**
  106776. * Gets the skybox texture created by the helper.
  106777. */
  106778. readonly skyboxTexture: Nullable<BaseTexture>;
  106779. private _skyboxMaterial;
  106780. /**
  106781. * Gets the skybox material created by the helper.
  106782. */
  106783. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  106784. private _ground;
  106785. /**
  106786. * Gets the ground mesh created by the helper.
  106787. */
  106788. readonly ground: Nullable<Mesh>;
  106789. private _groundTexture;
  106790. /**
  106791. * Gets the ground texture created by the helper.
  106792. */
  106793. readonly groundTexture: Nullable<BaseTexture>;
  106794. private _groundMirror;
  106795. /**
  106796. * Gets the ground mirror created by the helper.
  106797. */
  106798. readonly groundMirror: Nullable<MirrorTexture>;
  106799. /**
  106800. * Gets the ground mirror render list to helps pushing the meshes
  106801. * you wish in the ground reflection.
  106802. */
  106803. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  106804. private _groundMaterial;
  106805. /**
  106806. * Gets the ground material created by the helper.
  106807. */
  106808. readonly groundMaterial: Nullable<BackgroundMaterial>;
  106809. /**
  106810. * Stores the creation options.
  106811. */
  106812. private readonly _scene;
  106813. private _options;
  106814. /**
  106815. * This observable will be notified with any error during the creation of the environment,
  106816. * mainly texture creation errors.
  106817. */
  106818. onErrorObservable: Observable<{
  106819. message?: string;
  106820. exception?: any;
  106821. }>;
  106822. /**
  106823. * constructor
  106824. * @param options Defines the options we want to customize the helper
  106825. * @param scene The scene to add the material to
  106826. */
  106827. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  106828. /**
  106829. * Updates the background according to the new options
  106830. * @param options
  106831. */
  106832. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  106833. /**
  106834. * Sets the primary color of all the available elements.
  106835. * @param color the main color to affect to the ground and the background
  106836. */
  106837. setMainColor(color: Color3): void;
  106838. /**
  106839. * Setup the image processing according to the specified options.
  106840. */
  106841. private _setupImageProcessing;
  106842. /**
  106843. * Setup the environment texture according to the specified options.
  106844. */
  106845. private _setupEnvironmentTexture;
  106846. /**
  106847. * Setup the background according to the specified options.
  106848. */
  106849. private _setupBackground;
  106850. /**
  106851. * Get the scene sizes according to the setup.
  106852. */
  106853. private _getSceneSize;
  106854. /**
  106855. * Setup the ground according to the specified options.
  106856. */
  106857. private _setupGround;
  106858. /**
  106859. * Setup the ground material according to the specified options.
  106860. */
  106861. private _setupGroundMaterial;
  106862. /**
  106863. * Setup the ground diffuse texture according to the specified options.
  106864. */
  106865. private _setupGroundDiffuseTexture;
  106866. /**
  106867. * Setup the ground mirror texture according to the specified options.
  106868. */
  106869. private _setupGroundMirrorTexture;
  106870. /**
  106871. * Setup the ground to receive the mirror texture.
  106872. */
  106873. private _setupMirrorInGroundMaterial;
  106874. /**
  106875. * Setup the skybox according to the specified options.
  106876. */
  106877. private _setupSkybox;
  106878. /**
  106879. * Setup the skybox material according to the specified options.
  106880. */
  106881. private _setupSkyboxMaterial;
  106882. /**
  106883. * Setup the skybox reflection texture according to the specified options.
  106884. */
  106885. private _setupSkyboxReflectionTexture;
  106886. private _errorHandler;
  106887. /**
  106888. * Dispose all the elements created by the Helper.
  106889. */
  106890. dispose(): void;
  106891. }
  106892. }
  106893. declare module BABYLON {
  106894. /**
  106895. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  106896. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  106897. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  106898. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106899. */
  106900. export class PhotoDome extends TransformNode {
  106901. /**
  106902. * Define the image as a Monoscopic panoramic 360 image.
  106903. */
  106904. static readonly MODE_MONOSCOPIC: number;
  106905. /**
  106906. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106907. */
  106908. static readonly MODE_TOPBOTTOM: number;
  106909. /**
  106910. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106911. */
  106912. static readonly MODE_SIDEBYSIDE: number;
  106913. private _useDirectMapping;
  106914. /**
  106915. * The texture being displayed on the sphere
  106916. */
  106917. protected _photoTexture: Texture;
  106918. /**
  106919. * Gets or sets the texture being displayed on the sphere
  106920. */
  106921. photoTexture: Texture;
  106922. /**
  106923. * Observable raised when an error occured while loading the 360 image
  106924. */
  106925. onLoadErrorObservable: Observable<string>;
  106926. /**
  106927. * The skybox material
  106928. */
  106929. protected _material: BackgroundMaterial;
  106930. /**
  106931. * The surface used for the skybox
  106932. */
  106933. protected _mesh: Mesh;
  106934. /**
  106935. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106936. * Also see the options.resolution property.
  106937. */
  106938. fovMultiplier: number;
  106939. private _imageMode;
  106940. /**
  106941. * Gets or set the current video mode for the video. It can be:
  106942. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  106943. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106944. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106945. */
  106946. imageMode: number;
  106947. /**
  106948. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  106949. * @param name Element's name, child elements will append suffixes for their own names.
  106950. * @param urlsOfPhoto defines the url of the photo to display
  106951. * @param options defines an object containing optional or exposed sub element properties
  106952. * @param onError defines a callback called when an error occured while loading the texture
  106953. */
  106954. constructor(name: string, urlOfPhoto: string, options: {
  106955. resolution?: number;
  106956. size?: number;
  106957. useDirectMapping?: boolean;
  106958. faceForward?: boolean;
  106959. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  106960. private _onBeforeCameraRenderObserver;
  106961. private _changeImageMode;
  106962. /**
  106963. * Releases resources associated with this node.
  106964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106966. */
  106967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106968. }
  106969. }
  106970. declare module BABYLON {
  106971. /** @hidden */
  106972. export var rgbdDecodePixelShader: {
  106973. name: string;
  106974. shader: string;
  106975. };
  106976. }
  106977. declare module BABYLON {
  106978. /**
  106979. * Class used to host texture specific utilities
  106980. */
  106981. export class BRDFTextureTools {
  106982. /**
  106983. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  106984. * @param texture the texture to expand.
  106985. */
  106986. private static _ExpandDefaultBRDFTexture;
  106987. /**
  106988. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  106989. * @param scene defines the hosting scene
  106990. * @returns the environment BRDF texture
  106991. */
  106992. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  106993. private static _environmentBRDFBase64Texture;
  106994. }
  106995. }
  106996. declare module BABYLON {
  106997. /**
  106998. * @hidden
  106999. */
  107000. export interface IMaterialClearCoatDefines {
  107001. CLEARCOAT: boolean;
  107002. CLEARCOAT_DEFAULTIOR: boolean;
  107003. CLEARCOAT_TEXTURE: boolean;
  107004. CLEARCOAT_TEXTUREDIRECTUV: number;
  107005. CLEARCOAT_BUMP: boolean;
  107006. CLEARCOAT_BUMPDIRECTUV: number;
  107007. CLEARCOAT_TINT: boolean;
  107008. CLEARCOAT_TINT_TEXTURE: boolean;
  107009. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107010. /** @hidden */
  107011. _areTexturesDirty: boolean;
  107012. }
  107013. /**
  107014. * Define the code related to the clear coat parameters of the pbr material.
  107015. */
  107016. export class PBRClearCoatConfiguration {
  107017. /**
  107018. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107019. * The default fits with a polyurethane material.
  107020. */
  107021. private static readonly _DefaultIndexOfRefraction;
  107022. private _isEnabled;
  107023. /**
  107024. * Defines if the clear coat is enabled in the material.
  107025. */
  107026. isEnabled: boolean;
  107027. /**
  107028. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107029. */
  107030. intensity: number;
  107031. /**
  107032. * Defines the clear coat layer roughness.
  107033. */
  107034. roughness: number;
  107035. private _indexOfRefraction;
  107036. /**
  107037. * Defines the index of refraction of the clear coat.
  107038. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107039. * The default fits with a polyurethane material.
  107040. * Changing the default value is more performance intensive.
  107041. */
  107042. indexOfRefraction: number;
  107043. private _texture;
  107044. /**
  107045. * Stores the clear coat values in a texture.
  107046. */
  107047. texture: Nullable<BaseTexture>;
  107048. private _bumpTexture;
  107049. /**
  107050. * Define the clear coat specific bump texture.
  107051. */
  107052. bumpTexture: Nullable<BaseTexture>;
  107053. private _isTintEnabled;
  107054. /**
  107055. * Defines if the clear coat tint is enabled in the material.
  107056. */
  107057. isTintEnabled: boolean;
  107058. /**
  107059. * Defines the clear coat tint of the material.
  107060. * This is only use if tint is enabled
  107061. */
  107062. tintColor: Color3;
  107063. /**
  107064. * Defines the distance at which the tint color should be found in the
  107065. * clear coat media.
  107066. * This is only use if tint is enabled
  107067. */
  107068. tintColorAtDistance: number;
  107069. /**
  107070. * Defines the clear coat layer thickness.
  107071. * This is only use if tint is enabled
  107072. */
  107073. tintThickness: number;
  107074. private _tintTexture;
  107075. /**
  107076. * Stores the clear tint values in a texture.
  107077. * rgb is tint
  107078. * a is a thickness factor
  107079. */
  107080. tintTexture: Nullable<BaseTexture>;
  107081. /** @hidden */
  107082. private _internalMarkAllSubMeshesAsTexturesDirty;
  107083. /** @hidden */
  107084. _markAllSubMeshesAsTexturesDirty(): void;
  107085. /**
  107086. * Instantiate a new istance of clear coat configuration.
  107087. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107088. */
  107089. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107090. /**
  107091. * Gets wehter the submesh is ready to be used or not.
  107092. * @param defines the list of "defines" to update.
  107093. * @param scene defines the scene the material belongs to.
  107094. * @param engine defines the engine the material belongs to.
  107095. * @param disableBumpMap defines wether the material disables bump or not.
  107096. * @returns - boolean indicating that the submesh is ready or not.
  107097. */
  107098. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107099. /**
  107100. * Checks to see if a texture is used in the material.
  107101. * @param defines the list of "defines" to update.
  107102. * @param scene defines the scene to the material belongs to.
  107103. */
  107104. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107105. /**
  107106. * Binds the material data.
  107107. * @param uniformBuffer defines the Uniform buffer to fill in.
  107108. * @param scene defines the scene the material belongs to.
  107109. * @param engine defines the engine the material belongs to.
  107110. * @param disableBumpMap defines wether the material disables bump or not.
  107111. * @param isFrozen defines wether the material is frozen or not.
  107112. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107113. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107114. */
  107115. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107116. /**
  107117. * Checks to see if a texture is used in the material.
  107118. * @param texture - Base texture to use.
  107119. * @returns - Boolean specifying if a texture is used in the material.
  107120. */
  107121. hasTexture(texture: BaseTexture): boolean;
  107122. /**
  107123. * Returns an array of the actively used textures.
  107124. * @param activeTextures Array of BaseTextures
  107125. */
  107126. getActiveTextures(activeTextures: BaseTexture[]): void;
  107127. /**
  107128. * Returns the animatable textures.
  107129. * @param animatables Array of animatable textures.
  107130. */
  107131. getAnimatables(animatables: IAnimatable[]): void;
  107132. /**
  107133. * Disposes the resources of the material.
  107134. * @param forceDisposeTextures - Forces the disposal of all textures.
  107135. */
  107136. dispose(forceDisposeTextures?: boolean): void;
  107137. /**
  107138. * Get the current class name of the texture useful for serialization or dynamic coding.
  107139. * @returns "PBRClearCoatConfiguration"
  107140. */
  107141. getClassName(): string;
  107142. /**
  107143. * Add fallbacks to the effect fallbacks list.
  107144. * @param defines defines the Base texture to use.
  107145. * @param fallbacks defines the current fallback list.
  107146. * @param currentRank defines the current fallback rank.
  107147. * @returns the new fallback rank.
  107148. */
  107149. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107150. /**
  107151. * Add the required uniforms to the current list.
  107152. * @param uniforms defines the current uniform list.
  107153. */
  107154. static AddUniforms(uniforms: string[]): void;
  107155. /**
  107156. * Add the required samplers to the current list.
  107157. * @param samplers defines the current sampler list.
  107158. */
  107159. static AddSamplers(samplers: string[]): void;
  107160. /**
  107161. * Add the required uniforms to the current buffer.
  107162. * @param uniformBuffer defines the current uniform buffer.
  107163. */
  107164. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107165. /**
  107166. * Makes a duplicate of the current configuration into another one.
  107167. * @param clearCoatConfiguration define the config where to copy the info
  107168. */
  107169. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107170. /**
  107171. * Serializes this clear coat configuration.
  107172. * @returns - An object with the serialized config.
  107173. */
  107174. serialize(): any;
  107175. /**
  107176. * Parses a Clear Coat Configuration from a serialized object.
  107177. * @param source - Serialized object.
  107178. */
  107179. parse(source: any): void;
  107180. }
  107181. }
  107182. declare module BABYLON {
  107183. /**
  107184. * @hidden
  107185. */
  107186. export interface IMaterialAnisotropicDefines {
  107187. ANISOTROPIC: boolean;
  107188. ANISOTROPIC_TEXTURE: boolean;
  107189. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107190. MAINUV1: boolean;
  107191. _areTexturesDirty: boolean;
  107192. _needUVs: boolean;
  107193. }
  107194. /**
  107195. * Define the code related to the anisotropic parameters of the pbr material.
  107196. */
  107197. export class PBRAnisotropicConfiguration {
  107198. private _isEnabled;
  107199. /**
  107200. * Defines if the anisotropy is enabled in the material.
  107201. */
  107202. isEnabled: boolean;
  107203. /**
  107204. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107205. */
  107206. intensity: number;
  107207. /**
  107208. * Defines if the effect is along the tangents, bitangents or in between.
  107209. * By default, the effect is "strectching" the highlights along the tangents.
  107210. */
  107211. direction: Vector2;
  107212. private _texture;
  107213. /**
  107214. * Stores the anisotropy values in a texture.
  107215. * rg is direction (like normal from -1 to 1)
  107216. * b is a intensity
  107217. */
  107218. texture: Nullable<BaseTexture>;
  107219. /** @hidden */
  107220. private _internalMarkAllSubMeshesAsTexturesDirty;
  107221. /** @hidden */
  107222. _markAllSubMeshesAsTexturesDirty(): void;
  107223. /**
  107224. * Instantiate a new istance of anisotropy configuration.
  107225. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107226. */
  107227. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107228. /**
  107229. * Specifies that the submesh is ready to be used.
  107230. * @param defines the list of "defines" to update.
  107231. * @param scene defines the scene the material belongs to.
  107232. * @returns - boolean indicating that the submesh is ready or not.
  107233. */
  107234. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107235. /**
  107236. * Checks to see if a texture is used in the material.
  107237. * @param defines the list of "defines" to update.
  107238. * @param mesh the mesh we are preparing the defines for.
  107239. * @param scene defines the scene the material belongs to.
  107240. */
  107241. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107242. /**
  107243. * Binds the material data.
  107244. * @param uniformBuffer defines the Uniform buffer to fill in.
  107245. * @param scene defines the scene the material belongs to.
  107246. * @param isFrozen defines wether the material is frozen or not.
  107247. */
  107248. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107249. /**
  107250. * Checks to see if a texture is used in the material.
  107251. * @param texture - Base texture to use.
  107252. * @returns - Boolean specifying if a texture is used in the material.
  107253. */
  107254. hasTexture(texture: BaseTexture): boolean;
  107255. /**
  107256. * Returns an array of the actively used textures.
  107257. * @param activeTextures Array of BaseTextures
  107258. */
  107259. getActiveTextures(activeTextures: BaseTexture[]): void;
  107260. /**
  107261. * Returns the animatable textures.
  107262. * @param animatables Array of animatable textures.
  107263. */
  107264. getAnimatables(animatables: IAnimatable[]): void;
  107265. /**
  107266. * Disposes the resources of the material.
  107267. * @param forceDisposeTextures - Forces the disposal of all textures.
  107268. */
  107269. dispose(forceDisposeTextures?: boolean): void;
  107270. /**
  107271. * Get the current class name of the texture useful for serialization or dynamic coding.
  107272. * @returns "PBRAnisotropicConfiguration"
  107273. */
  107274. getClassName(): string;
  107275. /**
  107276. * Add fallbacks to the effect fallbacks list.
  107277. * @param defines defines the Base texture to use.
  107278. * @param fallbacks defines the current fallback list.
  107279. * @param currentRank defines the current fallback rank.
  107280. * @returns the new fallback rank.
  107281. */
  107282. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107283. /**
  107284. * Add the required uniforms to the current list.
  107285. * @param uniforms defines the current uniform list.
  107286. */
  107287. static AddUniforms(uniforms: string[]): void;
  107288. /**
  107289. * Add the required uniforms to the current buffer.
  107290. * @param uniformBuffer defines the current uniform buffer.
  107291. */
  107292. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107293. /**
  107294. * Add the required samplers to the current list.
  107295. * @param samplers defines the current sampler list.
  107296. */
  107297. static AddSamplers(samplers: string[]): void;
  107298. /**
  107299. * Makes a duplicate of the current configuration into another one.
  107300. * @param anisotropicConfiguration define the config where to copy the info
  107301. */
  107302. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107303. /**
  107304. * Serializes this anisotropy configuration.
  107305. * @returns - An object with the serialized config.
  107306. */
  107307. serialize(): any;
  107308. /**
  107309. * Parses a anisotropy Configuration from a serialized object.
  107310. * @param source - Serialized object.
  107311. */
  107312. parse(source: any): void;
  107313. }
  107314. }
  107315. declare module BABYLON {
  107316. /**
  107317. * @hidden
  107318. */
  107319. export interface IMaterialBRDFDefines {
  107320. BRDF_V_HEIGHT_CORRELATED: boolean;
  107321. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107322. SPHERICAL_HARMONICS: boolean;
  107323. /** @hidden */
  107324. _areMiscDirty: boolean;
  107325. }
  107326. /**
  107327. * Define the code related to the BRDF parameters of the pbr material.
  107328. */
  107329. export class PBRBRDFConfiguration {
  107330. /**
  107331. * Default value used for the energy conservation.
  107332. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107333. */
  107334. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107335. /**
  107336. * Default value used for the Smith Visibility Height Correlated mode.
  107337. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107338. */
  107339. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107340. /**
  107341. * Default value used for the IBL diffuse part.
  107342. * This can help switching back to the polynomials mode globally which is a tiny bit
  107343. * less GPU intensive at the drawback of a lower quality.
  107344. */
  107345. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107346. private _useEnergyConservation;
  107347. /**
  107348. * Defines if the material uses energy conservation.
  107349. */
  107350. useEnergyConservation: boolean;
  107351. private _useSmithVisibilityHeightCorrelated;
  107352. /**
  107353. * LEGACY Mode set to false
  107354. * Defines if the material uses height smith correlated visibility term.
  107355. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107356. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107357. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107358. * Not relying on height correlated will also disable energy conservation.
  107359. */
  107360. useSmithVisibilityHeightCorrelated: boolean;
  107361. private _useSphericalHarmonics;
  107362. /**
  107363. * LEGACY Mode set to false
  107364. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107365. * diffuse part of the IBL.
  107366. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107367. * to the ground truth.
  107368. */
  107369. useSphericalHarmonics: boolean;
  107370. /** @hidden */
  107371. private _internalMarkAllSubMeshesAsMiscDirty;
  107372. /** @hidden */
  107373. _markAllSubMeshesAsMiscDirty(): void;
  107374. /**
  107375. * Instantiate a new istance of clear coat configuration.
  107376. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107377. */
  107378. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107379. /**
  107380. * Checks to see if a texture is used in the material.
  107381. * @param defines the list of "defines" to update.
  107382. */
  107383. prepareDefines(defines: IMaterialBRDFDefines): void;
  107384. /**
  107385. * Get the current class name of the texture useful for serialization or dynamic coding.
  107386. * @returns "PBRClearCoatConfiguration"
  107387. */
  107388. getClassName(): string;
  107389. /**
  107390. * Makes a duplicate of the current configuration into another one.
  107391. * @param brdfConfiguration define the config where to copy the info
  107392. */
  107393. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107394. /**
  107395. * Serializes this BRDF configuration.
  107396. * @returns - An object with the serialized config.
  107397. */
  107398. serialize(): any;
  107399. /**
  107400. * Parses a BRDF Configuration from a serialized object.
  107401. * @param source - Serialized object.
  107402. */
  107403. parse(source: any): void;
  107404. }
  107405. }
  107406. declare module BABYLON {
  107407. /**
  107408. * @hidden
  107409. */
  107410. export interface IMaterialSheenDefines {
  107411. SHEEN: boolean;
  107412. SHEEN_TEXTURE: boolean;
  107413. SHEEN_TEXTUREDIRECTUV: number;
  107414. SHEEN_LINKWITHALBEDO: boolean;
  107415. /** @hidden */
  107416. _areTexturesDirty: boolean;
  107417. }
  107418. /**
  107419. * Define the code related to the Sheen parameters of the pbr material.
  107420. */
  107421. export class PBRSheenConfiguration {
  107422. private _isEnabled;
  107423. /**
  107424. * Defines if the material uses sheen.
  107425. */
  107426. isEnabled: boolean;
  107427. private _linkSheenWithAlbedo;
  107428. /**
  107429. * Defines if the sheen is linked to the sheen color.
  107430. */
  107431. linkSheenWithAlbedo: boolean;
  107432. /**
  107433. * Defines the sheen intensity.
  107434. */
  107435. intensity: number;
  107436. /**
  107437. * Defines the sheen color.
  107438. */
  107439. color: Color3;
  107440. private _texture;
  107441. /**
  107442. * Stores the sheen tint values in a texture.
  107443. * rgb is tint
  107444. * a is a intensity
  107445. */
  107446. texture: Nullable<BaseTexture>;
  107447. /** @hidden */
  107448. private _internalMarkAllSubMeshesAsTexturesDirty;
  107449. /** @hidden */
  107450. _markAllSubMeshesAsTexturesDirty(): void;
  107451. /**
  107452. * Instantiate a new istance of clear coat configuration.
  107453. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107454. */
  107455. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107456. /**
  107457. * Specifies that the submesh is ready to be used.
  107458. * @param defines the list of "defines" to update.
  107459. * @param scene defines the scene the material belongs to.
  107460. * @returns - boolean indicating that the submesh is ready or not.
  107461. */
  107462. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107463. /**
  107464. * Checks to see if a texture is used in the material.
  107465. * @param defines the list of "defines" to update.
  107466. * @param scene defines the scene the material belongs to.
  107467. */
  107468. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107469. /**
  107470. * Binds the material data.
  107471. * @param uniformBuffer defines the Uniform buffer to fill in.
  107472. * @param scene defines the scene the material belongs to.
  107473. * @param isFrozen defines wether the material is frozen or not.
  107474. */
  107475. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107476. /**
  107477. * Checks to see if a texture is used in the material.
  107478. * @param texture - Base texture to use.
  107479. * @returns - Boolean specifying if a texture is used in the material.
  107480. */
  107481. hasTexture(texture: BaseTexture): boolean;
  107482. /**
  107483. * Returns an array of the actively used textures.
  107484. * @param activeTextures Array of BaseTextures
  107485. */
  107486. getActiveTextures(activeTextures: BaseTexture[]): void;
  107487. /**
  107488. * Returns the animatable textures.
  107489. * @param animatables Array of animatable textures.
  107490. */
  107491. getAnimatables(animatables: IAnimatable[]): void;
  107492. /**
  107493. * Disposes the resources of the material.
  107494. * @param forceDisposeTextures - Forces the disposal of all textures.
  107495. */
  107496. dispose(forceDisposeTextures?: boolean): void;
  107497. /**
  107498. * Get the current class name of the texture useful for serialization or dynamic coding.
  107499. * @returns "PBRSheenConfiguration"
  107500. */
  107501. getClassName(): string;
  107502. /**
  107503. * Add fallbacks to the effect fallbacks list.
  107504. * @param defines defines the Base texture to use.
  107505. * @param fallbacks defines the current fallback list.
  107506. * @param currentRank defines the current fallback rank.
  107507. * @returns the new fallback rank.
  107508. */
  107509. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107510. /**
  107511. * Add the required uniforms to the current list.
  107512. * @param uniforms defines the current uniform list.
  107513. */
  107514. static AddUniforms(uniforms: string[]): void;
  107515. /**
  107516. * Add the required uniforms to the current buffer.
  107517. * @param uniformBuffer defines the current uniform buffer.
  107518. */
  107519. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107520. /**
  107521. * Add the required samplers to the current list.
  107522. * @param samplers defines the current sampler list.
  107523. */
  107524. static AddSamplers(samplers: string[]): void;
  107525. /**
  107526. * Makes a duplicate of the current configuration into another one.
  107527. * @param sheenConfiguration define the config where to copy the info
  107528. */
  107529. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107530. /**
  107531. * Serializes this BRDF configuration.
  107532. * @returns - An object with the serialized config.
  107533. */
  107534. serialize(): any;
  107535. /**
  107536. * Parses a Sheen Configuration from a serialized object.
  107537. * @param source - Serialized object.
  107538. */
  107539. parse(source: any): void;
  107540. }
  107541. }
  107542. declare module BABYLON {
  107543. /**
  107544. * @hidden
  107545. */
  107546. export interface IMaterialSubSurfaceDefines {
  107547. SUBSURFACE: boolean;
  107548. SS_REFRACTION: boolean;
  107549. SS_TRANSLUCENCY: boolean;
  107550. SS_SCATERRING: boolean;
  107551. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107552. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107553. SS_REFRACTIONMAP_3D: boolean;
  107554. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107555. SS_LODINREFRACTIONALPHA: boolean;
  107556. SS_GAMMAREFRACTION: boolean;
  107557. SS_RGBDREFRACTION: boolean;
  107558. SS_LINEARSPECULARREFRACTION: boolean;
  107559. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107560. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107561. /** @hidden */
  107562. _areTexturesDirty: boolean;
  107563. }
  107564. /**
  107565. * Define the code related to the sub surface parameters of the pbr material.
  107566. */
  107567. export class PBRSubSurfaceConfiguration {
  107568. private _isRefractionEnabled;
  107569. /**
  107570. * Defines if the refraction is enabled in the material.
  107571. */
  107572. isRefractionEnabled: boolean;
  107573. private _isTranslucencyEnabled;
  107574. /**
  107575. * Defines if the translucency is enabled in the material.
  107576. */
  107577. isTranslucencyEnabled: boolean;
  107578. private _isScatteringEnabled;
  107579. /**
  107580. * Defines the refraction intensity of the material.
  107581. * The refraction when enabled replaces the Diffuse part of the material.
  107582. * The intensity helps transitionning between diffuse and refraction.
  107583. */
  107584. refractionIntensity: number;
  107585. /**
  107586. * Defines the translucency intensity of the material.
  107587. * When translucency has been enabled, this defines how much of the "translucency"
  107588. * is addded to the diffuse part of the material.
  107589. */
  107590. translucencyIntensity: number;
  107591. /**
  107592. * Defines the scattering intensity of the material.
  107593. * When scattering has been enabled, this defines how much of the "scattered light"
  107594. * is addded to the diffuse part of the material.
  107595. */
  107596. scatteringIntensity: number;
  107597. private _thicknessTexture;
  107598. /**
  107599. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  107600. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  107601. * 0 would mean minimumThickness
  107602. * 1 would mean maximumThickness
  107603. * The other channels might be use as a mask to vary the different effects intensity.
  107604. */
  107605. thicknessTexture: Nullable<BaseTexture>;
  107606. private _refractionTexture;
  107607. /**
  107608. * Defines the texture to use for refraction.
  107609. */
  107610. refractionTexture: Nullable<BaseTexture>;
  107611. private _indexOfRefraction;
  107612. /**
  107613. * Defines the index of refraction used in the material.
  107614. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107615. */
  107616. indexOfRefraction: number;
  107617. private _invertRefractionY;
  107618. /**
  107619. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107620. */
  107621. invertRefractionY: boolean;
  107622. private _linkRefractionWithTransparency;
  107623. /**
  107624. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107625. * Materials half opaque for instance using refraction could benefit from this control.
  107626. */
  107627. linkRefractionWithTransparency: boolean;
  107628. /**
  107629. * Defines the minimum thickness stored in the thickness map.
  107630. * If no thickness map is defined, this value will be used to simulate thickness.
  107631. */
  107632. minimumThickness: number;
  107633. /**
  107634. * Defines the maximum thickness stored in the thickness map.
  107635. */
  107636. maximumThickness: number;
  107637. /**
  107638. * Defines the volume tint of the material.
  107639. * This is used for both translucency and scattering.
  107640. */
  107641. tintColor: Color3;
  107642. /**
  107643. * Defines the distance at which the tint color should be found in the media.
  107644. * This is used for refraction only.
  107645. */
  107646. tintColorAtDistance: number;
  107647. /**
  107648. * Defines how far each channel transmit through the media.
  107649. * It is defined as a color to simplify it selection.
  107650. */
  107651. diffusionDistance: Color3;
  107652. private _useMaskFromThicknessTexture;
  107653. /**
  107654. * Stores the intensity of the different subsurface effects in the thickness texture.
  107655. * * the green channel is the translucency intensity.
  107656. * * the blue channel is the scattering intensity.
  107657. * * the alpha channel is the refraction intensity.
  107658. */
  107659. useMaskFromThicknessTexture: boolean;
  107660. /** @hidden */
  107661. private _internalMarkAllSubMeshesAsTexturesDirty;
  107662. /** @hidden */
  107663. _markAllSubMeshesAsTexturesDirty(): void;
  107664. /**
  107665. * Instantiate a new istance of sub surface configuration.
  107666. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107667. */
  107668. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107669. /**
  107670. * Gets wehter the submesh is ready to be used or not.
  107671. * @param defines the list of "defines" to update.
  107672. * @param scene defines the scene the material belongs to.
  107673. * @returns - boolean indicating that the submesh is ready or not.
  107674. */
  107675. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  107676. /**
  107677. * Checks to see if a texture is used in the material.
  107678. * @param defines the list of "defines" to update.
  107679. * @param scene defines the scene to the material belongs to.
  107680. */
  107681. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  107682. /**
  107683. * Binds the material data.
  107684. * @param uniformBuffer defines the Uniform buffer to fill in.
  107685. * @param scene defines the scene the material belongs to.
  107686. * @param engine defines the engine the material belongs to.
  107687. * @param isFrozen defines wether the material is frozen or not.
  107688. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  107689. */
  107690. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  107691. /**
  107692. * Unbinds the material from the mesh.
  107693. * @param activeEffect defines the effect that should be unbound from.
  107694. * @returns true if unbound, otherwise false
  107695. */
  107696. unbind(activeEffect: Effect): boolean;
  107697. /**
  107698. * Returns the texture used for refraction or null if none is used.
  107699. * @param scene defines the scene the material belongs to.
  107700. * @returns - Refraction texture if present. If no refraction texture and refraction
  107701. * is linked with transparency, returns environment texture. Otherwise, returns null.
  107702. */
  107703. private _getRefractionTexture;
  107704. /**
  107705. * Returns true if alpha blending should be disabled.
  107706. */
  107707. readonly disableAlphaBlending: boolean;
  107708. /**
  107709. * Fills the list of render target textures.
  107710. * @param renderTargets the list of render targets to update
  107711. */
  107712. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  107713. /**
  107714. * Checks to see if a texture is used in the material.
  107715. * @param texture - Base texture to use.
  107716. * @returns - Boolean specifying if a texture is used in the material.
  107717. */
  107718. hasTexture(texture: BaseTexture): boolean;
  107719. /**
  107720. * Gets a boolean indicating that current material needs to register RTT
  107721. * @returns true if this uses a render target otherwise false.
  107722. */
  107723. hasRenderTargetTextures(): boolean;
  107724. /**
  107725. * Returns an array of the actively used textures.
  107726. * @param activeTextures Array of BaseTextures
  107727. */
  107728. getActiveTextures(activeTextures: BaseTexture[]): void;
  107729. /**
  107730. * Returns the animatable textures.
  107731. * @param animatables Array of animatable textures.
  107732. */
  107733. getAnimatables(animatables: IAnimatable[]): void;
  107734. /**
  107735. * Disposes the resources of the material.
  107736. * @param forceDisposeTextures - Forces the disposal of all textures.
  107737. */
  107738. dispose(forceDisposeTextures?: boolean): void;
  107739. /**
  107740. * Get the current class name of the texture useful for serialization or dynamic coding.
  107741. * @returns "PBRSubSurfaceConfiguration"
  107742. */
  107743. getClassName(): string;
  107744. /**
  107745. * Add fallbacks to the effect fallbacks list.
  107746. * @param defines defines the Base texture to use.
  107747. * @param fallbacks defines the current fallback list.
  107748. * @param currentRank defines the current fallback rank.
  107749. * @returns the new fallback rank.
  107750. */
  107751. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107752. /**
  107753. * Add the required uniforms to the current list.
  107754. * @param uniforms defines the current uniform list.
  107755. */
  107756. static AddUniforms(uniforms: string[]): void;
  107757. /**
  107758. * Add the required samplers to the current list.
  107759. * @param samplers defines the current sampler list.
  107760. */
  107761. static AddSamplers(samplers: string[]): void;
  107762. /**
  107763. * Add the required uniforms to the current buffer.
  107764. * @param uniformBuffer defines the current uniform buffer.
  107765. */
  107766. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107767. /**
  107768. * Makes a duplicate of the current configuration into another one.
  107769. * @param configuration define the config where to copy the info
  107770. */
  107771. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  107772. /**
  107773. * Serializes this Sub Surface configuration.
  107774. * @returns - An object with the serialized config.
  107775. */
  107776. serialize(): any;
  107777. /**
  107778. * Parses a Sub Surface Configuration from a serialized object.
  107779. * @param source - Serialized object.
  107780. */
  107781. parse(source: any): void;
  107782. }
  107783. }
  107784. declare module BABYLON {
  107785. /** @hidden */
  107786. export var pbrFragmentDeclaration: {
  107787. name: string;
  107788. shader: string;
  107789. };
  107790. }
  107791. declare module BABYLON {
  107792. /** @hidden */
  107793. export var pbrUboDeclaration: {
  107794. name: string;
  107795. shader: string;
  107796. };
  107797. }
  107798. declare module BABYLON {
  107799. /** @hidden */
  107800. export var pbrFragmentExtraDeclaration: {
  107801. name: string;
  107802. shader: string;
  107803. };
  107804. }
  107805. declare module BABYLON {
  107806. /** @hidden */
  107807. export var pbrFragmentSamplersDeclaration: {
  107808. name: string;
  107809. shader: string;
  107810. };
  107811. }
  107812. declare module BABYLON {
  107813. /** @hidden */
  107814. export var pbrHelperFunctions: {
  107815. name: string;
  107816. shader: string;
  107817. };
  107818. }
  107819. declare module BABYLON {
  107820. /** @hidden */
  107821. export var harmonicsFunctions: {
  107822. name: string;
  107823. shader: string;
  107824. };
  107825. }
  107826. declare module BABYLON {
  107827. /** @hidden */
  107828. export var pbrDirectLightingSetupFunctions: {
  107829. name: string;
  107830. shader: string;
  107831. };
  107832. }
  107833. declare module BABYLON {
  107834. /** @hidden */
  107835. export var pbrDirectLightingFalloffFunctions: {
  107836. name: string;
  107837. shader: string;
  107838. };
  107839. }
  107840. declare module BABYLON {
  107841. /** @hidden */
  107842. export var pbrBRDFFunctions: {
  107843. name: string;
  107844. shader: string;
  107845. };
  107846. }
  107847. declare module BABYLON {
  107848. /** @hidden */
  107849. export var pbrDirectLightingFunctions: {
  107850. name: string;
  107851. shader: string;
  107852. };
  107853. }
  107854. declare module BABYLON {
  107855. /** @hidden */
  107856. export var pbrIBLFunctions: {
  107857. name: string;
  107858. shader: string;
  107859. };
  107860. }
  107861. declare module BABYLON {
  107862. /** @hidden */
  107863. export var pbrDebug: {
  107864. name: string;
  107865. shader: string;
  107866. };
  107867. }
  107868. declare module BABYLON {
  107869. /** @hidden */
  107870. export var pbrPixelShader: {
  107871. name: string;
  107872. shader: string;
  107873. };
  107874. }
  107875. declare module BABYLON {
  107876. /** @hidden */
  107877. export var pbrVertexDeclaration: {
  107878. name: string;
  107879. shader: string;
  107880. };
  107881. }
  107882. declare module BABYLON {
  107883. /** @hidden */
  107884. export var pbrVertexShader: {
  107885. name: string;
  107886. shader: string;
  107887. };
  107888. }
  107889. declare module BABYLON {
  107890. /**
  107891. * Manages the defines for the PBR Material.
  107892. * @hidden
  107893. */
  107894. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  107895. PBR: boolean;
  107896. MAINUV1: boolean;
  107897. MAINUV2: boolean;
  107898. UV1: boolean;
  107899. UV2: boolean;
  107900. ALBEDO: boolean;
  107901. ALBEDODIRECTUV: number;
  107902. VERTEXCOLOR: boolean;
  107903. AMBIENT: boolean;
  107904. AMBIENTDIRECTUV: number;
  107905. AMBIENTINGRAYSCALE: boolean;
  107906. OPACITY: boolean;
  107907. VERTEXALPHA: boolean;
  107908. OPACITYDIRECTUV: number;
  107909. OPACITYRGB: boolean;
  107910. ALPHATEST: boolean;
  107911. DEPTHPREPASS: boolean;
  107912. ALPHABLEND: boolean;
  107913. ALPHAFROMALBEDO: boolean;
  107914. ALPHATESTVALUE: string;
  107915. SPECULAROVERALPHA: boolean;
  107916. RADIANCEOVERALPHA: boolean;
  107917. ALPHAFRESNEL: boolean;
  107918. LINEARALPHAFRESNEL: boolean;
  107919. PREMULTIPLYALPHA: boolean;
  107920. EMISSIVE: boolean;
  107921. EMISSIVEDIRECTUV: number;
  107922. REFLECTIVITY: boolean;
  107923. REFLECTIVITYDIRECTUV: number;
  107924. SPECULARTERM: boolean;
  107925. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107926. MICROSURFACEAUTOMATIC: boolean;
  107927. LODBASEDMICROSFURACE: boolean;
  107928. MICROSURFACEMAP: boolean;
  107929. MICROSURFACEMAPDIRECTUV: number;
  107930. METALLICWORKFLOW: boolean;
  107931. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107932. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107933. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107934. AOSTOREINMETALMAPRED: boolean;
  107935. ENVIRONMENTBRDF: boolean;
  107936. ENVIRONMENTBRDF_RGBD: boolean;
  107937. NORMAL: boolean;
  107938. TANGENT: boolean;
  107939. BUMP: boolean;
  107940. BUMPDIRECTUV: number;
  107941. OBJECTSPACE_NORMALMAP: boolean;
  107942. PARALLAX: boolean;
  107943. PARALLAXOCCLUSION: boolean;
  107944. NORMALXYSCALE: boolean;
  107945. LIGHTMAP: boolean;
  107946. LIGHTMAPDIRECTUV: number;
  107947. USELIGHTMAPASSHADOWMAP: boolean;
  107948. GAMMALIGHTMAP: boolean;
  107949. REFLECTION: boolean;
  107950. REFLECTIONMAP_3D: boolean;
  107951. REFLECTIONMAP_SPHERICAL: boolean;
  107952. REFLECTIONMAP_PLANAR: boolean;
  107953. REFLECTIONMAP_CUBIC: boolean;
  107954. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107955. REFLECTIONMAP_PROJECTION: boolean;
  107956. REFLECTIONMAP_SKYBOX: boolean;
  107957. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107958. REFLECTIONMAP_EXPLICIT: boolean;
  107959. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107960. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107961. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107962. INVERTCUBICMAP: boolean;
  107963. USESPHERICALFROMREFLECTIONMAP: boolean;
  107964. USEIRRADIANCEMAP: boolean;
  107965. SPHERICAL_HARMONICS: boolean;
  107966. USESPHERICALINVERTEX: boolean;
  107967. REFLECTIONMAP_OPPOSITEZ: boolean;
  107968. LODINREFLECTIONALPHA: boolean;
  107969. GAMMAREFLECTION: boolean;
  107970. RGBDREFLECTION: boolean;
  107971. LINEARSPECULARREFLECTION: boolean;
  107972. RADIANCEOCCLUSION: boolean;
  107973. HORIZONOCCLUSION: boolean;
  107974. INSTANCES: boolean;
  107975. NUM_BONE_INFLUENCERS: number;
  107976. BonesPerMesh: number;
  107977. BONETEXTURE: boolean;
  107978. NONUNIFORMSCALING: boolean;
  107979. MORPHTARGETS: boolean;
  107980. MORPHTARGETS_NORMAL: boolean;
  107981. MORPHTARGETS_TANGENT: boolean;
  107982. NUM_MORPH_INFLUENCERS: number;
  107983. IMAGEPROCESSING: boolean;
  107984. VIGNETTE: boolean;
  107985. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107986. VIGNETTEBLENDMODEOPAQUE: boolean;
  107987. TONEMAPPING: boolean;
  107988. TONEMAPPING_ACES: boolean;
  107989. CONTRAST: boolean;
  107990. COLORCURVES: boolean;
  107991. COLORGRADING: boolean;
  107992. COLORGRADING3D: boolean;
  107993. SAMPLER3DGREENDEPTH: boolean;
  107994. SAMPLER3DBGRMAP: boolean;
  107995. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107996. EXPOSURE: boolean;
  107997. MULTIVIEW: boolean;
  107998. USEPHYSICALLIGHTFALLOFF: boolean;
  107999. USEGLTFLIGHTFALLOFF: boolean;
  108000. TWOSIDEDLIGHTING: boolean;
  108001. SHADOWFLOAT: boolean;
  108002. CLIPPLANE: boolean;
  108003. CLIPPLANE2: boolean;
  108004. CLIPPLANE3: boolean;
  108005. CLIPPLANE4: boolean;
  108006. POINTSIZE: boolean;
  108007. FOG: boolean;
  108008. LOGARITHMICDEPTH: boolean;
  108009. FORCENORMALFORWARD: boolean;
  108010. SPECULARAA: boolean;
  108011. CLEARCOAT: boolean;
  108012. CLEARCOAT_DEFAULTIOR: boolean;
  108013. CLEARCOAT_TEXTURE: boolean;
  108014. CLEARCOAT_TEXTUREDIRECTUV: number;
  108015. CLEARCOAT_BUMP: boolean;
  108016. CLEARCOAT_BUMPDIRECTUV: number;
  108017. CLEARCOAT_TINT: boolean;
  108018. CLEARCOAT_TINT_TEXTURE: boolean;
  108019. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108020. ANISOTROPIC: boolean;
  108021. ANISOTROPIC_TEXTURE: boolean;
  108022. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108023. BRDF_V_HEIGHT_CORRELATED: boolean;
  108024. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108025. SHEEN: boolean;
  108026. SHEEN_TEXTURE: boolean;
  108027. SHEEN_TEXTUREDIRECTUV: number;
  108028. SHEEN_LINKWITHALBEDO: boolean;
  108029. SUBSURFACE: boolean;
  108030. SS_REFRACTION: boolean;
  108031. SS_TRANSLUCENCY: boolean;
  108032. SS_SCATERRING: boolean;
  108033. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108034. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108035. SS_REFRACTIONMAP_3D: boolean;
  108036. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108037. SS_LODINREFRACTIONALPHA: boolean;
  108038. SS_GAMMAREFRACTION: boolean;
  108039. SS_RGBDREFRACTION: boolean;
  108040. SS_LINEARSPECULARREFRACTION: boolean;
  108041. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108042. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108043. UNLIT: boolean;
  108044. DEBUGMODE: number;
  108045. /**
  108046. * Initializes the PBR Material defines.
  108047. */
  108048. constructor();
  108049. /**
  108050. * Resets the PBR Material defines.
  108051. */
  108052. reset(): void;
  108053. }
  108054. /**
  108055. * The Physically based material base class of BJS.
  108056. *
  108057. * This offers the main features of a standard PBR material.
  108058. * For more information, please refer to the documentation :
  108059. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108060. */
  108061. export abstract class PBRBaseMaterial extends PushMaterial {
  108062. /**
  108063. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108064. */
  108065. static readonly PBRMATERIAL_OPAQUE: number;
  108066. /**
  108067. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108068. */
  108069. static readonly PBRMATERIAL_ALPHATEST: number;
  108070. /**
  108071. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108072. */
  108073. static readonly PBRMATERIAL_ALPHABLEND: number;
  108074. /**
  108075. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108076. * They are also discarded below the alpha cutoff threshold to improve performances.
  108077. */
  108078. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108079. /**
  108080. * Defines the default value of how much AO map is occluding the analytical lights
  108081. * (point spot...).
  108082. */
  108083. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108084. /**
  108085. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108086. */
  108087. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108088. /**
  108089. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108090. * to enhance interoperability with other engines.
  108091. */
  108092. static readonly LIGHTFALLOFF_GLTF: number;
  108093. /**
  108094. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108095. * to enhance interoperability with other materials.
  108096. */
  108097. static readonly LIGHTFALLOFF_STANDARD: number;
  108098. /**
  108099. * Intensity of the direct lights e.g. the four lights available in your scene.
  108100. * This impacts both the direct diffuse and specular highlights.
  108101. */
  108102. protected _directIntensity: number;
  108103. /**
  108104. * Intensity of the emissive part of the material.
  108105. * This helps controlling the emissive effect without modifying the emissive color.
  108106. */
  108107. protected _emissiveIntensity: number;
  108108. /**
  108109. * Intensity of the environment e.g. how much the environment will light the object
  108110. * either through harmonics for rough material or through the refelction for shiny ones.
  108111. */
  108112. protected _environmentIntensity: number;
  108113. /**
  108114. * This is a special control allowing the reduction of the specular highlights coming from the
  108115. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108116. */
  108117. protected _specularIntensity: number;
  108118. /**
  108119. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108120. */
  108121. private _lightingInfos;
  108122. /**
  108123. * Debug Control allowing disabling the bump map on this material.
  108124. */
  108125. protected _disableBumpMap: boolean;
  108126. /**
  108127. * AKA Diffuse Texture in standard nomenclature.
  108128. */
  108129. protected _albedoTexture: Nullable<BaseTexture>;
  108130. /**
  108131. * AKA Occlusion Texture in other nomenclature.
  108132. */
  108133. protected _ambientTexture: Nullable<BaseTexture>;
  108134. /**
  108135. * AKA Occlusion Texture Intensity in other nomenclature.
  108136. */
  108137. protected _ambientTextureStrength: number;
  108138. /**
  108139. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108140. * 1 means it completely occludes it
  108141. * 0 mean it has no impact
  108142. */
  108143. protected _ambientTextureImpactOnAnalyticalLights: number;
  108144. /**
  108145. * Stores the alpha values in a texture.
  108146. */
  108147. protected _opacityTexture: Nullable<BaseTexture>;
  108148. /**
  108149. * Stores the reflection values in a texture.
  108150. */
  108151. protected _reflectionTexture: Nullable<BaseTexture>;
  108152. /**
  108153. * Stores the emissive values in a texture.
  108154. */
  108155. protected _emissiveTexture: Nullable<BaseTexture>;
  108156. /**
  108157. * AKA Specular texture in other nomenclature.
  108158. */
  108159. protected _reflectivityTexture: Nullable<BaseTexture>;
  108160. /**
  108161. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108162. */
  108163. protected _metallicTexture: Nullable<BaseTexture>;
  108164. /**
  108165. * Specifies the metallic scalar of the metallic/roughness workflow.
  108166. * Can also be used to scale the metalness values of the metallic texture.
  108167. */
  108168. protected _metallic: Nullable<number>;
  108169. /**
  108170. * Specifies the roughness scalar of the metallic/roughness workflow.
  108171. * Can also be used to scale the roughness values of the metallic texture.
  108172. */
  108173. protected _roughness: Nullable<number>;
  108174. /**
  108175. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108176. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108177. */
  108178. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108179. /**
  108180. * Stores surface normal data used to displace a mesh in a texture.
  108181. */
  108182. protected _bumpTexture: Nullable<BaseTexture>;
  108183. /**
  108184. * Stores the pre-calculated light information of a mesh in a texture.
  108185. */
  108186. protected _lightmapTexture: Nullable<BaseTexture>;
  108187. /**
  108188. * The color of a material in ambient lighting.
  108189. */
  108190. protected _ambientColor: Color3;
  108191. /**
  108192. * AKA Diffuse Color in other nomenclature.
  108193. */
  108194. protected _albedoColor: Color3;
  108195. /**
  108196. * AKA Specular Color in other nomenclature.
  108197. */
  108198. protected _reflectivityColor: Color3;
  108199. /**
  108200. * The color applied when light is reflected from a material.
  108201. */
  108202. protected _reflectionColor: Color3;
  108203. /**
  108204. * The color applied when light is emitted from a material.
  108205. */
  108206. protected _emissiveColor: Color3;
  108207. /**
  108208. * AKA Glossiness in other nomenclature.
  108209. */
  108210. protected _microSurface: number;
  108211. /**
  108212. * Specifies that the material will use the light map as a show map.
  108213. */
  108214. protected _useLightmapAsShadowmap: boolean;
  108215. /**
  108216. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108217. * makes the reflect vector face the model (under horizon).
  108218. */
  108219. protected _useHorizonOcclusion: boolean;
  108220. /**
  108221. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108222. * too much the area relying on ambient texture to define their ambient occlusion.
  108223. */
  108224. protected _useRadianceOcclusion: boolean;
  108225. /**
  108226. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108227. */
  108228. protected _useAlphaFromAlbedoTexture: boolean;
  108229. /**
  108230. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108231. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108232. */
  108233. protected _useSpecularOverAlpha: boolean;
  108234. /**
  108235. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108236. */
  108237. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108238. /**
  108239. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108240. */
  108241. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108242. /**
  108243. * Specifies if the metallic texture contains the roughness information in its green channel.
  108244. */
  108245. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108246. /**
  108247. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108248. */
  108249. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108250. /**
  108251. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108252. */
  108253. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108254. /**
  108255. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108256. */
  108257. protected _useAmbientInGrayScale: boolean;
  108258. /**
  108259. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108260. * The material will try to infer what glossiness each pixel should be.
  108261. */
  108262. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108263. /**
  108264. * Defines the falloff type used in this material.
  108265. * It by default is Physical.
  108266. */
  108267. protected _lightFalloff: number;
  108268. /**
  108269. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108270. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108271. */
  108272. protected _useRadianceOverAlpha: boolean;
  108273. /**
  108274. * Allows using an object space normal map (instead of tangent space).
  108275. */
  108276. protected _useObjectSpaceNormalMap: boolean;
  108277. /**
  108278. * Allows using the bump map in parallax mode.
  108279. */
  108280. protected _useParallax: boolean;
  108281. /**
  108282. * Allows using the bump map in parallax occlusion mode.
  108283. */
  108284. protected _useParallaxOcclusion: boolean;
  108285. /**
  108286. * Controls the scale bias of the parallax mode.
  108287. */
  108288. protected _parallaxScaleBias: number;
  108289. /**
  108290. * If sets to true, disables all the lights affecting the material.
  108291. */
  108292. protected _disableLighting: boolean;
  108293. /**
  108294. * Number of Simultaneous lights allowed on the material.
  108295. */
  108296. protected _maxSimultaneousLights: number;
  108297. /**
  108298. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108299. */
  108300. protected _invertNormalMapX: boolean;
  108301. /**
  108302. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108303. */
  108304. protected _invertNormalMapY: boolean;
  108305. /**
  108306. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108307. */
  108308. protected _twoSidedLighting: boolean;
  108309. /**
  108310. * Defines the alpha limits in alpha test mode.
  108311. */
  108312. protected _alphaCutOff: number;
  108313. /**
  108314. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108315. */
  108316. protected _forceAlphaTest: boolean;
  108317. /**
  108318. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108319. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108320. */
  108321. protected _useAlphaFresnel: boolean;
  108322. /**
  108323. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108324. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108325. */
  108326. protected _useLinearAlphaFresnel: boolean;
  108327. /**
  108328. * The transparency mode of the material.
  108329. */
  108330. protected _transparencyMode: Nullable<number>;
  108331. /**
  108332. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108333. * from cos thetav and roughness:
  108334. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108335. */
  108336. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108337. /**
  108338. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108339. */
  108340. protected _forceIrradianceInFragment: boolean;
  108341. /**
  108342. * Force normal to face away from face.
  108343. */
  108344. protected _forceNormalForward: boolean;
  108345. /**
  108346. * Enables specular anti aliasing in the PBR shader.
  108347. * It will both interacts on the Geometry for analytical and IBL lighting.
  108348. * It also prefilter the roughness map based on the bump values.
  108349. */
  108350. protected _enableSpecularAntiAliasing: boolean;
  108351. /**
  108352. * Default configuration related to image processing available in the PBR Material.
  108353. */
  108354. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108355. /**
  108356. * Keep track of the image processing observer to allow dispose and replace.
  108357. */
  108358. private _imageProcessingObserver;
  108359. /**
  108360. * Attaches a new image processing configuration to the PBR Material.
  108361. * @param configuration
  108362. */
  108363. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108364. /**
  108365. * Stores the available render targets.
  108366. */
  108367. private _renderTargets;
  108368. /**
  108369. * Sets the global ambient color for the material used in lighting calculations.
  108370. */
  108371. private _globalAmbientColor;
  108372. /**
  108373. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108374. */
  108375. private _useLogarithmicDepth;
  108376. /**
  108377. * If set to true, no lighting calculations will be applied.
  108378. */
  108379. private _unlit;
  108380. private _debugMode;
  108381. /**
  108382. * @hidden
  108383. * This is reserved for the inspector.
  108384. * Defines the material debug mode.
  108385. * It helps seeing only some components of the material while troubleshooting.
  108386. */
  108387. debugMode: number;
  108388. /**
  108389. * @hidden
  108390. * This is reserved for the inspector.
  108391. * Specify from where on screen the debug mode should start.
  108392. * The value goes from -1 (full screen) to 1 (not visible)
  108393. * It helps with side by side comparison against the final render
  108394. * This defaults to -1
  108395. */
  108396. private debugLimit;
  108397. /**
  108398. * @hidden
  108399. * This is reserved for the inspector.
  108400. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108401. * You can use the factor to better multiply the final value.
  108402. */
  108403. private debugFactor;
  108404. /**
  108405. * Defines the clear coat layer parameters for the material.
  108406. */
  108407. readonly clearCoat: PBRClearCoatConfiguration;
  108408. /**
  108409. * Defines the anisotropic parameters for the material.
  108410. */
  108411. readonly anisotropy: PBRAnisotropicConfiguration;
  108412. /**
  108413. * Defines the BRDF parameters for the material.
  108414. */
  108415. readonly brdf: PBRBRDFConfiguration;
  108416. /**
  108417. * Defines the Sheen parameters for the material.
  108418. */
  108419. readonly sheen: PBRSheenConfiguration;
  108420. /**
  108421. * Defines the SubSurface parameters for the material.
  108422. */
  108423. readonly subSurface: PBRSubSurfaceConfiguration;
  108424. /**
  108425. * Custom callback helping to override the default shader used in the material.
  108426. */
  108427. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108428. /**
  108429. * Instantiates a new PBRMaterial instance.
  108430. *
  108431. * @param name The material name
  108432. * @param scene The scene the material will be use in.
  108433. */
  108434. constructor(name: string, scene: Scene);
  108435. /**
  108436. * Gets a boolean indicating that current material needs to register RTT
  108437. */
  108438. readonly hasRenderTargetTextures: boolean;
  108439. /**
  108440. * Gets the name of the material class.
  108441. */
  108442. getClassName(): string;
  108443. /**
  108444. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108445. */
  108446. /**
  108447. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108448. */
  108449. useLogarithmicDepth: boolean;
  108450. /**
  108451. * Gets the current transparency mode.
  108452. */
  108453. /**
  108454. * Sets the transparency mode of the material.
  108455. *
  108456. * | Value | Type | Description |
  108457. * | ----- | ----------------------------------- | ----------- |
  108458. * | 0 | OPAQUE | |
  108459. * | 1 | ALPHATEST | |
  108460. * | 2 | ALPHABLEND | |
  108461. * | 3 | ALPHATESTANDBLEND | |
  108462. *
  108463. */
  108464. transparencyMode: Nullable<number>;
  108465. /**
  108466. * Returns true if alpha blending should be disabled.
  108467. */
  108468. private readonly _disableAlphaBlending;
  108469. /**
  108470. * Specifies whether or not this material should be rendered in alpha blend mode.
  108471. */
  108472. needAlphaBlending(): boolean;
  108473. /**
  108474. * Specifies if the mesh will require alpha blending.
  108475. * @param mesh - BJS mesh.
  108476. */
  108477. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108478. /**
  108479. * Specifies whether or not this material should be rendered in alpha test mode.
  108480. */
  108481. needAlphaTesting(): boolean;
  108482. /**
  108483. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108484. */
  108485. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108486. /**
  108487. * Gets the texture used for the alpha test.
  108488. */
  108489. getAlphaTestTexture(): Nullable<BaseTexture>;
  108490. /**
  108491. * Specifies that the submesh is ready to be used.
  108492. * @param mesh - BJS mesh.
  108493. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108494. * @param useInstances - Specifies that instances should be used.
  108495. * @returns - boolean indicating that the submesh is ready or not.
  108496. */
  108497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108498. /**
  108499. * Specifies if the material uses metallic roughness workflow.
  108500. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108501. */
  108502. isMetallicWorkflow(): boolean;
  108503. private _prepareEffect;
  108504. private _prepareDefines;
  108505. /**
  108506. * Force shader compilation
  108507. */
  108508. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108509. clipPlane: boolean;
  108510. }>): void;
  108511. /**
  108512. * Initializes the uniform buffer layout for the shader.
  108513. */
  108514. buildUniformLayout(): void;
  108515. /**
  108516. * Unbinds the material from the mesh
  108517. */
  108518. unbind(): void;
  108519. /**
  108520. * Binds the submesh data.
  108521. * @param world - The world matrix.
  108522. * @param mesh - The BJS mesh.
  108523. * @param subMesh - A submesh of the BJS mesh.
  108524. */
  108525. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108526. /**
  108527. * Returns the animatable textures.
  108528. * @returns - Array of animatable textures.
  108529. */
  108530. getAnimatables(): IAnimatable[];
  108531. /**
  108532. * Returns the texture used for reflections.
  108533. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108534. */
  108535. private _getReflectionTexture;
  108536. /**
  108537. * Returns an array of the actively used textures.
  108538. * @returns - Array of BaseTextures
  108539. */
  108540. getActiveTextures(): BaseTexture[];
  108541. /**
  108542. * Checks to see if a texture is used in the material.
  108543. * @param texture - Base texture to use.
  108544. * @returns - Boolean specifying if a texture is used in the material.
  108545. */
  108546. hasTexture(texture: BaseTexture): boolean;
  108547. /**
  108548. * Disposes the resources of the material.
  108549. * @param forceDisposeEffect - Forces the disposal of effects.
  108550. * @param forceDisposeTextures - Forces the disposal of all textures.
  108551. */
  108552. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108553. }
  108554. }
  108555. declare module BABYLON {
  108556. /**
  108557. * The Physically based material of BJS.
  108558. *
  108559. * This offers the main features of a standard PBR material.
  108560. * For more information, please refer to the documentation :
  108561. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108562. */
  108563. export class PBRMaterial extends PBRBaseMaterial {
  108564. /**
  108565. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108566. */
  108567. static readonly PBRMATERIAL_OPAQUE: number;
  108568. /**
  108569. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108570. */
  108571. static readonly PBRMATERIAL_ALPHATEST: number;
  108572. /**
  108573. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108574. */
  108575. static readonly PBRMATERIAL_ALPHABLEND: number;
  108576. /**
  108577. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108578. * They are also discarded below the alpha cutoff threshold to improve performances.
  108579. */
  108580. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108581. /**
  108582. * Defines the default value of how much AO map is occluding the analytical lights
  108583. * (point spot...).
  108584. */
  108585. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108586. /**
  108587. * Intensity of the direct lights e.g. the four lights available in your scene.
  108588. * This impacts both the direct diffuse and specular highlights.
  108589. */
  108590. directIntensity: number;
  108591. /**
  108592. * Intensity of the emissive part of the material.
  108593. * This helps controlling the emissive effect without modifying the emissive color.
  108594. */
  108595. emissiveIntensity: number;
  108596. /**
  108597. * Intensity of the environment e.g. how much the environment will light the object
  108598. * either through harmonics for rough material or through the refelction for shiny ones.
  108599. */
  108600. environmentIntensity: number;
  108601. /**
  108602. * This is a special control allowing the reduction of the specular highlights coming from the
  108603. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108604. */
  108605. specularIntensity: number;
  108606. /**
  108607. * Debug Control allowing disabling the bump map on this material.
  108608. */
  108609. disableBumpMap: boolean;
  108610. /**
  108611. * AKA Diffuse Texture in standard nomenclature.
  108612. */
  108613. albedoTexture: BaseTexture;
  108614. /**
  108615. * AKA Occlusion Texture in other nomenclature.
  108616. */
  108617. ambientTexture: BaseTexture;
  108618. /**
  108619. * AKA Occlusion Texture Intensity in other nomenclature.
  108620. */
  108621. ambientTextureStrength: number;
  108622. /**
  108623. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108624. * 1 means it completely occludes it
  108625. * 0 mean it has no impact
  108626. */
  108627. ambientTextureImpactOnAnalyticalLights: number;
  108628. /**
  108629. * Stores the alpha values in a texture.
  108630. */
  108631. opacityTexture: BaseTexture;
  108632. /**
  108633. * Stores the reflection values in a texture.
  108634. */
  108635. reflectionTexture: Nullable<BaseTexture>;
  108636. /**
  108637. * Stores the emissive values in a texture.
  108638. */
  108639. emissiveTexture: BaseTexture;
  108640. /**
  108641. * AKA Specular texture in other nomenclature.
  108642. */
  108643. reflectivityTexture: BaseTexture;
  108644. /**
  108645. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108646. */
  108647. metallicTexture: BaseTexture;
  108648. /**
  108649. * Specifies the metallic scalar of the metallic/roughness workflow.
  108650. * Can also be used to scale the metalness values of the metallic texture.
  108651. */
  108652. metallic: Nullable<number>;
  108653. /**
  108654. * Specifies the roughness scalar of the metallic/roughness workflow.
  108655. * Can also be used to scale the roughness values of the metallic texture.
  108656. */
  108657. roughness: Nullable<number>;
  108658. /**
  108659. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108660. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108661. */
  108662. microSurfaceTexture: BaseTexture;
  108663. /**
  108664. * Stores surface normal data used to displace a mesh in a texture.
  108665. */
  108666. bumpTexture: BaseTexture;
  108667. /**
  108668. * Stores the pre-calculated light information of a mesh in a texture.
  108669. */
  108670. lightmapTexture: BaseTexture;
  108671. /**
  108672. * Stores the refracted light information in a texture.
  108673. */
  108674. refractionTexture: Nullable<BaseTexture>;
  108675. /**
  108676. * The color of a material in ambient lighting.
  108677. */
  108678. ambientColor: Color3;
  108679. /**
  108680. * AKA Diffuse Color in other nomenclature.
  108681. */
  108682. albedoColor: Color3;
  108683. /**
  108684. * AKA Specular Color in other nomenclature.
  108685. */
  108686. reflectivityColor: Color3;
  108687. /**
  108688. * The color reflected from the material.
  108689. */
  108690. reflectionColor: Color3;
  108691. /**
  108692. * The color emitted from the material.
  108693. */
  108694. emissiveColor: Color3;
  108695. /**
  108696. * AKA Glossiness in other nomenclature.
  108697. */
  108698. microSurface: number;
  108699. /**
  108700. * source material index of refraction (IOR)' / 'destination material IOR.
  108701. */
  108702. indexOfRefraction: number;
  108703. /**
  108704. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108705. */
  108706. invertRefractionY: boolean;
  108707. /**
  108708. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108709. * Materials half opaque for instance using refraction could benefit from this control.
  108710. */
  108711. linkRefractionWithTransparency: boolean;
  108712. /**
  108713. * If true, the light map contains occlusion information instead of lighting info.
  108714. */
  108715. useLightmapAsShadowmap: boolean;
  108716. /**
  108717. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108718. */
  108719. useAlphaFromAlbedoTexture: boolean;
  108720. /**
  108721. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108722. */
  108723. forceAlphaTest: boolean;
  108724. /**
  108725. * Defines the alpha limits in alpha test mode.
  108726. */
  108727. alphaCutOff: number;
  108728. /**
  108729. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108730. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108731. */
  108732. useSpecularOverAlpha: boolean;
  108733. /**
  108734. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108735. */
  108736. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108737. /**
  108738. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108739. */
  108740. useRoughnessFromMetallicTextureAlpha: boolean;
  108741. /**
  108742. * Specifies if the metallic texture contains the roughness information in its green channel.
  108743. */
  108744. useRoughnessFromMetallicTextureGreen: boolean;
  108745. /**
  108746. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108747. */
  108748. useMetallnessFromMetallicTextureBlue: boolean;
  108749. /**
  108750. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108751. */
  108752. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108753. /**
  108754. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108755. */
  108756. useAmbientInGrayScale: boolean;
  108757. /**
  108758. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108759. * The material will try to infer what glossiness each pixel should be.
  108760. */
  108761. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108762. /**
  108763. * BJS is using an harcoded light falloff based on a manually sets up range.
  108764. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108765. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108766. */
  108767. /**
  108768. * BJS is using an harcoded light falloff based on a manually sets up range.
  108769. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108770. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108771. */
  108772. usePhysicalLightFalloff: boolean;
  108773. /**
  108774. * In order to support the falloff compatibility with gltf, a special mode has been added
  108775. * to reproduce the gltf light falloff.
  108776. */
  108777. /**
  108778. * In order to support the falloff compatibility with gltf, a special mode has been added
  108779. * to reproduce the gltf light falloff.
  108780. */
  108781. useGLTFLightFalloff: boolean;
  108782. /**
  108783. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108784. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108785. */
  108786. useRadianceOverAlpha: boolean;
  108787. /**
  108788. * Allows using an object space normal map (instead of tangent space).
  108789. */
  108790. useObjectSpaceNormalMap: boolean;
  108791. /**
  108792. * Allows using the bump map in parallax mode.
  108793. */
  108794. useParallax: boolean;
  108795. /**
  108796. * Allows using the bump map in parallax occlusion mode.
  108797. */
  108798. useParallaxOcclusion: boolean;
  108799. /**
  108800. * Controls the scale bias of the parallax mode.
  108801. */
  108802. parallaxScaleBias: number;
  108803. /**
  108804. * If sets to true, disables all the lights affecting the material.
  108805. */
  108806. disableLighting: boolean;
  108807. /**
  108808. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108809. */
  108810. forceIrradianceInFragment: boolean;
  108811. /**
  108812. * Number of Simultaneous lights allowed on the material.
  108813. */
  108814. maxSimultaneousLights: number;
  108815. /**
  108816. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108817. */
  108818. invertNormalMapX: boolean;
  108819. /**
  108820. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108821. */
  108822. invertNormalMapY: boolean;
  108823. /**
  108824. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108825. */
  108826. twoSidedLighting: boolean;
  108827. /**
  108828. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108829. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108830. */
  108831. useAlphaFresnel: boolean;
  108832. /**
  108833. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108834. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108835. */
  108836. useLinearAlphaFresnel: boolean;
  108837. /**
  108838. * Let user defines the brdf lookup texture used for IBL.
  108839. * A default 8bit version is embedded but you could point at :
  108840. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  108841. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108842. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  108843. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108844. */
  108845. environmentBRDFTexture: Nullable<BaseTexture>;
  108846. /**
  108847. * Force normal to face away from face.
  108848. */
  108849. forceNormalForward: boolean;
  108850. /**
  108851. * Enables specular anti aliasing in the PBR shader.
  108852. * It will both interacts on the Geometry for analytical and IBL lighting.
  108853. * It also prefilter the roughness map based on the bump values.
  108854. */
  108855. enableSpecularAntiAliasing: boolean;
  108856. /**
  108857. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108858. * makes the reflect vector face the model (under horizon).
  108859. */
  108860. useHorizonOcclusion: boolean;
  108861. /**
  108862. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108863. * too much the area relying on ambient texture to define their ambient occlusion.
  108864. */
  108865. useRadianceOcclusion: boolean;
  108866. /**
  108867. * If set to true, no lighting calculations will be applied.
  108868. */
  108869. unlit: boolean;
  108870. /**
  108871. * Gets the image processing configuration used either in this material.
  108872. */
  108873. /**
  108874. * Sets the Default image processing configuration used either in the this material.
  108875. *
  108876. * If sets to null, the scene one is in use.
  108877. */
  108878. imageProcessingConfiguration: ImageProcessingConfiguration;
  108879. /**
  108880. * Gets wether the color curves effect is enabled.
  108881. */
  108882. /**
  108883. * Sets wether the color curves effect is enabled.
  108884. */
  108885. cameraColorCurvesEnabled: boolean;
  108886. /**
  108887. * Gets wether the color grading effect is enabled.
  108888. */
  108889. /**
  108890. * Gets wether the color grading effect is enabled.
  108891. */
  108892. cameraColorGradingEnabled: boolean;
  108893. /**
  108894. * Gets wether tonemapping is enabled or not.
  108895. */
  108896. /**
  108897. * Sets wether tonemapping is enabled or not
  108898. */
  108899. cameraToneMappingEnabled: boolean;
  108900. /**
  108901. * The camera exposure used on this material.
  108902. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108903. * This corresponds to a photographic exposure.
  108904. */
  108905. /**
  108906. * The camera exposure used on this material.
  108907. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108908. * This corresponds to a photographic exposure.
  108909. */
  108910. cameraExposure: number;
  108911. /**
  108912. * Gets The camera contrast used on this material.
  108913. */
  108914. /**
  108915. * Sets The camera contrast used on this material.
  108916. */
  108917. cameraContrast: number;
  108918. /**
  108919. * Gets the Color Grading 2D Lookup Texture.
  108920. */
  108921. /**
  108922. * Sets the Color Grading 2D Lookup Texture.
  108923. */
  108924. cameraColorGradingTexture: Nullable<BaseTexture>;
  108925. /**
  108926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108928. * 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;
  108929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108930. */
  108931. /**
  108932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108934. * 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;
  108935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108936. */
  108937. cameraColorCurves: Nullable<ColorCurves>;
  108938. /**
  108939. * Instantiates a new PBRMaterial instance.
  108940. *
  108941. * @param name The material name
  108942. * @param scene The scene the material will be use in.
  108943. */
  108944. constructor(name: string, scene: Scene);
  108945. /**
  108946. * Returns the name of this material class.
  108947. */
  108948. getClassName(): string;
  108949. /**
  108950. * Makes a duplicate of the current material.
  108951. * @param name - name to use for the new material.
  108952. */
  108953. clone(name: string): PBRMaterial;
  108954. /**
  108955. * Serializes this PBR Material.
  108956. * @returns - An object with the serialized material.
  108957. */
  108958. serialize(): any;
  108959. /**
  108960. * Parses a PBR Material from a serialized object.
  108961. * @param source - Serialized object.
  108962. * @param scene - BJS scene instance.
  108963. * @param rootUrl - url for the scene object
  108964. * @returns - PBRMaterial
  108965. */
  108966. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108967. }
  108968. }
  108969. declare module BABYLON {
  108970. /**
  108971. * Direct draw surface info
  108972. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  108973. */
  108974. export interface DDSInfo {
  108975. /**
  108976. * Width of the texture
  108977. */
  108978. width: number;
  108979. /**
  108980. * Width of the texture
  108981. */
  108982. height: number;
  108983. /**
  108984. * Number of Mipmaps for the texture
  108985. * @see https://en.wikipedia.org/wiki/Mipmap
  108986. */
  108987. mipmapCount: number;
  108988. /**
  108989. * If the textures format is a known fourCC format
  108990. * @see https://www.fourcc.org/
  108991. */
  108992. isFourCC: boolean;
  108993. /**
  108994. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  108995. */
  108996. isRGB: boolean;
  108997. /**
  108998. * If the texture is a lumincance format
  108999. */
  109000. isLuminance: boolean;
  109001. /**
  109002. * If this is a cube texture
  109003. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109004. */
  109005. isCube: boolean;
  109006. /**
  109007. * If the texture is a compressed format eg. FOURCC_DXT1
  109008. */
  109009. isCompressed: boolean;
  109010. /**
  109011. * The dxgiFormat of the texture
  109012. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109013. */
  109014. dxgiFormat: number;
  109015. /**
  109016. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109017. */
  109018. textureType: number;
  109019. /**
  109020. * Sphericle polynomial created for the dds texture
  109021. */
  109022. sphericalPolynomial?: SphericalPolynomial;
  109023. }
  109024. /**
  109025. * Class used to provide DDS decompression tools
  109026. */
  109027. export class DDSTools {
  109028. /**
  109029. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109030. */
  109031. static StoreLODInAlphaChannel: boolean;
  109032. /**
  109033. * Gets DDS information from an array buffer
  109034. * @param arrayBuffer defines the array buffer to read data from
  109035. * @returns the DDS information
  109036. */
  109037. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109038. private static _FloatView;
  109039. private static _Int32View;
  109040. private static _ToHalfFloat;
  109041. private static _FromHalfFloat;
  109042. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109043. private static _GetHalfFloatRGBAArrayBuffer;
  109044. private static _GetFloatRGBAArrayBuffer;
  109045. private static _GetFloatAsUIntRGBAArrayBuffer;
  109046. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109047. private static _GetRGBAArrayBuffer;
  109048. private static _ExtractLongWordOrder;
  109049. private static _GetRGBArrayBuffer;
  109050. private static _GetLuminanceArrayBuffer;
  109051. /**
  109052. * Uploads DDS Levels to a Babylon Texture
  109053. * @hidden
  109054. */
  109055. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109056. }
  109057. interface Engine {
  109058. /**
  109059. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109060. * @param rootUrl defines the url where the file to load is located
  109061. * @param scene defines the current scene
  109062. * @param lodScale defines scale to apply to the mip map selection
  109063. * @param lodOffset defines offset to apply to the mip map selection
  109064. * @param onLoad defines an optional callback raised when the texture is loaded
  109065. * @param onError defines an optional callback raised if there is an issue to load the texture
  109066. * @param format defines the format of the data
  109067. * @param forcedExtension defines the extension to use to pick the right loader
  109068. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109069. * @returns the cube texture as an InternalTexture
  109070. */
  109071. 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;
  109072. }
  109073. }
  109074. declare module BABYLON {
  109075. /**
  109076. * Implementation of the DDS Texture Loader.
  109077. * @hidden
  109078. */
  109079. export class _DDSTextureLoader implements IInternalTextureLoader {
  109080. /**
  109081. * Defines wether the loader supports cascade loading the different faces.
  109082. */
  109083. readonly supportCascades: boolean;
  109084. /**
  109085. * This returns if the loader support the current file information.
  109086. * @param extension defines the file extension of the file being loaded
  109087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109088. * @param fallback defines the fallback internal texture if any
  109089. * @param isBase64 defines whether the texture is encoded as a base64
  109090. * @param isBuffer defines whether the texture data are stored as a buffer
  109091. * @returns true if the loader can load the specified file
  109092. */
  109093. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109094. /**
  109095. * Transform the url before loading if required.
  109096. * @param rootUrl the url of the texture
  109097. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109098. * @returns the transformed texture
  109099. */
  109100. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109101. /**
  109102. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109103. * @param rootUrl the url of the texture
  109104. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109105. * @returns the fallback texture
  109106. */
  109107. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109108. /**
  109109. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109110. * @param data contains the texture data
  109111. * @param texture defines the BabylonJS internal texture
  109112. * @param createPolynomials will be true if polynomials have been requested
  109113. * @param onLoad defines the callback to trigger once the texture is ready
  109114. * @param onError defines the callback to trigger in case of error
  109115. */
  109116. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109117. /**
  109118. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109119. * @param data contains the texture data
  109120. * @param texture defines the BabylonJS internal texture
  109121. * @param callback defines the method to call once ready to upload
  109122. */
  109123. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109124. }
  109125. }
  109126. declare module BABYLON {
  109127. /** @hidden */
  109128. export var rgbdEncodePixelShader: {
  109129. name: string;
  109130. shader: string;
  109131. };
  109132. }
  109133. declare module BABYLON {
  109134. /**
  109135. * Raw texture data and descriptor sufficient for WebGL texture upload
  109136. */
  109137. export interface EnvironmentTextureInfo {
  109138. /**
  109139. * Version of the environment map
  109140. */
  109141. version: number;
  109142. /**
  109143. * Width of image
  109144. */
  109145. width: number;
  109146. /**
  109147. * Irradiance information stored in the file.
  109148. */
  109149. irradiance: any;
  109150. /**
  109151. * Specular information stored in the file.
  109152. */
  109153. specular: any;
  109154. }
  109155. /**
  109156. * Sets of helpers addressing the serialization and deserialization of environment texture
  109157. * stored in a BabylonJS env file.
  109158. * Those files are usually stored as .env files.
  109159. */
  109160. export class EnvironmentTextureTools {
  109161. /**
  109162. * Magic number identifying the env file.
  109163. */
  109164. private static _MagicBytes;
  109165. /**
  109166. * Gets the environment info from an env file.
  109167. * @param data The array buffer containing the .env bytes.
  109168. * @returns the environment file info (the json header) if successfully parsed.
  109169. */
  109170. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109171. /**
  109172. * Creates an environment texture from a loaded cube texture.
  109173. * @param texture defines the cube texture to convert in env file
  109174. * @return a promise containing the environment data if succesfull.
  109175. */
  109176. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109177. /**
  109178. * Creates a JSON representation of the spherical data.
  109179. * @param texture defines the texture containing the polynomials
  109180. * @return the JSON representation of the spherical info
  109181. */
  109182. private static _CreateEnvTextureIrradiance;
  109183. /**
  109184. * Uploads the texture info contained in the env file to the GPU.
  109185. * @param texture defines the internal texture to upload to
  109186. * @param arrayBuffer defines the buffer cotaining the data to load
  109187. * @param info defines the texture info retrieved through the GetEnvInfo method
  109188. * @returns a promise
  109189. */
  109190. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109191. /**
  109192. * Uploads the levels of image data to the GPU.
  109193. * @param texture defines the internal texture to upload to
  109194. * @param imageData defines the array buffer views of image data [mipmap][face]
  109195. * @returns a promise
  109196. */
  109197. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109198. /**
  109199. * Uploads spherical polynomials information to the texture.
  109200. * @param texture defines the texture we are trying to upload the information to
  109201. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109202. */
  109203. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109204. /** @hidden */
  109205. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109206. }
  109207. }
  109208. declare module BABYLON {
  109209. /**
  109210. * Implementation of the ENV Texture Loader.
  109211. * @hidden
  109212. */
  109213. export class _ENVTextureLoader implements IInternalTextureLoader {
  109214. /**
  109215. * Defines wether the loader supports cascade loading the different faces.
  109216. */
  109217. readonly supportCascades: boolean;
  109218. /**
  109219. * This returns if the loader support the current file information.
  109220. * @param extension defines the file extension of the file being loaded
  109221. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109222. * @param fallback defines the fallback internal texture if any
  109223. * @param isBase64 defines whether the texture is encoded as a base64
  109224. * @param isBuffer defines whether the texture data are stored as a buffer
  109225. * @returns true if the loader can load the specified file
  109226. */
  109227. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109228. /**
  109229. * Transform the url before loading if required.
  109230. * @param rootUrl the url of the texture
  109231. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109232. * @returns the transformed texture
  109233. */
  109234. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109235. /**
  109236. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109237. * @param rootUrl the url of the texture
  109238. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109239. * @returns the fallback texture
  109240. */
  109241. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109242. /**
  109243. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109244. * @param data contains the texture data
  109245. * @param texture defines the BabylonJS internal texture
  109246. * @param createPolynomials will be true if polynomials have been requested
  109247. * @param onLoad defines the callback to trigger once the texture is ready
  109248. * @param onError defines the callback to trigger in case of error
  109249. */
  109250. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109251. /**
  109252. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109253. * @param data contains the texture data
  109254. * @param texture defines the BabylonJS internal texture
  109255. * @param callback defines the method to call once ready to upload
  109256. */
  109257. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109258. }
  109259. }
  109260. declare module BABYLON {
  109261. /**
  109262. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109263. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109264. */
  109265. export class KhronosTextureContainer {
  109266. /** contents of the KTX container file */
  109267. arrayBuffer: any;
  109268. private static HEADER_LEN;
  109269. private static COMPRESSED_2D;
  109270. private static COMPRESSED_3D;
  109271. private static TEX_2D;
  109272. private static TEX_3D;
  109273. /**
  109274. * Gets the openGL type
  109275. */
  109276. glType: number;
  109277. /**
  109278. * Gets the openGL type size
  109279. */
  109280. glTypeSize: number;
  109281. /**
  109282. * Gets the openGL format
  109283. */
  109284. glFormat: number;
  109285. /**
  109286. * Gets the openGL internal format
  109287. */
  109288. glInternalFormat: number;
  109289. /**
  109290. * Gets the base internal format
  109291. */
  109292. glBaseInternalFormat: number;
  109293. /**
  109294. * Gets image width in pixel
  109295. */
  109296. pixelWidth: number;
  109297. /**
  109298. * Gets image height in pixel
  109299. */
  109300. pixelHeight: number;
  109301. /**
  109302. * Gets image depth in pixels
  109303. */
  109304. pixelDepth: number;
  109305. /**
  109306. * Gets the number of array elements
  109307. */
  109308. numberOfArrayElements: number;
  109309. /**
  109310. * Gets the number of faces
  109311. */
  109312. numberOfFaces: number;
  109313. /**
  109314. * Gets the number of mipmap levels
  109315. */
  109316. numberOfMipmapLevels: number;
  109317. /**
  109318. * Gets the bytes of key value data
  109319. */
  109320. bytesOfKeyValueData: number;
  109321. /**
  109322. * Gets the load type
  109323. */
  109324. loadType: number;
  109325. /**
  109326. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109327. */
  109328. isInvalid: boolean;
  109329. /**
  109330. * Creates a new KhronosTextureContainer
  109331. * @param arrayBuffer contents of the KTX container file
  109332. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109333. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109334. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109335. */
  109336. constructor(
  109337. /** contents of the KTX container file */
  109338. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109339. /**
  109340. * Uploads KTX content to a Babylon Texture.
  109341. * It is assumed that the texture has already been created & is currently bound
  109342. * @hidden
  109343. */
  109344. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109345. private _upload2DCompressedLevels;
  109346. }
  109347. }
  109348. declare module BABYLON {
  109349. /**
  109350. * Implementation of the KTX Texture Loader.
  109351. * @hidden
  109352. */
  109353. export class _KTXTextureLoader implements IInternalTextureLoader {
  109354. /**
  109355. * Defines wether the loader supports cascade loading the different faces.
  109356. */
  109357. readonly supportCascades: boolean;
  109358. /**
  109359. * This returns if the loader support the current file information.
  109360. * @param extension defines the file extension of the file being loaded
  109361. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109362. * @param fallback defines the fallback internal texture if any
  109363. * @param isBase64 defines whether the texture is encoded as a base64
  109364. * @param isBuffer defines whether the texture data are stored as a buffer
  109365. * @returns true if the loader can load the specified file
  109366. */
  109367. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109368. /**
  109369. * Transform the url before loading if required.
  109370. * @param rootUrl the url of the texture
  109371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109372. * @returns the transformed texture
  109373. */
  109374. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109375. /**
  109376. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109377. * @param rootUrl the url of the texture
  109378. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109379. * @returns the fallback texture
  109380. */
  109381. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109382. /**
  109383. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109384. * @param data contains the texture data
  109385. * @param texture defines the BabylonJS internal texture
  109386. * @param createPolynomials will be true if polynomials have been requested
  109387. * @param onLoad defines the callback to trigger once the texture is ready
  109388. * @param onError defines the callback to trigger in case of error
  109389. */
  109390. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109391. /**
  109392. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109393. * @param data contains the texture data
  109394. * @param texture defines the BabylonJS internal texture
  109395. * @param callback defines the method to call once ready to upload
  109396. */
  109397. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109398. }
  109399. }
  109400. declare module BABYLON {
  109401. /** @hidden */
  109402. export var _forceSceneHelpersToBundle: boolean;
  109403. interface Scene {
  109404. /**
  109405. * Creates a default light for the scene.
  109406. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109407. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109408. */
  109409. createDefaultLight(replace?: boolean): void;
  109410. /**
  109411. * Creates a default camera for the scene.
  109412. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109413. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109414. * @param replace has default false, when true replaces the active camera in the scene
  109415. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109416. */
  109417. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109418. /**
  109419. * Creates a default camera and a default light.
  109420. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109421. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109422. * @param replace has the default false, when true replaces the active camera/light in the scene
  109423. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109424. */
  109425. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109426. /**
  109427. * Creates a new sky box
  109428. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109429. * @param environmentTexture defines the texture to use as environment texture
  109430. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109431. * @param scale defines the overall scale of the skybox
  109432. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109433. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109434. * @returns a new mesh holding the sky box
  109435. */
  109436. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109437. /**
  109438. * Creates a new environment
  109439. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109440. * @param options defines the options you can use to configure the environment
  109441. * @returns the new EnvironmentHelper
  109442. */
  109443. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109444. /**
  109445. * Creates a new VREXperienceHelper
  109446. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109447. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109448. * @returns a new VREXperienceHelper
  109449. */
  109450. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109451. /**
  109452. * Creates a new XREXperienceHelper
  109453. * @see http://doc.babylonjs.com/how_to/webxr
  109454. * @returns a promise for a new XREXperienceHelper
  109455. */
  109456. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109457. }
  109458. }
  109459. declare module BABYLON {
  109460. /**
  109461. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109462. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109463. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109464. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109465. */
  109466. export class VideoDome extends TransformNode {
  109467. /**
  109468. * Define the video source as a Monoscopic panoramic 360 video.
  109469. */
  109470. static readonly MODE_MONOSCOPIC: number;
  109471. /**
  109472. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109473. */
  109474. static readonly MODE_TOPBOTTOM: number;
  109475. /**
  109476. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109477. */
  109478. static readonly MODE_SIDEBYSIDE: number;
  109479. private _useDirectMapping;
  109480. /**
  109481. * The video texture being displayed on the sphere
  109482. */
  109483. protected _videoTexture: VideoTexture;
  109484. /**
  109485. * Gets the video texture being displayed on the sphere
  109486. */
  109487. readonly videoTexture: VideoTexture;
  109488. /**
  109489. * The skybox material
  109490. */
  109491. protected _material: BackgroundMaterial;
  109492. /**
  109493. * The surface used for the skybox
  109494. */
  109495. protected _mesh: Mesh;
  109496. /**
  109497. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109498. * Also see the options.resolution property.
  109499. */
  109500. fovMultiplier: number;
  109501. private _videoMode;
  109502. /**
  109503. * Gets or set the current video mode for the video. It can be:
  109504. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109505. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109506. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109507. */
  109508. videoMode: number;
  109509. /**
  109510. * Oberserver used in Stereoscopic VR Mode.
  109511. */
  109512. private _onBeforeCameraRenderObserver;
  109513. /**
  109514. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109515. * @param name Element's name, child elements will append suffixes for their own names.
  109516. * @param urlsOrVideo defines the url(s) or the video element to use
  109517. * @param options An object containing optional or exposed sub element properties
  109518. */
  109519. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109520. resolution?: number;
  109521. clickToPlay?: boolean;
  109522. autoPlay?: boolean;
  109523. loop?: boolean;
  109524. size?: number;
  109525. poster?: string;
  109526. faceForward?: boolean;
  109527. useDirectMapping?: boolean;
  109528. }, scene: Scene);
  109529. private _changeVideoMode;
  109530. /**
  109531. * Releases resources associated with this node.
  109532. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109533. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109534. */
  109535. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109536. }
  109537. }
  109538. declare module BABYLON {
  109539. /**
  109540. * This class can be used to get instrumentation data from a Babylon engine
  109541. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109542. */
  109543. export class EngineInstrumentation implements IDisposable {
  109544. /**
  109545. * Define the instrumented engine.
  109546. */
  109547. engine: Engine;
  109548. private _captureGPUFrameTime;
  109549. private _gpuFrameTimeToken;
  109550. private _gpuFrameTime;
  109551. private _captureShaderCompilationTime;
  109552. private _shaderCompilationTime;
  109553. private _onBeginFrameObserver;
  109554. private _onEndFrameObserver;
  109555. private _onBeforeShaderCompilationObserver;
  109556. private _onAfterShaderCompilationObserver;
  109557. /**
  109558. * Gets the perf counter used for GPU frame time
  109559. */
  109560. readonly gpuFrameTimeCounter: PerfCounter;
  109561. /**
  109562. * Gets the GPU frame time capture status
  109563. */
  109564. /**
  109565. * Enable or disable the GPU frame time capture
  109566. */
  109567. captureGPUFrameTime: boolean;
  109568. /**
  109569. * Gets the perf counter used for shader compilation time
  109570. */
  109571. readonly shaderCompilationTimeCounter: PerfCounter;
  109572. /**
  109573. * Gets the shader compilation time capture status
  109574. */
  109575. /**
  109576. * Enable or disable the shader compilation time capture
  109577. */
  109578. captureShaderCompilationTime: boolean;
  109579. /**
  109580. * Instantiates a new engine instrumentation.
  109581. * This class can be used to get instrumentation data from a Babylon engine
  109582. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109583. * @param engine Defines the engine to instrument
  109584. */
  109585. constructor(
  109586. /**
  109587. * Define the instrumented engine.
  109588. */
  109589. engine: Engine);
  109590. /**
  109591. * Dispose and release associated resources.
  109592. */
  109593. dispose(): void;
  109594. }
  109595. }
  109596. declare module BABYLON {
  109597. /**
  109598. * This class can be used to get instrumentation data from a Babylon engine
  109599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109600. */
  109601. export class SceneInstrumentation implements IDisposable {
  109602. /**
  109603. * Defines the scene to instrument
  109604. */
  109605. scene: Scene;
  109606. private _captureActiveMeshesEvaluationTime;
  109607. private _activeMeshesEvaluationTime;
  109608. private _captureRenderTargetsRenderTime;
  109609. private _renderTargetsRenderTime;
  109610. private _captureFrameTime;
  109611. private _frameTime;
  109612. private _captureRenderTime;
  109613. private _renderTime;
  109614. private _captureInterFrameTime;
  109615. private _interFrameTime;
  109616. private _captureParticlesRenderTime;
  109617. private _particlesRenderTime;
  109618. private _captureSpritesRenderTime;
  109619. private _spritesRenderTime;
  109620. private _capturePhysicsTime;
  109621. private _physicsTime;
  109622. private _captureAnimationsTime;
  109623. private _animationsTime;
  109624. private _captureCameraRenderTime;
  109625. private _cameraRenderTime;
  109626. private _onBeforeActiveMeshesEvaluationObserver;
  109627. private _onAfterActiveMeshesEvaluationObserver;
  109628. private _onBeforeRenderTargetsRenderObserver;
  109629. private _onAfterRenderTargetsRenderObserver;
  109630. private _onAfterRenderObserver;
  109631. private _onBeforeDrawPhaseObserver;
  109632. private _onAfterDrawPhaseObserver;
  109633. private _onBeforeAnimationsObserver;
  109634. private _onBeforeParticlesRenderingObserver;
  109635. private _onAfterParticlesRenderingObserver;
  109636. private _onBeforeSpritesRenderingObserver;
  109637. private _onAfterSpritesRenderingObserver;
  109638. private _onBeforePhysicsObserver;
  109639. private _onAfterPhysicsObserver;
  109640. private _onAfterAnimationsObserver;
  109641. private _onBeforeCameraRenderObserver;
  109642. private _onAfterCameraRenderObserver;
  109643. /**
  109644. * Gets the perf counter used for active meshes evaluation time
  109645. */
  109646. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  109647. /**
  109648. * Gets the active meshes evaluation time capture status
  109649. */
  109650. /**
  109651. * Enable or disable the active meshes evaluation time capture
  109652. */
  109653. captureActiveMeshesEvaluationTime: boolean;
  109654. /**
  109655. * Gets the perf counter used for render targets render time
  109656. */
  109657. readonly renderTargetsRenderTimeCounter: PerfCounter;
  109658. /**
  109659. * Gets the render targets render time capture status
  109660. */
  109661. /**
  109662. * Enable or disable the render targets render time capture
  109663. */
  109664. captureRenderTargetsRenderTime: boolean;
  109665. /**
  109666. * Gets the perf counter used for particles render time
  109667. */
  109668. readonly particlesRenderTimeCounter: PerfCounter;
  109669. /**
  109670. * Gets the particles render time capture status
  109671. */
  109672. /**
  109673. * Enable or disable the particles render time capture
  109674. */
  109675. captureParticlesRenderTime: boolean;
  109676. /**
  109677. * Gets the perf counter used for sprites render time
  109678. */
  109679. readonly spritesRenderTimeCounter: PerfCounter;
  109680. /**
  109681. * Gets the sprites render time capture status
  109682. */
  109683. /**
  109684. * Enable or disable the sprites render time capture
  109685. */
  109686. captureSpritesRenderTime: boolean;
  109687. /**
  109688. * Gets the perf counter used for physics time
  109689. */
  109690. readonly physicsTimeCounter: PerfCounter;
  109691. /**
  109692. * Gets the physics time capture status
  109693. */
  109694. /**
  109695. * Enable or disable the physics time capture
  109696. */
  109697. capturePhysicsTime: boolean;
  109698. /**
  109699. * Gets the perf counter used for animations time
  109700. */
  109701. readonly animationsTimeCounter: PerfCounter;
  109702. /**
  109703. * Gets the animations time capture status
  109704. */
  109705. /**
  109706. * Enable or disable the animations time capture
  109707. */
  109708. captureAnimationsTime: boolean;
  109709. /**
  109710. * Gets the perf counter used for frame time capture
  109711. */
  109712. readonly frameTimeCounter: PerfCounter;
  109713. /**
  109714. * Gets the frame time capture status
  109715. */
  109716. /**
  109717. * Enable or disable the frame time capture
  109718. */
  109719. captureFrameTime: boolean;
  109720. /**
  109721. * Gets the perf counter used for inter-frames time capture
  109722. */
  109723. readonly interFrameTimeCounter: PerfCounter;
  109724. /**
  109725. * Gets the inter-frames time capture status
  109726. */
  109727. /**
  109728. * Enable or disable the inter-frames time capture
  109729. */
  109730. captureInterFrameTime: boolean;
  109731. /**
  109732. * Gets the perf counter used for render time capture
  109733. */
  109734. readonly renderTimeCounter: PerfCounter;
  109735. /**
  109736. * Gets the render time capture status
  109737. */
  109738. /**
  109739. * Enable or disable the render time capture
  109740. */
  109741. captureRenderTime: boolean;
  109742. /**
  109743. * Gets the perf counter used for camera render time capture
  109744. */
  109745. readonly cameraRenderTimeCounter: PerfCounter;
  109746. /**
  109747. * Gets the camera render time capture status
  109748. */
  109749. /**
  109750. * Enable or disable the camera render time capture
  109751. */
  109752. captureCameraRenderTime: boolean;
  109753. /**
  109754. * Gets the perf counter used for draw calls
  109755. */
  109756. readonly drawCallsCounter: PerfCounter;
  109757. /**
  109758. * Instantiates a new scene instrumentation.
  109759. * This class can be used to get instrumentation data from a Babylon engine
  109760. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109761. * @param scene Defines the scene to instrument
  109762. */
  109763. constructor(
  109764. /**
  109765. * Defines the scene to instrument
  109766. */
  109767. scene: Scene);
  109768. /**
  109769. * Dispose and release associated resources.
  109770. */
  109771. dispose(): void;
  109772. }
  109773. }
  109774. declare module BABYLON {
  109775. /** @hidden */
  109776. export var glowMapGenerationPixelShader: {
  109777. name: string;
  109778. shader: string;
  109779. };
  109780. }
  109781. declare module BABYLON {
  109782. /** @hidden */
  109783. export var glowMapGenerationVertexShader: {
  109784. name: string;
  109785. shader: string;
  109786. };
  109787. }
  109788. declare module BABYLON {
  109789. /**
  109790. * Effect layer options. This helps customizing the behaviour
  109791. * of the effect layer.
  109792. */
  109793. export interface IEffectLayerOptions {
  109794. /**
  109795. * Multiplication factor apply to the canvas size to compute the render target size
  109796. * used to generated the objects (the smaller the faster).
  109797. */
  109798. mainTextureRatio: number;
  109799. /**
  109800. * Enforces a fixed size texture to ensure effect stability across devices.
  109801. */
  109802. mainTextureFixedSize?: number;
  109803. /**
  109804. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  109805. */
  109806. alphaBlendingMode: number;
  109807. /**
  109808. * The camera attached to the layer.
  109809. */
  109810. camera: Nullable<Camera>;
  109811. /**
  109812. * The rendering group to draw the layer in.
  109813. */
  109814. renderingGroupId: number;
  109815. }
  109816. /**
  109817. * The effect layer Helps adding post process effect blended with the main pass.
  109818. *
  109819. * This can be for instance use to generate glow or higlight effects on the scene.
  109820. *
  109821. * The effect layer class can not be used directly and is intented to inherited from to be
  109822. * customized per effects.
  109823. */
  109824. export abstract class EffectLayer {
  109825. private _vertexBuffers;
  109826. private _indexBuffer;
  109827. private _cachedDefines;
  109828. private _effectLayerMapGenerationEffect;
  109829. private _effectLayerOptions;
  109830. private _mergeEffect;
  109831. protected _scene: Scene;
  109832. protected _engine: Engine;
  109833. protected _maxSize: number;
  109834. protected _mainTextureDesiredSize: ISize;
  109835. protected _mainTexture: RenderTargetTexture;
  109836. protected _shouldRender: boolean;
  109837. protected _postProcesses: PostProcess[];
  109838. protected _textures: BaseTexture[];
  109839. protected _emissiveTextureAndColor: {
  109840. texture: Nullable<BaseTexture>;
  109841. color: Color4;
  109842. };
  109843. /**
  109844. * The name of the layer
  109845. */
  109846. name: string;
  109847. /**
  109848. * The clear color of the texture used to generate the glow map.
  109849. */
  109850. neutralColor: Color4;
  109851. /**
  109852. * Specifies wether the highlight layer is enabled or not.
  109853. */
  109854. isEnabled: boolean;
  109855. /**
  109856. * Gets the camera attached to the layer.
  109857. */
  109858. readonly camera: Nullable<Camera>;
  109859. /**
  109860. * Gets the rendering group id the layer should render in.
  109861. */
  109862. readonly renderingGroupId: number;
  109863. /**
  109864. * An event triggered when the effect layer has been disposed.
  109865. */
  109866. onDisposeObservable: Observable<EffectLayer>;
  109867. /**
  109868. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  109869. */
  109870. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  109871. /**
  109872. * An event triggered when the generated texture is being merged in the scene.
  109873. */
  109874. onBeforeComposeObservable: Observable<EffectLayer>;
  109875. /**
  109876. * An event triggered when the generated texture has been merged in the scene.
  109877. */
  109878. onAfterComposeObservable: Observable<EffectLayer>;
  109879. /**
  109880. * An event triggered when the efffect layer changes its size.
  109881. */
  109882. onSizeChangedObservable: Observable<EffectLayer>;
  109883. /** @hidden */
  109884. static _SceneComponentInitialization: (scene: Scene) => void;
  109885. /**
  109886. * Instantiates a new effect Layer and references it in the scene.
  109887. * @param name The name of the layer
  109888. * @param scene The scene to use the layer in
  109889. */
  109890. constructor(
  109891. /** The Friendly of the effect in the scene */
  109892. name: string, scene: Scene);
  109893. /**
  109894. * Get the effect name of the layer.
  109895. * @return The effect name
  109896. */
  109897. abstract getEffectName(): string;
  109898. /**
  109899. * Checks for the readiness of the element composing the layer.
  109900. * @param subMesh the mesh to check for
  109901. * @param useInstances specify wether or not to use instances to render the mesh
  109902. * @return true if ready otherwise, false
  109903. */
  109904. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109905. /**
  109906. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109907. * @returns true if the effect requires stencil during the main canvas render pass.
  109908. */
  109909. abstract needStencil(): boolean;
  109910. /**
  109911. * Create the merge effect. This is the shader use to blit the information back
  109912. * to the main canvas at the end of the scene rendering.
  109913. * @returns The effect containing the shader used to merge the effect on the main canvas
  109914. */
  109915. protected abstract _createMergeEffect(): Effect;
  109916. /**
  109917. * Creates the render target textures and post processes used in the effect layer.
  109918. */
  109919. protected abstract _createTextureAndPostProcesses(): void;
  109920. /**
  109921. * Implementation specific of rendering the generating effect on the main canvas.
  109922. * @param effect The effect used to render through
  109923. */
  109924. protected abstract _internalRender(effect: Effect): void;
  109925. /**
  109926. * Sets the required values for both the emissive texture and and the main color.
  109927. */
  109928. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109929. /**
  109930. * Free any resources and references associated to a mesh.
  109931. * Internal use
  109932. * @param mesh The mesh to free.
  109933. */
  109934. abstract _disposeMesh(mesh: Mesh): void;
  109935. /**
  109936. * Serializes this layer (Glow or Highlight for example)
  109937. * @returns a serialized layer object
  109938. */
  109939. abstract serialize?(): any;
  109940. /**
  109941. * Initializes the effect layer with the required options.
  109942. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  109943. */
  109944. protected _init(options: Partial<IEffectLayerOptions>): void;
  109945. /**
  109946. * Generates the index buffer of the full screen quad blending to the main canvas.
  109947. */
  109948. private _generateIndexBuffer;
  109949. /**
  109950. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  109951. */
  109952. private _generateVertexBuffer;
  109953. /**
  109954. * Sets the main texture desired size which is the closest power of two
  109955. * of the engine canvas size.
  109956. */
  109957. private _setMainTextureSize;
  109958. /**
  109959. * Creates the main texture for the effect layer.
  109960. */
  109961. protected _createMainTexture(): void;
  109962. /**
  109963. * Adds specific effects defines.
  109964. * @param defines The defines to add specifics to.
  109965. */
  109966. protected _addCustomEffectDefines(defines: string[]): void;
  109967. /**
  109968. * Checks for the readiness of the element composing the layer.
  109969. * @param subMesh the mesh to check for
  109970. * @param useInstances specify wether or not to use instances to render the mesh
  109971. * @param emissiveTexture the associated emissive texture used to generate the glow
  109972. * @return true if ready otherwise, false
  109973. */
  109974. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  109975. /**
  109976. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  109977. */
  109978. render(): void;
  109979. /**
  109980. * Determine if a given mesh will be used in the current effect.
  109981. * @param mesh mesh to test
  109982. * @returns true if the mesh will be used
  109983. */
  109984. hasMesh(mesh: AbstractMesh): boolean;
  109985. /**
  109986. * Returns true if the layer contains information to display, otherwise false.
  109987. * @returns true if the glow layer should be rendered
  109988. */
  109989. shouldRender(): boolean;
  109990. /**
  109991. * Returns true if the mesh should render, otherwise false.
  109992. * @param mesh The mesh to render
  109993. * @returns true if it should render otherwise false
  109994. */
  109995. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  109996. /**
  109997. * Returns true if the mesh can be rendered, otherwise false.
  109998. * @param mesh The mesh to render
  109999. * @param material The material used on the mesh
  110000. * @returns true if it can be rendered otherwise false
  110001. */
  110002. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110003. /**
  110004. * Returns true if the mesh should render, otherwise false.
  110005. * @param mesh The mesh to render
  110006. * @returns true if it should render otherwise false
  110007. */
  110008. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110009. /**
  110010. * Renders the submesh passed in parameter to the generation map.
  110011. */
  110012. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110013. /**
  110014. * Rebuild the required buffers.
  110015. * @hidden Internal use only.
  110016. */
  110017. _rebuild(): void;
  110018. /**
  110019. * Dispose only the render target textures and post process.
  110020. */
  110021. private _disposeTextureAndPostProcesses;
  110022. /**
  110023. * Dispose the highlight layer and free resources.
  110024. */
  110025. dispose(): void;
  110026. /**
  110027. * Gets the class name of the effect layer
  110028. * @returns the string with the class name of the effect layer
  110029. */
  110030. getClassName(): string;
  110031. /**
  110032. * Creates an effect layer from parsed effect layer data
  110033. * @param parsedEffectLayer defines effect layer data
  110034. * @param scene defines the current scene
  110035. * @param rootUrl defines the root URL containing the effect layer information
  110036. * @returns a parsed effect Layer
  110037. */
  110038. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110039. }
  110040. }
  110041. declare module BABYLON {
  110042. interface AbstractScene {
  110043. /**
  110044. * The list of effect layers (highlights/glow) added to the scene
  110045. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110046. * @see http://doc.babylonjs.com/how_to/glow_layer
  110047. */
  110048. effectLayers: Array<EffectLayer>;
  110049. /**
  110050. * Removes the given effect layer from this scene.
  110051. * @param toRemove defines the effect layer to remove
  110052. * @returns the index of the removed effect layer
  110053. */
  110054. removeEffectLayer(toRemove: EffectLayer): number;
  110055. /**
  110056. * Adds the given effect layer to this scene
  110057. * @param newEffectLayer defines the effect layer to add
  110058. */
  110059. addEffectLayer(newEffectLayer: EffectLayer): void;
  110060. }
  110061. /**
  110062. * Defines the layer scene component responsible to manage any effect layers
  110063. * in a given scene.
  110064. */
  110065. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110066. /**
  110067. * The component name helpfull to identify the component in the list of scene components.
  110068. */
  110069. readonly name: string;
  110070. /**
  110071. * The scene the component belongs to.
  110072. */
  110073. scene: Scene;
  110074. private _engine;
  110075. private _renderEffects;
  110076. private _needStencil;
  110077. private _previousStencilState;
  110078. /**
  110079. * Creates a new instance of the component for the given scene
  110080. * @param scene Defines the scene to register the component in
  110081. */
  110082. constructor(scene: Scene);
  110083. /**
  110084. * Registers the component in a given scene
  110085. */
  110086. register(): void;
  110087. /**
  110088. * Rebuilds the elements related to this component in case of
  110089. * context lost for instance.
  110090. */
  110091. rebuild(): void;
  110092. /**
  110093. * Serializes the component data to the specified json object
  110094. * @param serializationObject The object to serialize to
  110095. */
  110096. serialize(serializationObject: any): void;
  110097. /**
  110098. * Adds all the elements from the container to the scene
  110099. * @param container the container holding the elements
  110100. */
  110101. addFromContainer(container: AbstractScene): void;
  110102. /**
  110103. * Removes all the elements in the container from the scene
  110104. * @param container contains the elements to remove
  110105. * @param dispose if the removed element should be disposed (default: false)
  110106. */
  110107. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110108. /**
  110109. * Disposes the component and the associated ressources.
  110110. */
  110111. dispose(): void;
  110112. private _isReadyForMesh;
  110113. private _renderMainTexture;
  110114. private _setStencil;
  110115. private _setStencilBack;
  110116. private _draw;
  110117. private _drawCamera;
  110118. private _drawRenderingGroup;
  110119. }
  110120. }
  110121. declare module BABYLON {
  110122. /** @hidden */
  110123. export var glowMapMergePixelShader: {
  110124. name: string;
  110125. shader: string;
  110126. };
  110127. }
  110128. declare module BABYLON {
  110129. /** @hidden */
  110130. export var glowMapMergeVertexShader: {
  110131. name: string;
  110132. shader: string;
  110133. };
  110134. }
  110135. declare module BABYLON {
  110136. interface AbstractScene {
  110137. /**
  110138. * Return a the first highlight layer of the scene with a given name.
  110139. * @param name The name of the highlight layer to look for.
  110140. * @return The highlight layer if found otherwise null.
  110141. */
  110142. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110143. }
  110144. /**
  110145. * Glow layer options. This helps customizing the behaviour
  110146. * of the glow layer.
  110147. */
  110148. export interface IGlowLayerOptions {
  110149. /**
  110150. * Multiplication factor apply to the canvas size to compute the render target size
  110151. * used to generated the glowing objects (the smaller the faster).
  110152. */
  110153. mainTextureRatio: number;
  110154. /**
  110155. * Enforces a fixed size texture to ensure resize independant blur.
  110156. */
  110157. mainTextureFixedSize?: number;
  110158. /**
  110159. * How big is the kernel of the blur texture.
  110160. */
  110161. blurKernelSize: number;
  110162. /**
  110163. * The camera attached to the layer.
  110164. */
  110165. camera: Nullable<Camera>;
  110166. /**
  110167. * Enable MSAA by chosing the number of samples.
  110168. */
  110169. mainTextureSamples?: number;
  110170. /**
  110171. * The rendering group to draw the layer in.
  110172. */
  110173. renderingGroupId: number;
  110174. }
  110175. /**
  110176. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110177. *
  110178. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110179. * glowy meshes to your scene.
  110180. *
  110181. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110182. */
  110183. export class GlowLayer extends EffectLayer {
  110184. /**
  110185. * Effect Name of the layer.
  110186. */
  110187. static readonly EffectName: string;
  110188. /**
  110189. * The default blur kernel size used for the glow.
  110190. */
  110191. static DefaultBlurKernelSize: number;
  110192. /**
  110193. * The default texture size ratio used for the glow.
  110194. */
  110195. static DefaultTextureRatio: number;
  110196. /**
  110197. * Sets the kernel size of the blur.
  110198. */
  110199. /**
  110200. * Gets the kernel size of the blur.
  110201. */
  110202. blurKernelSize: number;
  110203. /**
  110204. * Sets the glow intensity.
  110205. */
  110206. /**
  110207. * Gets the glow intensity.
  110208. */
  110209. intensity: number;
  110210. private _options;
  110211. private _intensity;
  110212. private _horizontalBlurPostprocess1;
  110213. private _verticalBlurPostprocess1;
  110214. private _horizontalBlurPostprocess2;
  110215. private _verticalBlurPostprocess2;
  110216. private _blurTexture1;
  110217. private _blurTexture2;
  110218. private _postProcesses1;
  110219. private _postProcesses2;
  110220. private _includedOnlyMeshes;
  110221. private _excludedMeshes;
  110222. /**
  110223. * Callback used to let the user override the color selection on a per mesh basis
  110224. */
  110225. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110226. /**
  110227. * Callback used to let the user override the texture selection on a per mesh basis
  110228. */
  110229. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110230. /**
  110231. * Instantiates a new glow Layer and references it to the scene.
  110232. * @param name The name of the layer
  110233. * @param scene The scene to use the layer in
  110234. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110235. */
  110236. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110237. /**
  110238. * Get the effect name of the layer.
  110239. * @return The effect name
  110240. */
  110241. getEffectName(): string;
  110242. /**
  110243. * Create the merge effect. This is the shader use to blit the information back
  110244. * to the main canvas at the end of the scene rendering.
  110245. */
  110246. protected _createMergeEffect(): Effect;
  110247. /**
  110248. * Creates the render target textures and post processes used in the glow layer.
  110249. */
  110250. protected _createTextureAndPostProcesses(): void;
  110251. /**
  110252. * Checks for the readiness of the element composing the layer.
  110253. * @param subMesh the mesh to check for
  110254. * @param useInstances specify wether or not to use instances to render the mesh
  110255. * @param emissiveTexture the associated emissive texture used to generate the glow
  110256. * @return true if ready otherwise, false
  110257. */
  110258. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110259. /**
  110260. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110261. */
  110262. needStencil(): boolean;
  110263. /**
  110264. * Returns true if the mesh can be rendered, otherwise false.
  110265. * @param mesh The mesh to render
  110266. * @param material The material used on the mesh
  110267. * @returns true if it can be rendered otherwise false
  110268. */
  110269. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110270. /**
  110271. * Implementation specific of rendering the generating effect on the main canvas.
  110272. * @param effect The effect used to render through
  110273. */
  110274. protected _internalRender(effect: Effect): void;
  110275. /**
  110276. * Sets the required values for both the emissive texture and and the main color.
  110277. */
  110278. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110279. /**
  110280. * Returns true if the mesh should render, otherwise false.
  110281. * @param mesh The mesh to render
  110282. * @returns true if it should render otherwise false
  110283. */
  110284. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110285. /**
  110286. * Adds specific effects defines.
  110287. * @param defines The defines to add specifics to.
  110288. */
  110289. protected _addCustomEffectDefines(defines: string[]): void;
  110290. /**
  110291. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110292. * @param mesh The mesh to exclude from the glow layer
  110293. */
  110294. addExcludedMesh(mesh: Mesh): void;
  110295. /**
  110296. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110297. * @param mesh The mesh to remove
  110298. */
  110299. removeExcludedMesh(mesh: Mesh): void;
  110300. /**
  110301. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110302. * @param mesh The mesh to include in the glow layer
  110303. */
  110304. addIncludedOnlyMesh(mesh: Mesh): void;
  110305. /**
  110306. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110307. * @param mesh The mesh to remove
  110308. */
  110309. removeIncludedOnlyMesh(mesh: Mesh): void;
  110310. /**
  110311. * Determine if a given mesh will be used in the glow layer
  110312. * @param mesh The mesh to test
  110313. * @returns true if the mesh will be highlighted by the current glow layer
  110314. */
  110315. hasMesh(mesh: AbstractMesh): boolean;
  110316. /**
  110317. * Free any resources and references associated to a mesh.
  110318. * Internal use
  110319. * @param mesh The mesh to free.
  110320. * @hidden
  110321. */
  110322. _disposeMesh(mesh: Mesh): void;
  110323. /**
  110324. * Gets the class name of the effect layer
  110325. * @returns the string with the class name of the effect layer
  110326. */
  110327. getClassName(): string;
  110328. /**
  110329. * Serializes this glow layer
  110330. * @returns a serialized glow layer object
  110331. */
  110332. serialize(): any;
  110333. /**
  110334. * Creates a Glow Layer from parsed glow layer data
  110335. * @param parsedGlowLayer defines glow layer data
  110336. * @param scene defines the current scene
  110337. * @param rootUrl defines the root URL containing the glow layer information
  110338. * @returns a parsed Glow Layer
  110339. */
  110340. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110341. }
  110342. }
  110343. declare module BABYLON {
  110344. /** @hidden */
  110345. export var glowBlurPostProcessPixelShader: {
  110346. name: string;
  110347. shader: string;
  110348. };
  110349. }
  110350. declare module BABYLON {
  110351. interface AbstractScene {
  110352. /**
  110353. * Return a the first highlight layer of the scene with a given name.
  110354. * @param name The name of the highlight layer to look for.
  110355. * @return The highlight layer if found otherwise null.
  110356. */
  110357. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110358. }
  110359. /**
  110360. * Highlight layer options. This helps customizing the behaviour
  110361. * of the highlight layer.
  110362. */
  110363. export interface IHighlightLayerOptions {
  110364. /**
  110365. * Multiplication factor apply to the canvas size to compute the render target size
  110366. * used to generated the glowing objects (the smaller the faster).
  110367. */
  110368. mainTextureRatio: number;
  110369. /**
  110370. * Enforces a fixed size texture to ensure resize independant blur.
  110371. */
  110372. mainTextureFixedSize?: number;
  110373. /**
  110374. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110375. * of the picture to blur (the smaller the faster).
  110376. */
  110377. blurTextureSizeRatio: number;
  110378. /**
  110379. * How big in texel of the blur texture is the vertical blur.
  110380. */
  110381. blurVerticalSize: number;
  110382. /**
  110383. * How big in texel of the blur texture is the horizontal blur.
  110384. */
  110385. blurHorizontalSize: number;
  110386. /**
  110387. * Alpha blending mode used to apply the blur. Default is combine.
  110388. */
  110389. alphaBlendingMode: number;
  110390. /**
  110391. * The camera attached to the layer.
  110392. */
  110393. camera: Nullable<Camera>;
  110394. /**
  110395. * Should we display highlight as a solid stroke?
  110396. */
  110397. isStroke?: boolean;
  110398. /**
  110399. * The rendering group to draw the layer in.
  110400. */
  110401. renderingGroupId: number;
  110402. }
  110403. /**
  110404. * The highlight layer Helps adding a glow effect around a mesh.
  110405. *
  110406. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110407. * glowy meshes to your scene.
  110408. *
  110409. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110410. */
  110411. export class HighlightLayer extends EffectLayer {
  110412. name: string;
  110413. /**
  110414. * Effect Name of the highlight layer.
  110415. */
  110416. static readonly EffectName: string;
  110417. /**
  110418. * The neutral color used during the preparation of the glow effect.
  110419. * This is black by default as the blend operation is a blend operation.
  110420. */
  110421. static NeutralColor: Color4;
  110422. /**
  110423. * Stencil value used for glowing meshes.
  110424. */
  110425. static GlowingMeshStencilReference: number;
  110426. /**
  110427. * Stencil value used for the other meshes in the scene.
  110428. */
  110429. static NormalMeshStencilReference: number;
  110430. /**
  110431. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110432. */
  110433. innerGlow: boolean;
  110434. /**
  110435. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110436. */
  110437. outerGlow: boolean;
  110438. /**
  110439. * Specifies the horizontal size of the blur.
  110440. */
  110441. /**
  110442. * Gets the horizontal size of the blur.
  110443. */
  110444. blurHorizontalSize: number;
  110445. /**
  110446. * Specifies the vertical size of the blur.
  110447. */
  110448. /**
  110449. * Gets the vertical size of the blur.
  110450. */
  110451. blurVerticalSize: number;
  110452. /**
  110453. * An event triggered when the highlight layer is being blurred.
  110454. */
  110455. onBeforeBlurObservable: Observable<HighlightLayer>;
  110456. /**
  110457. * An event triggered when the highlight layer has been blurred.
  110458. */
  110459. onAfterBlurObservable: Observable<HighlightLayer>;
  110460. private _instanceGlowingMeshStencilReference;
  110461. private _options;
  110462. private _downSamplePostprocess;
  110463. private _horizontalBlurPostprocess;
  110464. private _verticalBlurPostprocess;
  110465. private _blurTexture;
  110466. private _meshes;
  110467. private _excludedMeshes;
  110468. /**
  110469. * Instantiates a new highlight Layer and references it to the scene..
  110470. * @param name The name of the layer
  110471. * @param scene The scene to use the layer in
  110472. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110473. */
  110474. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110475. /**
  110476. * Get the effect name of the layer.
  110477. * @return The effect name
  110478. */
  110479. getEffectName(): string;
  110480. /**
  110481. * Create the merge effect. This is the shader use to blit the information back
  110482. * to the main canvas at the end of the scene rendering.
  110483. */
  110484. protected _createMergeEffect(): Effect;
  110485. /**
  110486. * Creates the render target textures and post processes used in the highlight layer.
  110487. */
  110488. protected _createTextureAndPostProcesses(): void;
  110489. /**
  110490. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110491. */
  110492. needStencil(): boolean;
  110493. /**
  110494. * Checks for the readiness of the element composing the layer.
  110495. * @param subMesh the mesh to check for
  110496. * @param useInstances specify wether or not to use instances to render the mesh
  110497. * @param emissiveTexture the associated emissive texture used to generate the glow
  110498. * @return true if ready otherwise, false
  110499. */
  110500. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110501. /**
  110502. * Implementation specific of rendering the generating effect on the main canvas.
  110503. * @param effect The effect used to render through
  110504. */
  110505. protected _internalRender(effect: Effect): void;
  110506. /**
  110507. * Returns true if the layer contains information to display, otherwise false.
  110508. */
  110509. shouldRender(): boolean;
  110510. /**
  110511. * Returns true if the mesh should render, otherwise false.
  110512. * @param mesh The mesh to render
  110513. * @returns true if it should render otherwise false
  110514. */
  110515. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110516. /**
  110517. * Sets the required values for both the emissive texture and and the main color.
  110518. */
  110519. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110520. /**
  110521. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110522. * @param mesh The mesh to exclude from the highlight layer
  110523. */
  110524. addExcludedMesh(mesh: Mesh): void;
  110525. /**
  110526. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110527. * @param mesh The mesh to highlight
  110528. */
  110529. removeExcludedMesh(mesh: Mesh): void;
  110530. /**
  110531. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110532. * @param mesh mesh to test
  110533. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110534. */
  110535. hasMesh(mesh: AbstractMesh): boolean;
  110536. /**
  110537. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110538. * @param mesh The mesh to highlight
  110539. * @param color The color of the highlight
  110540. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110541. */
  110542. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110543. /**
  110544. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110545. * @param mesh The mesh to highlight
  110546. */
  110547. removeMesh(mesh: Mesh): void;
  110548. /**
  110549. * Force the stencil to the normal expected value for none glowing parts
  110550. */
  110551. private _defaultStencilReference;
  110552. /**
  110553. * Free any resources and references associated to a mesh.
  110554. * Internal use
  110555. * @param mesh The mesh to free.
  110556. * @hidden
  110557. */
  110558. _disposeMesh(mesh: Mesh): void;
  110559. /**
  110560. * Dispose the highlight layer and free resources.
  110561. */
  110562. dispose(): void;
  110563. /**
  110564. * Gets the class name of the effect layer
  110565. * @returns the string with the class name of the effect layer
  110566. */
  110567. getClassName(): string;
  110568. /**
  110569. * Serializes this Highlight layer
  110570. * @returns a serialized Highlight layer object
  110571. */
  110572. serialize(): any;
  110573. /**
  110574. * Creates a Highlight layer from parsed Highlight layer data
  110575. * @param parsedHightlightLayer defines the Highlight layer data
  110576. * @param scene defines the current scene
  110577. * @param rootUrl defines the root URL containing the Highlight layer information
  110578. * @returns a parsed Highlight layer
  110579. */
  110580. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110581. }
  110582. }
  110583. declare module BABYLON {
  110584. interface AbstractScene {
  110585. /**
  110586. * The list of layers (background and foreground) of the scene
  110587. */
  110588. layers: Array<Layer>;
  110589. }
  110590. /**
  110591. * Defines the layer scene component responsible to manage any layers
  110592. * in a given scene.
  110593. */
  110594. export class LayerSceneComponent implements ISceneComponent {
  110595. /**
  110596. * The component name helpfull to identify the component in the list of scene components.
  110597. */
  110598. readonly name: string;
  110599. /**
  110600. * The scene the component belongs to.
  110601. */
  110602. scene: Scene;
  110603. private _engine;
  110604. /**
  110605. * Creates a new instance of the component for the given scene
  110606. * @param scene Defines the scene to register the component in
  110607. */
  110608. constructor(scene: Scene);
  110609. /**
  110610. * Registers the component in a given scene
  110611. */
  110612. register(): void;
  110613. /**
  110614. * Rebuilds the elements related to this component in case of
  110615. * context lost for instance.
  110616. */
  110617. rebuild(): void;
  110618. /**
  110619. * Disposes the component and the associated ressources.
  110620. */
  110621. dispose(): void;
  110622. private _draw;
  110623. private _drawCameraPredicate;
  110624. private _drawCameraBackground;
  110625. private _drawCameraForeground;
  110626. private _drawRenderTargetPredicate;
  110627. private _drawRenderTargetBackground;
  110628. private _drawRenderTargetForeground;
  110629. /**
  110630. * Adds all the elements from the container to the scene
  110631. * @param container the container holding the elements
  110632. */
  110633. addFromContainer(container: AbstractScene): void;
  110634. /**
  110635. * Removes all the elements in the container from the scene
  110636. * @param container contains the elements to remove
  110637. * @param dispose if the removed element should be disposed (default: false)
  110638. */
  110639. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110640. }
  110641. }
  110642. declare module BABYLON {
  110643. /** @hidden */
  110644. export var layerPixelShader: {
  110645. name: string;
  110646. shader: string;
  110647. };
  110648. }
  110649. declare module BABYLON {
  110650. /** @hidden */
  110651. export var layerVertexShader: {
  110652. name: string;
  110653. shader: string;
  110654. };
  110655. }
  110656. declare module BABYLON {
  110657. /**
  110658. * This represents a full screen 2d layer.
  110659. * This can be useful to display a picture in the background of your scene for instance.
  110660. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110661. */
  110662. export class Layer {
  110663. /**
  110664. * Define the name of the layer.
  110665. */
  110666. name: string;
  110667. /**
  110668. * Define the texture the layer should display.
  110669. */
  110670. texture: Nullable<Texture>;
  110671. /**
  110672. * Is the layer in background or foreground.
  110673. */
  110674. isBackground: boolean;
  110675. /**
  110676. * Define the color of the layer (instead of texture).
  110677. */
  110678. color: Color4;
  110679. /**
  110680. * Define the scale of the layer in order to zoom in out of the texture.
  110681. */
  110682. scale: Vector2;
  110683. /**
  110684. * Define an offset for the layer in order to shift the texture.
  110685. */
  110686. offset: Vector2;
  110687. /**
  110688. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  110689. */
  110690. alphaBlendingMode: number;
  110691. /**
  110692. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  110693. * Alpha test will not mix with the background color in case of transparency.
  110694. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  110695. */
  110696. alphaTest: boolean;
  110697. /**
  110698. * Define a mask to restrict the layer to only some of the scene cameras.
  110699. */
  110700. layerMask: number;
  110701. /**
  110702. * Define the list of render target the layer is visible into.
  110703. */
  110704. renderTargetTextures: RenderTargetTexture[];
  110705. /**
  110706. * Define if the layer is only used in renderTarget or if it also
  110707. * renders in the main frame buffer of the canvas.
  110708. */
  110709. renderOnlyInRenderTargetTextures: boolean;
  110710. private _scene;
  110711. private _vertexBuffers;
  110712. private _indexBuffer;
  110713. private _effect;
  110714. private _alphaTestEffect;
  110715. /**
  110716. * An event triggered when the layer is disposed.
  110717. */
  110718. onDisposeObservable: Observable<Layer>;
  110719. private _onDisposeObserver;
  110720. /**
  110721. * Back compatibility with callback before the onDisposeObservable existed.
  110722. * The set callback will be triggered when the layer has been disposed.
  110723. */
  110724. onDispose: () => void;
  110725. /**
  110726. * An event triggered before rendering the scene
  110727. */
  110728. onBeforeRenderObservable: Observable<Layer>;
  110729. private _onBeforeRenderObserver;
  110730. /**
  110731. * Back compatibility with callback before the onBeforeRenderObservable existed.
  110732. * The set callback will be triggered just before rendering the layer.
  110733. */
  110734. onBeforeRender: () => void;
  110735. /**
  110736. * An event triggered after rendering the scene
  110737. */
  110738. onAfterRenderObservable: Observable<Layer>;
  110739. private _onAfterRenderObserver;
  110740. /**
  110741. * Back compatibility with callback before the onAfterRenderObservable existed.
  110742. * The set callback will be triggered just after rendering the layer.
  110743. */
  110744. onAfterRender: () => void;
  110745. /**
  110746. * Instantiates a new layer.
  110747. * This represents a full screen 2d layer.
  110748. * This can be useful to display a picture in the background of your scene for instance.
  110749. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110750. * @param name Define the name of the layer in the scene
  110751. * @param imgUrl Define the url of the texture to display in the layer
  110752. * @param scene Define the scene the layer belongs to
  110753. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  110754. * @param color Defines a color for the layer
  110755. */
  110756. constructor(
  110757. /**
  110758. * Define the name of the layer.
  110759. */
  110760. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  110761. private _createIndexBuffer;
  110762. /** @hidden */
  110763. _rebuild(): void;
  110764. /**
  110765. * Renders the layer in the scene.
  110766. */
  110767. render(): void;
  110768. /**
  110769. * Disposes and releases the associated ressources.
  110770. */
  110771. dispose(): void;
  110772. }
  110773. }
  110774. declare module BABYLON {
  110775. /** @hidden */
  110776. export var lensFlarePixelShader: {
  110777. name: string;
  110778. shader: string;
  110779. };
  110780. }
  110781. declare module BABYLON {
  110782. /** @hidden */
  110783. export var lensFlareVertexShader: {
  110784. name: string;
  110785. shader: string;
  110786. };
  110787. }
  110788. declare module BABYLON {
  110789. /**
  110790. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110791. * It is usually composed of several `lensFlare`.
  110792. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110793. */
  110794. export class LensFlareSystem {
  110795. /**
  110796. * Define the name of the lens flare system
  110797. */
  110798. name: string;
  110799. /**
  110800. * List of lens flares used in this system.
  110801. */
  110802. lensFlares: LensFlare[];
  110803. /**
  110804. * Define a limit from the border the lens flare can be visible.
  110805. */
  110806. borderLimit: number;
  110807. /**
  110808. * Define a viewport border we do not want to see the lens flare in.
  110809. */
  110810. viewportBorder: number;
  110811. /**
  110812. * Define a predicate which could limit the list of meshes able to occlude the effect.
  110813. */
  110814. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  110815. /**
  110816. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  110817. */
  110818. layerMask: number;
  110819. /**
  110820. * Define the id of the lens flare system in the scene.
  110821. * (equal to name by default)
  110822. */
  110823. id: string;
  110824. private _scene;
  110825. private _emitter;
  110826. private _vertexBuffers;
  110827. private _indexBuffer;
  110828. private _effect;
  110829. private _positionX;
  110830. private _positionY;
  110831. private _isEnabled;
  110832. /** @hidden */
  110833. static _SceneComponentInitialization: (scene: Scene) => void;
  110834. /**
  110835. * Instantiates a lens flare system.
  110836. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110837. * It is usually composed of several `lensFlare`.
  110838. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110839. * @param name Define the name of the lens flare system in the scene
  110840. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  110841. * @param scene Define the scene the lens flare system belongs to
  110842. */
  110843. constructor(
  110844. /**
  110845. * Define the name of the lens flare system
  110846. */
  110847. name: string, emitter: any, scene: Scene);
  110848. /**
  110849. * Define if the lens flare system is enabled.
  110850. */
  110851. isEnabled: boolean;
  110852. /**
  110853. * Get the scene the effects belongs to.
  110854. * @returns the scene holding the lens flare system
  110855. */
  110856. getScene(): Scene;
  110857. /**
  110858. * Get the emitter of the lens flare system.
  110859. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110860. * @returns the emitter of the lens flare system
  110861. */
  110862. getEmitter(): any;
  110863. /**
  110864. * Set the emitter of the lens flare system.
  110865. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110866. * @param newEmitter Define the new emitter of the system
  110867. */
  110868. setEmitter(newEmitter: any): void;
  110869. /**
  110870. * Get the lens flare system emitter position.
  110871. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  110872. * @returns the position
  110873. */
  110874. getEmitterPosition(): Vector3;
  110875. /**
  110876. * @hidden
  110877. */
  110878. computeEffectivePosition(globalViewport: Viewport): boolean;
  110879. /** @hidden */
  110880. _isVisible(): boolean;
  110881. /**
  110882. * @hidden
  110883. */
  110884. render(): boolean;
  110885. /**
  110886. * Dispose and release the lens flare with its associated resources.
  110887. */
  110888. dispose(): void;
  110889. /**
  110890. * Parse a lens flare system from a JSON repressentation
  110891. * @param parsedLensFlareSystem Define the JSON to parse
  110892. * @param scene Define the scene the parsed system should be instantiated in
  110893. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  110894. * @returns the parsed system
  110895. */
  110896. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  110897. /**
  110898. * Serialize the current Lens Flare System into a JSON representation.
  110899. * @returns the serialized JSON
  110900. */
  110901. serialize(): any;
  110902. }
  110903. }
  110904. declare module BABYLON {
  110905. /**
  110906. * This represents one of the lens effect in a `lensFlareSystem`.
  110907. * It controls one of the indiviual texture used in the effect.
  110908. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110909. */
  110910. export class LensFlare {
  110911. /**
  110912. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110913. */
  110914. size: number;
  110915. /**
  110916. * 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.
  110917. */
  110918. position: number;
  110919. /**
  110920. * Define the lens color.
  110921. */
  110922. color: Color3;
  110923. /**
  110924. * Define the lens texture.
  110925. */
  110926. texture: Nullable<Texture>;
  110927. /**
  110928. * Define the alpha mode to render this particular lens.
  110929. */
  110930. alphaMode: number;
  110931. private _system;
  110932. /**
  110933. * Creates a new Lens Flare.
  110934. * This represents one of the lens effect in a `lensFlareSystem`.
  110935. * It controls one of the indiviual texture used in the effect.
  110936. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110937. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  110938. * @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.
  110939. * @param color Define the lens color
  110940. * @param imgUrl Define the lens texture url
  110941. * @param system Define the `lensFlareSystem` this flare is part of
  110942. * @returns The newly created Lens Flare
  110943. */
  110944. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  110945. /**
  110946. * Instantiates a new Lens Flare.
  110947. * This represents one of the lens effect in a `lensFlareSystem`.
  110948. * It controls one of the indiviual texture used in the effect.
  110949. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110950. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  110951. * @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.
  110952. * @param color Define the lens color
  110953. * @param imgUrl Define the lens texture url
  110954. * @param system Define the `lensFlareSystem` this flare is part of
  110955. */
  110956. constructor(
  110957. /**
  110958. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110959. */
  110960. size: number,
  110961. /**
  110962. * 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.
  110963. */
  110964. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  110965. /**
  110966. * Dispose and release the lens flare with its associated resources.
  110967. */
  110968. dispose(): void;
  110969. }
  110970. }
  110971. declare module BABYLON {
  110972. interface AbstractScene {
  110973. /**
  110974. * The list of lens flare system added to the scene
  110975. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110976. */
  110977. lensFlareSystems: Array<LensFlareSystem>;
  110978. /**
  110979. * Removes the given lens flare system from this scene.
  110980. * @param toRemove The lens flare system to remove
  110981. * @returns The index of the removed lens flare system
  110982. */
  110983. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  110984. /**
  110985. * Adds the given lens flare system to this scene
  110986. * @param newLensFlareSystem The lens flare system to add
  110987. */
  110988. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  110989. /**
  110990. * Gets a lens flare system using its name
  110991. * @param name defines the name to look for
  110992. * @returns the lens flare system or null if not found
  110993. */
  110994. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  110995. /**
  110996. * Gets a lens flare system using its id
  110997. * @param id defines the id to look for
  110998. * @returns the lens flare system or null if not found
  110999. */
  111000. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111001. }
  111002. /**
  111003. * Defines the lens flare scene component responsible to manage any lens flares
  111004. * in a given scene.
  111005. */
  111006. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111007. /**
  111008. * The component name helpfull to identify the component in the list of scene components.
  111009. */
  111010. readonly name: string;
  111011. /**
  111012. * The scene the component belongs to.
  111013. */
  111014. scene: Scene;
  111015. /**
  111016. * Creates a new instance of the component for the given scene
  111017. * @param scene Defines the scene to register the component in
  111018. */
  111019. constructor(scene: Scene);
  111020. /**
  111021. * Registers the component in a given scene
  111022. */
  111023. register(): void;
  111024. /**
  111025. * Rebuilds the elements related to this component in case of
  111026. * context lost for instance.
  111027. */
  111028. rebuild(): void;
  111029. /**
  111030. * Adds all the elements from the container to the scene
  111031. * @param container the container holding the elements
  111032. */
  111033. addFromContainer(container: AbstractScene): void;
  111034. /**
  111035. * Removes all the elements in the container from the scene
  111036. * @param container contains the elements to remove
  111037. * @param dispose if the removed element should be disposed (default: false)
  111038. */
  111039. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111040. /**
  111041. * Serializes the component data to the specified json object
  111042. * @param serializationObject The object to serialize to
  111043. */
  111044. serialize(serializationObject: any): void;
  111045. /**
  111046. * Disposes the component and the associated ressources.
  111047. */
  111048. dispose(): void;
  111049. private _draw;
  111050. }
  111051. }
  111052. declare module BABYLON {
  111053. /**
  111054. * Defines the shadow generator component responsible to manage any shadow generators
  111055. * in a given scene.
  111056. */
  111057. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111058. /**
  111059. * The component name helpfull to identify the component in the list of scene components.
  111060. */
  111061. readonly name: string;
  111062. /**
  111063. * The scene the component belongs to.
  111064. */
  111065. scene: Scene;
  111066. /**
  111067. * Creates a new instance of the component for the given scene
  111068. * @param scene Defines the scene to register the component in
  111069. */
  111070. constructor(scene: Scene);
  111071. /**
  111072. * Registers the component in a given scene
  111073. */
  111074. register(): void;
  111075. /**
  111076. * Rebuilds the elements related to this component in case of
  111077. * context lost for instance.
  111078. */
  111079. rebuild(): void;
  111080. /**
  111081. * Serializes the component data to the specified json object
  111082. * @param serializationObject The object to serialize to
  111083. */
  111084. serialize(serializationObject: any): void;
  111085. /**
  111086. * Adds all the elements from the container to the scene
  111087. * @param container the container holding the elements
  111088. */
  111089. addFromContainer(container: AbstractScene): void;
  111090. /**
  111091. * Removes all the elements in the container from the scene
  111092. * @param container contains the elements to remove
  111093. * @param dispose if the removed element should be disposed (default: false)
  111094. */
  111095. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111096. /**
  111097. * Rebuilds the elements related to this component in case of
  111098. * context lost for instance.
  111099. */
  111100. dispose(): void;
  111101. private _gatherRenderTargets;
  111102. }
  111103. }
  111104. declare module BABYLON {
  111105. /**
  111106. * A point light is a light defined by an unique point in world space.
  111107. * The light is emitted in every direction from this point.
  111108. * A good example of a point light is a standard light bulb.
  111109. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111110. */
  111111. export class PointLight extends ShadowLight {
  111112. private _shadowAngle;
  111113. /**
  111114. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111115. * This specifies what angle the shadow will use to be created.
  111116. *
  111117. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111118. */
  111119. /**
  111120. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111121. * This specifies what angle the shadow will use to be created.
  111122. *
  111123. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111124. */
  111125. shadowAngle: number;
  111126. /**
  111127. * Gets the direction if it has been set.
  111128. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111129. */
  111130. /**
  111131. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111132. */
  111133. direction: Vector3;
  111134. /**
  111135. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111136. * A PointLight emits the light in every direction.
  111137. * It can cast shadows.
  111138. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111139. * ```javascript
  111140. * var pointLight = new PointLight("pl", camera.position, scene);
  111141. * ```
  111142. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111143. * @param name The light friendly name
  111144. * @param position The position of the point light in the scene
  111145. * @param scene The scene the lights belongs to
  111146. */
  111147. constructor(name: string, position: Vector3, scene: Scene);
  111148. /**
  111149. * Returns the string "PointLight"
  111150. * @returns the class name
  111151. */
  111152. getClassName(): string;
  111153. /**
  111154. * Returns the integer 0.
  111155. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111156. */
  111157. getTypeID(): number;
  111158. /**
  111159. * Specifies wether or not the shadowmap should be a cube texture.
  111160. * @returns true if the shadowmap needs to be a cube texture.
  111161. */
  111162. needCube(): boolean;
  111163. /**
  111164. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111165. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111166. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111167. */
  111168. getShadowDirection(faceIndex?: number): Vector3;
  111169. /**
  111170. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111171. * - fov = PI / 2
  111172. * - aspect ratio : 1.0
  111173. * - z-near and far equal to the active camera minZ and maxZ.
  111174. * Returns the PointLight.
  111175. */
  111176. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111177. protected _buildUniformLayout(): void;
  111178. /**
  111179. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111180. * @param effect The effect to update
  111181. * @param lightIndex The index of the light in the effect to update
  111182. * @returns The point light
  111183. */
  111184. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111185. /**
  111186. * Prepares the list of defines specific to the light type.
  111187. * @param defines the list of defines
  111188. * @param lightIndex defines the index of the light for the effect
  111189. */
  111190. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111191. }
  111192. }
  111193. declare module BABYLON {
  111194. /**
  111195. * Header information of HDR texture files.
  111196. */
  111197. export interface HDRInfo {
  111198. /**
  111199. * The height of the texture in pixels.
  111200. */
  111201. height: number;
  111202. /**
  111203. * The width of the texture in pixels.
  111204. */
  111205. width: number;
  111206. /**
  111207. * The index of the beginning of the data in the binary file.
  111208. */
  111209. dataPosition: number;
  111210. }
  111211. /**
  111212. * This groups tools to convert HDR texture to native colors array.
  111213. */
  111214. export class HDRTools {
  111215. private static Ldexp;
  111216. private static Rgbe2float;
  111217. private static readStringLine;
  111218. /**
  111219. * Reads header information from an RGBE texture stored in a native array.
  111220. * More information on this format are available here:
  111221. * https://en.wikipedia.org/wiki/RGBE_image_format
  111222. *
  111223. * @param uint8array The binary file stored in native array.
  111224. * @return The header information.
  111225. */
  111226. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111227. /**
  111228. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111229. * This RGBE texture needs to store the information as a panorama.
  111230. *
  111231. * More information on this format are available here:
  111232. * https://en.wikipedia.org/wiki/RGBE_image_format
  111233. *
  111234. * @param buffer The binary file stored in an array buffer.
  111235. * @param size The expected size of the extracted cubemap.
  111236. * @return The Cube Map information.
  111237. */
  111238. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111239. /**
  111240. * Returns the pixels data extracted from an RGBE texture.
  111241. * This pixels will be stored left to right up to down in the R G B order in one array.
  111242. *
  111243. * More information on this format are available here:
  111244. * https://en.wikipedia.org/wiki/RGBE_image_format
  111245. *
  111246. * @param uint8array The binary file stored in an array buffer.
  111247. * @param hdrInfo The header information of the file.
  111248. * @return The pixels data in RGB right to left up to down order.
  111249. */
  111250. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111251. private static RGBE_ReadPixels_RLE;
  111252. }
  111253. }
  111254. declare module BABYLON {
  111255. /**
  111256. * This represents a texture coming from an HDR input.
  111257. *
  111258. * The only supported format is currently panorama picture stored in RGBE format.
  111259. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111260. */
  111261. export class HDRCubeTexture extends BaseTexture {
  111262. private static _facesMapping;
  111263. private _generateHarmonics;
  111264. private _noMipmap;
  111265. private _textureMatrix;
  111266. private _size;
  111267. private _onLoad;
  111268. private _onError;
  111269. /**
  111270. * The texture URL.
  111271. */
  111272. url: string;
  111273. /**
  111274. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111275. */
  111276. coordinatesMode: number;
  111277. protected _isBlocking: boolean;
  111278. /**
  111279. * Sets wether or not the texture is blocking during loading.
  111280. */
  111281. /**
  111282. * Gets wether or not the texture is blocking during loading.
  111283. */
  111284. isBlocking: boolean;
  111285. protected _rotationY: number;
  111286. /**
  111287. * Sets texture matrix rotation angle around Y axis in radians.
  111288. */
  111289. /**
  111290. * Gets texture matrix rotation angle around Y axis radians.
  111291. */
  111292. rotationY: number;
  111293. /**
  111294. * Gets or sets the center of the bounding box associated with the cube texture
  111295. * It must define where the camera used to render the texture was set
  111296. */
  111297. boundingBoxPosition: Vector3;
  111298. private _boundingBoxSize;
  111299. /**
  111300. * Gets or sets the size of the bounding box associated with the cube texture
  111301. * When defined, the cubemap will switch to local mode
  111302. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111303. * @example https://www.babylonjs-playground.com/#RNASML
  111304. */
  111305. boundingBoxSize: Vector3;
  111306. /**
  111307. * Instantiates an HDRTexture from the following parameters.
  111308. *
  111309. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111310. * @param scene The scene the texture will be used in
  111311. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111312. * @param noMipmap Forces to not generate the mipmap if true
  111313. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111314. * @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)
  111315. * @param reserved Reserved flag for internal use.
  111316. */
  111317. 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>);
  111318. /**
  111319. * Get the current class name of the texture useful for serialization or dynamic coding.
  111320. * @returns "HDRCubeTexture"
  111321. */
  111322. getClassName(): string;
  111323. /**
  111324. * Occurs when the file is raw .hdr file.
  111325. */
  111326. private loadTexture;
  111327. clone(): HDRCubeTexture;
  111328. delayLoad(): void;
  111329. /**
  111330. * Get the texture reflection matrix used to rotate/transform the reflection.
  111331. * @returns the reflection matrix
  111332. */
  111333. getReflectionTextureMatrix(): Matrix;
  111334. /**
  111335. * Set the texture reflection matrix used to rotate/transform the reflection.
  111336. * @param value Define the reflection matrix to set
  111337. */
  111338. setReflectionTextureMatrix(value: Matrix): void;
  111339. /**
  111340. * Parses a JSON representation of an HDR Texture in order to create the texture
  111341. * @param parsedTexture Define the JSON representation
  111342. * @param scene Define the scene the texture should be created in
  111343. * @param rootUrl Define the root url in case we need to load relative dependencies
  111344. * @returns the newly created texture after parsing
  111345. */
  111346. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111347. serialize(): any;
  111348. }
  111349. }
  111350. declare module BABYLON {
  111351. /**
  111352. * Class used to control physics engine
  111353. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111354. */
  111355. export class PhysicsEngine implements IPhysicsEngine {
  111356. private _physicsPlugin;
  111357. /**
  111358. * Global value used to control the smallest number supported by the simulation
  111359. */
  111360. static Epsilon: number;
  111361. private _impostors;
  111362. private _joints;
  111363. /**
  111364. * Gets the gravity vector used by the simulation
  111365. */
  111366. gravity: Vector3;
  111367. /**
  111368. * Factory used to create the default physics plugin.
  111369. * @returns The default physics plugin
  111370. */
  111371. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111372. /**
  111373. * Creates a new Physics Engine
  111374. * @param gravity defines the gravity vector used by the simulation
  111375. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111376. */
  111377. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111378. /**
  111379. * Sets the gravity vector used by the simulation
  111380. * @param gravity defines the gravity vector to use
  111381. */
  111382. setGravity(gravity: Vector3): void;
  111383. /**
  111384. * Set the time step of the physics engine.
  111385. * Default is 1/60.
  111386. * To slow it down, enter 1/600 for example.
  111387. * To speed it up, 1/30
  111388. * @param newTimeStep defines the new timestep to apply to this world.
  111389. */
  111390. setTimeStep(newTimeStep?: number): void;
  111391. /**
  111392. * Get the time step of the physics engine.
  111393. * @returns the current time step
  111394. */
  111395. getTimeStep(): number;
  111396. /**
  111397. * Release all resources
  111398. */
  111399. dispose(): void;
  111400. /**
  111401. * Gets the name of the current physics plugin
  111402. * @returns the name of the plugin
  111403. */
  111404. getPhysicsPluginName(): string;
  111405. /**
  111406. * Adding a new impostor for the impostor tracking.
  111407. * This will be done by the impostor itself.
  111408. * @param impostor the impostor to add
  111409. */
  111410. addImpostor(impostor: PhysicsImpostor): void;
  111411. /**
  111412. * Remove an impostor from the engine.
  111413. * This impostor and its mesh will not longer be updated by the physics engine.
  111414. * @param impostor the impostor to remove
  111415. */
  111416. removeImpostor(impostor: PhysicsImpostor): void;
  111417. /**
  111418. * Add a joint to the physics engine
  111419. * @param mainImpostor defines the main impostor to which the joint is added.
  111420. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111421. * @param joint defines the joint that will connect both impostors.
  111422. */
  111423. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111424. /**
  111425. * Removes a joint from the simulation
  111426. * @param mainImpostor defines the impostor used with the joint
  111427. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111428. * @param joint defines the joint to remove
  111429. */
  111430. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111431. /**
  111432. * Called by the scene. No need to call it.
  111433. * @param delta defines the timespam between frames
  111434. */
  111435. _step(delta: number): void;
  111436. /**
  111437. * Gets the current plugin used to run the simulation
  111438. * @returns current plugin
  111439. */
  111440. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111441. /**
  111442. * Gets the list of physic impostors
  111443. * @returns an array of PhysicsImpostor
  111444. */
  111445. getImpostors(): Array<PhysicsImpostor>;
  111446. /**
  111447. * Gets the impostor for a physics enabled object
  111448. * @param object defines the object impersonated by the impostor
  111449. * @returns the PhysicsImpostor or null if not found
  111450. */
  111451. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111452. /**
  111453. * Gets the impostor for a physics body object
  111454. * @param body defines physics body used by the impostor
  111455. * @returns the PhysicsImpostor or null if not found
  111456. */
  111457. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111458. /**
  111459. * Does a raycast in the physics world
  111460. * @param from when should the ray start?
  111461. * @param to when should the ray end?
  111462. * @returns PhysicsRaycastResult
  111463. */
  111464. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111465. }
  111466. }
  111467. declare module BABYLON {
  111468. /** @hidden */
  111469. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111470. private _useDeltaForWorldStep;
  111471. world: any;
  111472. name: string;
  111473. private _physicsMaterials;
  111474. private _fixedTimeStep;
  111475. private _cannonRaycastResult;
  111476. private _raycastResult;
  111477. private _removeAfterStep;
  111478. BJSCANNON: any;
  111479. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111480. setGravity(gravity: Vector3): void;
  111481. setTimeStep(timeStep: number): void;
  111482. getTimeStep(): number;
  111483. executeStep(delta: number): void;
  111484. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111485. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111486. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111487. private _processChildMeshes;
  111488. removePhysicsBody(impostor: PhysicsImpostor): void;
  111489. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111490. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111491. private _addMaterial;
  111492. private _checkWithEpsilon;
  111493. private _createShape;
  111494. private _createHeightmap;
  111495. private _minus90X;
  111496. private _plus90X;
  111497. private _tmpPosition;
  111498. private _tmpDeltaPosition;
  111499. private _tmpUnityRotation;
  111500. private _updatePhysicsBodyTransformation;
  111501. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111502. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111503. isSupported(): boolean;
  111504. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111505. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111506. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111507. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111508. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111509. getBodyMass(impostor: PhysicsImpostor): number;
  111510. getBodyFriction(impostor: PhysicsImpostor): number;
  111511. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111512. getBodyRestitution(impostor: PhysicsImpostor): number;
  111513. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111514. sleepBody(impostor: PhysicsImpostor): void;
  111515. wakeUpBody(impostor: PhysicsImpostor): void;
  111516. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111517. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111518. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111519. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111520. getRadius(impostor: PhysicsImpostor): number;
  111521. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111522. dispose(): void;
  111523. private _extendNamespace;
  111524. /**
  111525. * Does a raycast in the physics world
  111526. * @param from when should the ray start?
  111527. * @param to when should the ray end?
  111528. * @returns PhysicsRaycastResult
  111529. */
  111530. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111531. }
  111532. }
  111533. declare module BABYLON {
  111534. /** @hidden */
  111535. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111536. world: any;
  111537. name: string;
  111538. BJSOIMO: any;
  111539. private _raycastResult;
  111540. constructor(iterations?: number, oimoInjection?: any);
  111541. setGravity(gravity: Vector3): void;
  111542. setTimeStep(timeStep: number): void;
  111543. getTimeStep(): number;
  111544. private _tmpImpostorsArray;
  111545. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111546. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111547. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111548. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111549. private _tmpPositionVector;
  111550. removePhysicsBody(impostor: PhysicsImpostor): void;
  111551. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111552. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111553. isSupported(): boolean;
  111554. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111555. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111556. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111557. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111558. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111559. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111560. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111561. getBodyMass(impostor: PhysicsImpostor): number;
  111562. getBodyFriction(impostor: PhysicsImpostor): number;
  111563. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111564. getBodyRestitution(impostor: PhysicsImpostor): number;
  111565. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111566. sleepBody(impostor: PhysicsImpostor): void;
  111567. wakeUpBody(impostor: PhysicsImpostor): void;
  111568. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111569. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111570. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111571. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111572. getRadius(impostor: PhysicsImpostor): number;
  111573. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111574. dispose(): void;
  111575. /**
  111576. * Does a raycast in the physics world
  111577. * @param from when should the ray start?
  111578. * @param to when should the ray end?
  111579. * @returns PhysicsRaycastResult
  111580. */
  111581. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111582. }
  111583. }
  111584. declare module BABYLON {
  111585. /**
  111586. * Class containing static functions to help procedurally build meshes
  111587. */
  111588. export class RibbonBuilder {
  111589. /**
  111590. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111591. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111592. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  111593. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  111594. * * 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
  111595. * * 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
  111596. * * 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
  111597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111599. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111600. * * 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
  111601. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  111602. * * 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
  111603. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  111604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111605. * @param name defines the name of the mesh
  111606. * @param options defines the options used to create the mesh
  111607. * @param scene defines the hosting scene
  111608. * @returns the ribbon mesh
  111609. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  111610. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111611. */
  111612. static CreateRibbon(name: string, options: {
  111613. pathArray: Vector3[][];
  111614. closeArray?: boolean;
  111615. closePath?: boolean;
  111616. offset?: number;
  111617. updatable?: boolean;
  111618. sideOrientation?: number;
  111619. frontUVs?: Vector4;
  111620. backUVs?: Vector4;
  111621. instance?: Mesh;
  111622. invertUV?: boolean;
  111623. uvs?: Vector2[];
  111624. colors?: Color4[];
  111625. }, scene?: Nullable<Scene>): Mesh;
  111626. }
  111627. }
  111628. declare module BABYLON {
  111629. /**
  111630. * Class containing static functions to help procedurally build meshes
  111631. */
  111632. export class ShapeBuilder {
  111633. /**
  111634. * 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.
  111635. * * 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.
  111636. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111637. * * 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.
  111638. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  111639. * * 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
  111640. * * 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
  111641. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  111642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111644. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  111645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111646. * @param name defines the name of the mesh
  111647. * @param options defines the options used to create the mesh
  111648. * @param scene defines the hosting scene
  111649. * @returns the extruded shape mesh
  111650. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111652. */
  111653. static ExtrudeShape(name: string, options: {
  111654. shape: Vector3[];
  111655. path: Vector3[];
  111656. scale?: number;
  111657. rotation?: number;
  111658. cap?: number;
  111659. updatable?: boolean;
  111660. sideOrientation?: number;
  111661. frontUVs?: Vector4;
  111662. backUVs?: Vector4;
  111663. instance?: Mesh;
  111664. invertUV?: boolean;
  111665. }, scene?: Nullable<Scene>): Mesh;
  111666. /**
  111667. * Creates an custom extruded shape mesh.
  111668. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  111669. * * 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.
  111670. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111671. * * 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
  111672. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  111673. * * 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
  111674. * * It must returns a float value that will be the scale value applied to the shape on each path point
  111675. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  111676. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  111677. * * 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
  111678. * * 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
  111679. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  111680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111684. * @param name defines the name of the mesh
  111685. * @param options defines the options used to create the mesh
  111686. * @param scene defines the hosting scene
  111687. * @returns the custom extruded shape mesh
  111688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  111689. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111691. */
  111692. static ExtrudeShapeCustom(name: string, options: {
  111693. shape: Vector3[];
  111694. path: Vector3[];
  111695. scaleFunction?: any;
  111696. rotationFunction?: any;
  111697. ribbonCloseArray?: boolean;
  111698. ribbonClosePath?: boolean;
  111699. cap?: number;
  111700. updatable?: boolean;
  111701. sideOrientation?: number;
  111702. frontUVs?: Vector4;
  111703. backUVs?: Vector4;
  111704. instance?: Mesh;
  111705. invertUV?: boolean;
  111706. }, scene?: Nullable<Scene>): Mesh;
  111707. private static _ExtrudeShapeGeneric;
  111708. }
  111709. }
  111710. declare module BABYLON {
  111711. /**
  111712. * AmmoJS Physics plugin
  111713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111714. * @see https://github.com/kripken/ammo.js/
  111715. */
  111716. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  111717. private _useDeltaForWorldStep;
  111718. /**
  111719. * Reference to the Ammo library
  111720. */
  111721. bjsAMMO: any;
  111722. /**
  111723. * Created ammoJS world which physics bodies are added to
  111724. */
  111725. world: any;
  111726. /**
  111727. * Name of the plugin
  111728. */
  111729. name: string;
  111730. private _timeStep;
  111731. private _fixedTimeStep;
  111732. private _maxSteps;
  111733. private _tmpQuaternion;
  111734. private _tmpAmmoTransform;
  111735. private _tmpAmmoQuaternion;
  111736. private _tmpAmmoConcreteContactResultCallback;
  111737. private _collisionConfiguration;
  111738. private _dispatcher;
  111739. private _overlappingPairCache;
  111740. private _solver;
  111741. private _softBodySolver;
  111742. private _tmpAmmoVectorA;
  111743. private _tmpAmmoVectorB;
  111744. private _tmpAmmoVectorC;
  111745. private _tmpAmmoVectorD;
  111746. private _tmpContactCallbackResult;
  111747. private _tmpAmmoVectorRCA;
  111748. private _tmpAmmoVectorRCB;
  111749. private _raycastResult;
  111750. private static readonly DISABLE_COLLISION_FLAG;
  111751. private static readonly KINEMATIC_FLAG;
  111752. private static readonly DISABLE_DEACTIVATION_FLAG;
  111753. /**
  111754. * Initializes the ammoJS plugin
  111755. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  111756. * @param ammoInjection can be used to inject your own ammo reference
  111757. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  111758. */
  111759. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  111760. /**
  111761. * Sets the gravity of the physics world (m/(s^2))
  111762. * @param gravity Gravity to set
  111763. */
  111764. setGravity(gravity: Vector3): void;
  111765. /**
  111766. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  111767. * @param timeStep timestep to use in seconds
  111768. */
  111769. setTimeStep(timeStep: number): void;
  111770. /**
  111771. * 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)
  111772. * @param fixedTimeStep fixedTimeStep to use in seconds
  111773. */
  111774. setFixedTimeStep(fixedTimeStep: number): void;
  111775. /**
  111776. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  111777. * @param maxSteps the maximum number of steps by the physics engine per frame
  111778. */
  111779. setMaxSteps(maxSteps: number): void;
  111780. /**
  111781. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  111782. * @returns the current timestep in seconds
  111783. */
  111784. getTimeStep(): number;
  111785. private _isImpostorInContact;
  111786. private _isImpostorPairInContact;
  111787. private _stepSimulation;
  111788. /**
  111789. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  111790. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  111791. * After the step the babylon meshes are set to the position of the physics imposters
  111792. * @param delta amount of time to step forward
  111793. * @param impostors array of imposters to update before/after the step
  111794. */
  111795. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111796. /**
  111797. * Update babylon mesh to match physics world object
  111798. * @param impostor imposter to match
  111799. */
  111800. private _afterSoftStep;
  111801. /**
  111802. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111803. * @param impostor imposter to match
  111804. */
  111805. private _ropeStep;
  111806. /**
  111807. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111808. * @param impostor imposter to match
  111809. */
  111810. private _softbodyOrClothStep;
  111811. private _tmpVector;
  111812. private _tmpMatrix;
  111813. /**
  111814. * Applies an impulse on the imposter
  111815. * @param impostor imposter to apply impulse to
  111816. * @param force amount of force to be applied to the imposter
  111817. * @param contactPoint the location to apply the impulse on the imposter
  111818. */
  111819. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111820. /**
  111821. * Applies a force on the imposter
  111822. * @param impostor imposter to apply force
  111823. * @param force amount of force to be applied to the imposter
  111824. * @param contactPoint the location to apply the force on the imposter
  111825. */
  111826. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111827. /**
  111828. * Creates a physics body using the plugin
  111829. * @param impostor the imposter to create the physics body on
  111830. */
  111831. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111832. /**
  111833. * Removes the physics body from the imposter and disposes of the body's memory
  111834. * @param impostor imposter to remove the physics body from
  111835. */
  111836. removePhysicsBody(impostor: PhysicsImpostor): void;
  111837. /**
  111838. * Generates a joint
  111839. * @param impostorJoint the imposter joint to create the joint with
  111840. */
  111841. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111842. /**
  111843. * Removes a joint
  111844. * @param impostorJoint the imposter joint to remove the joint from
  111845. */
  111846. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111847. private _addMeshVerts;
  111848. /**
  111849. * Initialise the soft body vertices to match its object's (mesh) vertices
  111850. * Softbody vertices (nodes) are in world space and to match this
  111851. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  111852. * @param impostor to create the softbody for
  111853. */
  111854. private _softVertexData;
  111855. /**
  111856. * Create an impostor's soft body
  111857. * @param impostor to create the softbody for
  111858. */
  111859. private _createSoftbody;
  111860. /**
  111861. * Create cloth for an impostor
  111862. * @param impostor to create the softbody for
  111863. */
  111864. private _createCloth;
  111865. /**
  111866. * Create rope for an impostor
  111867. * @param impostor to create the softbody for
  111868. */
  111869. private _createRope;
  111870. private _addHullVerts;
  111871. private _createShape;
  111872. /**
  111873. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  111874. * @param impostor imposter containing the physics body and babylon object
  111875. */
  111876. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111877. /**
  111878. * Sets the babylon object's position/rotation from the physics body's position/rotation
  111879. * @param impostor imposter containing the physics body and babylon object
  111880. * @param newPosition new position
  111881. * @param newRotation new rotation
  111882. */
  111883. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111884. /**
  111885. * If this plugin is supported
  111886. * @returns true if its supported
  111887. */
  111888. isSupported(): boolean;
  111889. /**
  111890. * Sets the linear velocity of the physics body
  111891. * @param impostor imposter to set the velocity on
  111892. * @param velocity velocity to set
  111893. */
  111894. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111895. /**
  111896. * Sets the angular velocity of the physics body
  111897. * @param impostor imposter to set the velocity on
  111898. * @param velocity velocity to set
  111899. */
  111900. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111901. /**
  111902. * gets the linear velocity
  111903. * @param impostor imposter to get linear velocity from
  111904. * @returns linear velocity
  111905. */
  111906. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111907. /**
  111908. * gets the angular velocity
  111909. * @param impostor imposter to get angular velocity from
  111910. * @returns angular velocity
  111911. */
  111912. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111913. /**
  111914. * Sets the mass of physics body
  111915. * @param impostor imposter to set the mass on
  111916. * @param mass mass to set
  111917. */
  111918. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111919. /**
  111920. * Gets the mass of the physics body
  111921. * @param impostor imposter to get the mass from
  111922. * @returns mass
  111923. */
  111924. getBodyMass(impostor: PhysicsImpostor): number;
  111925. /**
  111926. * Gets friction of the impostor
  111927. * @param impostor impostor to get friction from
  111928. * @returns friction value
  111929. */
  111930. getBodyFriction(impostor: PhysicsImpostor): number;
  111931. /**
  111932. * Sets friction of the impostor
  111933. * @param impostor impostor to set friction on
  111934. * @param friction friction value
  111935. */
  111936. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111937. /**
  111938. * Gets restitution of the impostor
  111939. * @param impostor impostor to get restitution from
  111940. * @returns restitution value
  111941. */
  111942. getBodyRestitution(impostor: PhysicsImpostor): number;
  111943. /**
  111944. * Sets resitution of the impostor
  111945. * @param impostor impostor to set resitution on
  111946. * @param restitution resitution value
  111947. */
  111948. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111949. /**
  111950. * Gets pressure inside the impostor
  111951. * @param impostor impostor to get pressure from
  111952. * @returns pressure value
  111953. */
  111954. getBodyPressure(impostor: PhysicsImpostor): number;
  111955. /**
  111956. * Sets pressure inside a soft body impostor
  111957. * Cloth and rope must remain 0 pressure
  111958. * @param impostor impostor to set pressure on
  111959. * @param pressure pressure value
  111960. */
  111961. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  111962. /**
  111963. * Gets stiffness of the impostor
  111964. * @param impostor impostor to get stiffness from
  111965. * @returns pressure value
  111966. */
  111967. getBodyStiffness(impostor: PhysicsImpostor): number;
  111968. /**
  111969. * Sets stiffness of the impostor
  111970. * @param impostor impostor to set stiffness on
  111971. * @param stiffness stiffness value from 0 to 1
  111972. */
  111973. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  111974. /**
  111975. * Gets velocityIterations of the impostor
  111976. * @param impostor impostor to get velocity iterations from
  111977. * @returns velocityIterations value
  111978. */
  111979. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  111980. /**
  111981. * Sets velocityIterations of the impostor
  111982. * @param impostor impostor to set velocity iterations on
  111983. * @param velocityIterations velocityIterations value
  111984. */
  111985. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  111986. /**
  111987. * Gets positionIterations of the impostor
  111988. * @param impostor impostor to get position iterations from
  111989. * @returns positionIterations value
  111990. */
  111991. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  111992. /**
  111993. * Sets positionIterations of the impostor
  111994. * @param impostor impostor to set position on
  111995. * @param positionIterations positionIterations value
  111996. */
  111997. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  111998. /**
  111999. * Append an anchor to a cloth object
  112000. * @param impostor is the cloth impostor to add anchor to
  112001. * @param otherImpostor is the rigid impostor to anchor to
  112002. * @param width ratio across width from 0 to 1
  112003. * @param height ratio up height from 0 to 1
  112004. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112005. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112006. */
  112007. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112008. /**
  112009. * Append an hook to a rope object
  112010. * @param impostor is the rope impostor to add hook to
  112011. * @param otherImpostor is the rigid impostor to hook to
  112012. * @param length ratio along the rope from 0 to 1
  112013. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112014. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112015. */
  112016. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112017. /**
  112018. * Sleeps the physics body and stops it from being active
  112019. * @param impostor impostor to sleep
  112020. */
  112021. sleepBody(impostor: PhysicsImpostor): void;
  112022. /**
  112023. * Activates the physics body
  112024. * @param impostor impostor to activate
  112025. */
  112026. wakeUpBody(impostor: PhysicsImpostor): void;
  112027. /**
  112028. * Updates the distance parameters of the joint
  112029. * @param joint joint to update
  112030. * @param maxDistance maximum distance of the joint
  112031. * @param minDistance minimum distance of the joint
  112032. */
  112033. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112034. /**
  112035. * Sets a motor on the joint
  112036. * @param joint joint to set motor on
  112037. * @param speed speed of the motor
  112038. * @param maxForce maximum force of the motor
  112039. * @param motorIndex index of the motor
  112040. */
  112041. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112042. /**
  112043. * Sets the motors limit
  112044. * @param joint joint to set limit on
  112045. * @param upperLimit upper limit
  112046. * @param lowerLimit lower limit
  112047. */
  112048. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112049. /**
  112050. * Syncs the position and rotation of a mesh with the impostor
  112051. * @param mesh mesh to sync
  112052. * @param impostor impostor to update the mesh with
  112053. */
  112054. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112055. /**
  112056. * Gets the radius of the impostor
  112057. * @param impostor impostor to get radius from
  112058. * @returns the radius
  112059. */
  112060. getRadius(impostor: PhysicsImpostor): number;
  112061. /**
  112062. * Gets the box size of the impostor
  112063. * @param impostor impostor to get box size from
  112064. * @param result the resulting box size
  112065. */
  112066. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112067. /**
  112068. * Disposes of the impostor
  112069. */
  112070. dispose(): void;
  112071. /**
  112072. * Does a raycast in the physics world
  112073. * @param from when should the ray start?
  112074. * @param to when should the ray end?
  112075. * @returns PhysicsRaycastResult
  112076. */
  112077. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112078. }
  112079. }
  112080. declare module BABYLON {
  112081. interface AbstractScene {
  112082. /**
  112083. * The list of reflection probes added to the scene
  112084. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112085. */
  112086. reflectionProbes: Array<ReflectionProbe>;
  112087. /**
  112088. * Removes the given reflection probe from this scene.
  112089. * @param toRemove The reflection probe to remove
  112090. * @returns The index of the removed reflection probe
  112091. */
  112092. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112093. /**
  112094. * Adds the given reflection probe to this scene.
  112095. * @param newReflectionProbe The reflection probe to add
  112096. */
  112097. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112098. }
  112099. /**
  112100. * Class used to generate realtime reflection / refraction cube textures
  112101. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112102. */
  112103. export class ReflectionProbe {
  112104. /** defines the name of the probe */
  112105. name: string;
  112106. private _scene;
  112107. private _renderTargetTexture;
  112108. private _projectionMatrix;
  112109. private _viewMatrix;
  112110. private _target;
  112111. private _add;
  112112. private _attachedMesh;
  112113. private _invertYAxis;
  112114. /** Gets or sets probe position (center of the cube map) */
  112115. position: Vector3;
  112116. /**
  112117. * Creates a new reflection probe
  112118. * @param name defines the name of the probe
  112119. * @param size defines the texture resolution (for each face)
  112120. * @param scene defines the hosting scene
  112121. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112122. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112123. */
  112124. constructor(
  112125. /** defines the name of the probe */
  112126. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112127. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112128. samples: number;
  112129. /** Gets or sets the refresh rate to use (on every frame by default) */
  112130. refreshRate: number;
  112131. /**
  112132. * Gets the hosting scene
  112133. * @returns a Scene
  112134. */
  112135. getScene(): Scene;
  112136. /** Gets the internal CubeTexture used to render to */
  112137. readonly cubeTexture: RenderTargetTexture;
  112138. /** Gets the list of meshes to render */
  112139. readonly renderList: Nullable<AbstractMesh[]>;
  112140. /**
  112141. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112142. * @param mesh defines the mesh to attach to
  112143. */
  112144. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112145. /**
  112146. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112147. * @param renderingGroupId The rendering group id corresponding to its index
  112148. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112149. */
  112150. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112151. /**
  112152. * Clean all associated resources
  112153. */
  112154. dispose(): void;
  112155. /**
  112156. * Converts the reflection probe information to a readable string for debug purpose.
  112157. * @param fullDetails Supports for multiple levels of logging within scene loading
  112158. * @returns the human readable reflection probe info
  112159. */
  112160. toString(fullDetails?: boolean): string;
  112161. /**
  112162. * Get the class name of the relfection probe.
  112163. * @returns "ReflectionProbe"
  112164. */
  112165. getClassName(): string;
  112166. /**
  112167. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112168. * @returns The JSON representation of the texture
  112169. */
  112170. serialize(): any;
  112171. /**
  112172. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112173. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112174. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112175. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112176. * @returns The parsed reflection probe if successful
  112177. */
  112178. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112179. }
  112180. }
  112181. declare module BABYLON {
  112182. /** @hidden */
  112183. export var _BabylonLoaderRegistered: boolean;
  112184. }
  112185. declare module BABYLON {
  112186. /**
  112187. * The Physically based simple base material of BJS.
  112188. *
  112189. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112190. * It is used as the base class for both the specGloss and metalRough conventions.
  112191. */
  112192. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112193. /**
  112194. * Number of Simultaneous lights allowed on the material.
  112195. */
  112196. maxSimultaneousLights: number;
  112197. /**
  112198. * If sets to true, disables all the lights affecting the material.
  112199. */
  112200. disableLighting: boolean;
  112201. /**
  112202. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112203. */
  112204. environmentTexture: BaseTexture;
  112205. /**
  112206. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112207. */
  112208. invertNormalMapX: boolean;
  112209. /**
  112210. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112211. */
  112212. invertNormalMapY: boolean;
  112213. /**
  112214. * Normal map used in the model.
  112215. */
  112216. normalTexture: BaseTexture;
  112217. /**
  112218. * Emissivie color used to self-illuminate the model.
  112219. */
  112220. emissiveColor: Color3;
  112221. /**
  112222. * Emissivie texture used to self-illuminate the model.
  112223. */
  112224. emissiveTexture: BaseTexture;
  112225. /**
  112226. * Occlusion Channel Strenght.
  112227. */
  112228. occlusionStrength: number;
  112229. /**
  112230. * Occlusion Texture of the material (adding extra occlusion effects).
  112231. */
  112232. occlusionTexture: BaseTexture;
  112233. /**
  112234. * Defines the alpha limits in alpha test mode.
  112235. */
  112236. alphaCutOff: number;
  112237. /**
  112238. * Gets the current double sided mode.
  112239. */
  112240. /**
  112241. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112242. */
  112243. doubleSided: boolean;
  112244. /**
  112245. * Stores the pre-calculated light information of a mesh in a texture.
  112246. */
  112247. lightmapTexture: BaseTexture;
  112248. /**
  112249. * If true, the light map contains occlusion information instead of lighting info.
  112250. */
  112251. useLightmapAsShadowmap: boolean;
  112252. /**
  112253. * Instantiates a new PBRMaterial instance.
  112254. *
  112255. * @param name The material name
  112256. * @param scene The scene the material will be use in.
  112257. */
  112258. constructor(name: string, scene: Scene);
  112259. getClassName(): string;
  112260. }
  112261. }
  112262. declare module BABYLON {
  112263. /**
  112264. * The PBR material of BJS following the metal roughness convention.
  112265. *
  112266. * This fits to the PBR convention in the GLTF definition:
  112267. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112268. */
  112269. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112270. /**
  112271. * The base color has two different interpretations depending on the value of metalness.
  112272. * When the material is a metal, the base color is the specific measured reflectance value
  112273. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112274. * of the material.
  112275. */
  112276. baseColor: Color3;
  112277. /**
  112278. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112279. * well as opacity information in the alpha channel.
  112280. */
  112281. baseTexture: BaseTexture;
  112282. /**
  112283. * Specifies the metallic scalar value of the material.
  112284. * Can also be used to scale the metalness values of the metallic texture.
  112285. */
  112286. metallic: number;
  112287. /**
  112288. * Specifies the roughness scalar value of the material.
  112289. * Can also be used to scale the roughness values of the metallic texture.
  112290. */
  112291. roughness: number;
  112292. /**
  112293. * Texture containing both the metallic value in the B channel and the
  112294. * roughness value in the G channel to keep better precision.
  112295. */
  112296. metallicRoughnessTexture: BaseTexture;
  112297. /**
  112298. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112299. *
  112300. * @param name The material name
  112301. * @param scene The scene the material will be use in.
  112302. */
  112303. constructor(name: string, scene: Scene);
  112304. /**
  112305. * Return the currrent class name of the material.
  112306. */
  112307. getClassName(): string;
  112308. /**
  112309. * Makes a duplicate of the current material.
  112310. * @param name - name to use for the new material.
  112311. */
  112312. clone(name: string): PBRMetallicRoughnessMaterial;
  112313. /**
  112314. * Serialize the material to a parsable JSON object.
  112315. */
  112316. serialize(): any;
  112317. /**
  112318. * Parses a JSON object correponding to the serialize function.
  112319. */
  112320. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112321. }
  112322. }
  112323. declare module BABYLON {
  112324. /**
  112325. * The PBR material of BJS following the specular glossiness convention.
  112326. *
  112327. * This fits to the PBR convention in the GLTF definition:
  112328. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112329. */
  112330. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112331. /**
  112332. * Specifies the diffuse color of the material.
  112333. */
  112334. diffuseColor: Color3;
  112335. /**
  112336. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112337. * channel.
  112338. */
  112339. diffuseTexture: BaseTexture;
  112340. /**
  112341. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112342. */
  112343. specularColor: Color3;
  112344. /**
  112345. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112346. */
  112347. glossiness: number;
  112348. /**
  112349. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112350. */
  112351. specularGlossinessTexture: BaseTexture;
  112352. /**
  112353. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112354. *
  112355. * @param name The material name
  112356. * @param scene The scene the material will be use in.
  112357. */
  112358. constructor(name: string, scene: Scene);
  112359. /**
  112360. * Return the currrent class name of the material.
  112361. */
  112362. getClassName(): string;
  112363. /**
  112364. * Makes a duplicate of the current material.
  112365. * @param name - name to use for the new material.
  112366. */
  112367. clone(name: string): PBRSpecularGlossinessMaterial;
  112368. /**
  112369. * Serialize the material to a parsable JSON object.
  112370. */
  112371. serialize(): any;
  112372. /**
  112373. * Parses a JSON object correponding to the serialize function.
  112374. */
  112375. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112376. }
  112377. }
  112378. declare module BABYLON {
  112379. /**
  112380. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112381. * It can help converting any input color in a desired output one. This can then be used to create effects
  112382. * from sepia, black and white to sixties or futuristic rendering...
  112383. *
  112384. * The only supported format is currently 3dl.
  112385. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112386. */
  112387. export class ColorGradingTexture extends BaseTexture {
  112388. /**
  112389. * The current texture matrix. (will always be identity in color grading texture)
  112390. */
  112391. private _textureMatrix;
  112392. /**
  112393. * The texture URL.
  112394. */
  112395. url: string;
  112396. /**
  112397. * Empty line regex stored for GC.
  112398. */
  112399. private static _noneEmptyLineRegex;
  112400. private _engine;
  112401. /**
  112402. * Instantiates a ColorGradingTexture from the following parameters.
  112403. *
  112404. * @param url The location of the color gradind data (currently only supporting 3dl)
  112405. * @param scene The scene the texture will be used in
  112406. */
  112407. constructor(url: string, scene: Scene);
  112408. /**
  112409. * Returns the texture matrix used in most of the material.
  112410. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112411. */
  112412. getTextureMatrix(): Matrix;
  112413. /**
  112414. * Occurs when the file being loaded is a .3dl LUT file.
  112415. */
  112416. private load3dlTexture;
  112417. /**
  112418. * Starts the loading process of the texture.
  112419. */
  112420. private loadTexture;
  112421. /**
  112422. * Clones the color gradind texture.
  112423. */
  112424. clone(): ColorGradingTexture;
  112425. /**
  112426. * Called during delayed load for textures.
  112427. */
  112428. delayLoad(): void;
  112429. /**
  112430. * Parses a color grading texture serialized by Babylon.
  112431. * @param parsedTexture The texture information being parsedTexture
  112432. * @param scene The scene to load the texture in
  112433. * @param rootUrl The root url of the data assets to load
  112434. * @return A color gradind texture
  112435. */
  112436. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112437. /**
  112438. * Serializes the LUT texture to json format.
  112439. */
  112440. serialize(): any;
  112441. }
  112442. }
  112443. declare module BABYLON {
  112444. /**
  112445. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112446. */
  112447. export class EquiRectangularCubeTexture extends BaseTexture {
  112448. /** The six faces of the cube. */
  112449. private static _FacesMapping;
  112450. private _noMipmap;
  112451. private _onLoad;
  112452. private _onError;
  112453. /** The size of the cubemap. */
  112454. private _size;
  112455. /** The buffer of the image. */
  112456. private _buffer;
  112457. /** The width of the input image. */
  112458. private _width;
  112459. /** The height of the input image. */
  112460. private _height;
  112461. /** The URL to the image. */
  112462. url: string;
  112463. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112464. coordinatesMode: number;
  112465. /**
  112466. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112467. * @param url The location of the image
  112468. * @param scene The scene the texture will be used in
  112469. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112470. * @param noMipmap Forces to not generate the mipmap if true
  112471. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112472. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112473. * @param onLoad — defines a callback called when texture is loaded
  112474. * @param onError — defines a callback called if there is an error
  112475. */
  112476. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112477. /**
  112478. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112479. */
  112480. private loadImage;
  112481. /**
  112482. * Convert the image buffer into a cubemap and create a CubeTexture.
  112483. */
  112484. private loadTexture;
  112485. /**
  112486. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112487. * @param buffer The ArrayBuffer that should be converted.
  112488. * @returns The buffer as Float32Array.
  112489. */
  112490. private getFloat32ArrayFromArrayBuffer;
  112491. /**
  112492. * Get the current class name of the texture useful for serialization or dynamic coding.
  112493. * @returns "EquiRectangularCubeTexture"
  112494. */
  112495. getClassName(): string;
  112496. /**
  112497. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112498. * @returns A clone of the current EquiRectangularCubeTexture.
  112499. */
  112500. clone(): EquiRectangularCubeTexture;
  112501. }
  112502. }
  112503. declare module BABYLON {
  112504. /**
  112505. * Based on jsTGALoader - Javascript loader for TGA file
  112506. * By Vincent Thibault
  112507. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112508. */
  112509. export class TGATools {
  112510. private static _TYPE_INDEXED;
  112511. private static _TYPE_RGB;
  112512. private static _TYPE_GREY;
  112513. private static _TYPE_RLE_INDEXED;
  112514. private static _TYPE_RLE_RGB;
  112515. private static _TYPE_RLE_GREY;
  112516. private static _ORIGIN_MASK;
  112517. private static _ORIGIN_SHIFT;
  112518. private static _ORIGIN_BL;
  112519. private static _ORIGIN_BR;
  112520. private static _ORIGIN_UL;
  112521. private static _ORIGIN_UR;
  112522. /**
  112523. * Gets the header of a TGA file
  112524. * @param data defines the TGA data
  112525. * @returns the header
  112526. */
  112527. static GetTGAHeader(data: Uint8Array): any;
  112528. /**
  112529. * Uploads TGA content to a Babylon Texture
  112530. * @hidden
  112531. */
  112532. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112533. /** @hidden */
  112534. 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;
  112535. /** @hidden */
  112536. 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;
  112537. /** @hidden */
  112538. 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;
  112539. /** @hidden */
  112540. 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;
  112541. /** @hidden */
  112542. 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;
  112543. /** @hidden */
  112544. 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;
  112545. }
  112546. }
  112547. declare module BABYLON {
  112548. /**
  112549. * Implementation of the TGA Texture Loader.
  112550. * @hidden
  112551. */
  112552. export class _TGATextureLoader implements IInternalTextureLoader {
  112553. /**
  112554. * Defines wether the loader supports cascade loading the different faces.
  112555. */
  112556. readonly supportCascades: boolean;
  112557. /**
  112558. * This returns if the loader support the current file information.
  112559. * @param extension defines the file extension of the file being loaded
  112560. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112561. * @param fallback defines the fallback internal texture if any
  112562. * @param isBase64 defines whether the texture is encoded as a base64
  112563. * @param isBuffer defines whether the texture data are stored as a buffer
  112564. * @returns true if the loader can load the specified file
  112565. */
  112566. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112567. /**
  112568. * Transform the url before loading if required.
  112569. * @param rootUrl the url of the texture
  112570. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112571. * @returns the transformed texture
  112572. */
  112573. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112574. /**
  112575. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112576. * @param rootUrl the url of the texture
  112577. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112578. * @returns the fallback texture
  112579. */
  112580. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112581. /**
  112582. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112583. * @param data contains the texture data
  112584. * @param texture defines the BabylonJS internal texture
  112585. * @param createPolynomials will be true if polynomials have been requested
  112586. * @param onLoad defines the callback to trigger once the texture is ready
  112587. * @param onError defines the callback to trigger in case of error
  112588. */
  112589. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112590. /**
  112591. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112592. * @param data contains the texture data
  112593. * @param texture defines the BabylonJS internal texture
  112594. * @param callback defines the method to call once ready to upload
  112595. */
  112596. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112597. }
  112598. }
  112599. declare module BABYLON {
  112600. /**
  112601. * Info about the .basis files
  112602. */
  112603. class BasisFileInfo {
  112604. /**
  112605. * If the file has alpha
  112606. */
  112607. hasAlpha: boolean;
  112608. /**
  112609. * Width of the image
  112610. */
  112611. width: number;
  112612. /**
  112613. * Height of the image
  112614. */
  112615. height: number;
  112616. /**
  112617. * Aligned width used when falling back to Rgb565 ((width + 3) & ~3)
  112618. */
  112619. alignedWidth: number;
  112620. /**
  112621. * Aligned height used when falling back to Rgb565 ((height + 3) & ~3)
  112622. */
  112623. alignedHeight: number;
  112624. }
  112625. /**
  112626. * Used to load .Basis files
  112627. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  112628. */
  112629. export class BasisTools {
  112630. private static _IgnoreSupportedFormats;
  112631. private static _LoadScriptPromise;
  112632. private static _FallbackURL;
  112633. private static _BASIS_FORMAT;
  112634. /**
  112635. * Basis module can be aquired from https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  112636. * This should be set prior to loading a .basis texture
  112637. */
  112638. static BasisModule: Nullable<any>;
  112639. /**
  112640. * Verifies that the BasisModule has been populated and falls back to loading from the web if not availible
  112641. * @returns promise which will resolve if the basis module was loaded
  112642. */
  112643. static VerifyBasisModuleAsync(): any;
  112644. /**
  112645. * Verifies that the basis module has been populated and creates a bsis file from the image data
  112646. * @param data array buffer of the .basis file
  112647. * @returns the Basis file
  112648. */
  112649. static LoadBasisFile(data: ArrayBuffer): any;
  112650. /**
  112651. * Detects the supported transcode format for the file
  112652. * @param engine Babylon engine
  112653. * @param fileInfo info about the file
  112654. * @returns the chosed format or null if none are supported
  112655. */
  112656. static GetSupportedTranscodeFormat(engine: Engine, fileInfo: BasisFileInfo): Nullable<number>;
  112657. /**
  112658. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  112659. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  112660. * @returns internal format corresponding to the Basis format
  112661. */
  112662. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  112663. /**
  112664. * Retreives information about the basis file eg. dimensions
  112665. * @param basisFile the basis file to get the info from
  112666. * @returns information about the basis file
  112667. */
  112668. static GetFileInfo(basisFile: any): BasisFileInfo;
  112669. /**
  112670. * Transcodes the basis file to the requested format to be transferred to the gpu
  112671. * @param format fromat to be transferred to
  112672. * @param fileInfo information about the loaded file
  112673. * @param loadedFile the loaded basis file
  112674. * @returns the resulting pixels and if the transcode fell back to using Rgb565
  112675. */
  112676. static TranscodeFile(format: Nullable<number>, fileInfo: BasisFileInfo, loadedFile: any): {
  112677. fallbackToRgb565: boolean;
  112678. pixels: Uint8Array;
  112679. };
  112680. /**
  112681. * From https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture/dxt-to-rgb565.js
  112682. * An unoptimized version of dxtToRgb565. Also, the floating
  112683. * point math used to compute the colors actually results in
  112684. * slightly different colors compared to hardware DXT decoders.
  112685. * @param src dxt src pixels
  112686. * @param srcByteOffset offset for the start of src
  112687. * @param width aligned width of the image
  112688. * @param height aligned height of the image
  112689. * @return the converted pixels
  112690. */
  112691. static ConvertDxtToRgb565(src: Uint16Array, srcByteOffset: number, width: number, height: number): Uint16Array;
  112692. }
  112693. }
  112694. declare module BABYLON {
  112695. /**
  112696. * Loader for .basis file format
  112697. */
  112698. export class _BasisTextureLoader implements IInternalTextureLoader {
  112699. /**
  112700. * Defines whether the loader supports cascade loading the different faces.
  112701. */
  112702. readonly supportCascades: boolean;
  112703. /**
  112704. * This returns if the loader support the current file information.
  112705. * @param extension defines the file extension of the file being loaded
  112706. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112707. * @param fallback defines the fallback internal texture if any
  112708. * @param isBase64 defines whether the texture is encoded as a base64
  112709. * @param isBuffer defines whether the texture data are stored as a buffer
  112710. * @returns true if the loader can load the specified file
  112711. */
  112712. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112713. /**
  112714. * Transform the url before loading if required.
  112715. * @param rootUrl the url of the texture
  112716. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112717. * @returns the transformed texture
  112718. */
  112719. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112720. /**
  112721. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112722. * @param rootUrl the url of the texture
  112723. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112724. * @returns the fallback texture
  112725. */
  112726. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112727. /**
  112728. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  112729. * @param data contains the texture data
  112730. * @param texture defines the BabylonJS internal texture
  112731. * @param createPolynomials will be true if polynomials have been requested
  112732. * @param onLoad defines the callback to trigger once the texture is ready
  112733. * @param onError defines the callback to trigger in case of error
  112734. */
  112735. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112736. /**
  112737. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112738. * @param data contains the texture data
  112739. * @param texture defines the BabylonJS internal texture
  112740. * @param callback defines the method to call once ready to upload
  112741. */
  112742. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112743. }
  112744. }
  112745. declare module BABYLON {
  112746. /**
  112747. * 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.
  112748. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112749. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112750. */
  112751. export class CustomProceduralTexture extends ProceduralTexture {
  112752. private _animate;
  112753. private _time;
  112754. private _config;
  112755. private _texturePath;
  112756. /**
  112757. * Instantiates a new Custom Procedural Texture.
  112758. * 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.
  112759. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112760. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112761. * @param name Define the name of the texture
  112762. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  112763. * @param size Define the size of the texture to create
  112764. * @param scene Define the scene the texture belongs to
  112765. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  112766. * @param generateMipMaps Define if the texture should creates mip maps or not
  112767. */
  112768. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112769. private _loadJson;
  112770. /**
  112771. * Is the texture ready to be used ? (rendered at least once)
  112772. * @returns true if ready, otherwise, false.
  112773. */
  112774. isReady(): boolean;
  112775. /**
  112776. * Render the texture to its associated render target.
  112777. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  112778. */
  112779. render(useCameraPostProcess?: boolean): void;
  112780. /**
  112781. * Update the list of dependant textures samplers in the shader.
  112782. */
  112783. updateTextures(): void;
  112784. /**
  112785. * Update the uniform values of the procedural texture in the shader.
  112786. */
  112787. updateShaderUniforms(): void;
  112788. /**
  112789. * Define if the texture animates or not.
  112790. */
  112791. animate: boolean;
  112792. }
  112793. }
  112794. declare module BABYLON {
  112795. /** @hidden */
  112796. export var noisePixelShader: {
  112797. name: string;
  112798. shader: string;
  112799. };
  112800. }
  112801. declare module BABYLON {
  112802. /**
  112803. * Class used to generate noise procedural textures
  112804. */
  112805. export class NoiseProceduralTexture extends ProceduralTexture {
  112806. private _time;
  112807. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  112808. brightness: number;
  112809. /** Defines the number of octaves to process */
  112810. octaves: number;
  112811. /** Defines the level of persistence (0.8 by default) */
  112812. persistence: number;
  112813. /** Gets or sets animation speed factor (default is 1) */
  112814. animationSpeedFactor: number;
  112815. /**
  112816. * Creates a new NoiseProceduralTexture
  112817. * @param name defines the name fo the texture
  112818. * @param size defines the size of the texture (default is 256)
  112819. * @param scene defines the hosting scene
  112820. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  112821. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  112822. */
  112823. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112824. private _updateShaderUniforms;
  112825. protected _getDefines(): string;
  112826. /** Generate the current state of the procedural texture */
  112827. render(useCameraPostProcess?: boolean): void;
  112828. /**
  112829. * Serializes this noise procedural texture
  112830. * @returns a serialized noise procedural texture object
  112831. */
  112832. serialize(): any;
  112833. /**
  112834. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  112835. * @param parsedTexture defines parsed texture data
  112836. * @param scene defines the current scene
  112837. * @param rootUrl defines the root URL containing noise procedural texture information
  112838. * @returns a parsed NoiseProceduralTexture
  112839. */
  112840. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  112841. }
  112842. }
  112843. declare module BABYLON {
  112844. /**
  112845. * Raw cube texture where the raw buffers are passed in
  112846. */
  112847. export class RawCubeTexture extends CubeTexture {
  112848. /**
  112849. * Creates a cube texture where the raw buffers are passed in.
  112850. * @param scene defines the scene the texture is attached to
  112851. * @param data defines the array of data to use to create each face
  112852. * @param size defines the size of the textures
  112853. * @param format defines the format of the data
  112854. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  112855. * @param generateMipMaps defines if the engine should generate the mip levels
  112856. * @param invertY defines if data must be stored with Y axis inverted
  112857. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  112858. * @param compression defines the compression used (null by default)
  112859. */
  112860. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  112861. /**
  112862. * Updates the raw cube texture.
  112863. * @param data defines the data to store
  112864. * @param format defines the data format
  112865. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112866. * @param invertY defines if data must be stored with Y axis inverted
  112867. * @param compression defines the compression used (null by default)
  112868. * @param level defines which level of the texture to update
  112869. */
  112870. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  112871. /**
  112872. * Updates a raw cube texture with RGBD encoded data.
  112873. * @param data defines the array of data [mipmap][face] to use to create each face
  112874. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  112875. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112876. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112877. * @returns a promsie that resolves when the operation is complete
  112878. */
  112879. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  112880. /**
  112881. * Clones the raw cube texture.
  112882. * @return a new cube texture
  112883. */
  112884. clone(): CubeTexture;
  112885. /** @hidden */
  112886. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112887. }
  112888. }
  112889. declare module BABYLON {
  112890. /**
  112891. * Class used to store 3D textures containing user data
  112892. */
  112893. export class RawTexture3D extends Texture {
  112894. /** Gets or sets the texture format to use */
  112895. format: number;
  112896. private _engine;
  112897. /**
  112898. * Create a new RawTexture3D
  112899. * @param data defines the data of the texture
  112900. * @param width defines the width of the texture
  112901. * @param height defines the height of the texture
  112902. * @param depth defines the depth of the texture
  112903. * @param format defines the texture format to use
  112904. * @param scene defines the hosting scene
  112905. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  112906. * @param invertY defines if texture must be stored with Y axis inverted
  112907. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112908. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  112909. */
  112910. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  112911. /** Gets or sets the texture format to use */
  112912. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  112913. /**
  112914. * Update the texture with new data
  112915. * @param data defines the data to store in the texture
  112916. */
  112917. update(data: ArrayBufferView): void;
  112918. }
  112919. }
  112920. declare module BABYLON {
  112921. /**
  112922. * Creates a refraction texture used by refraction channel of the standard material.
  112923. * It is like a mirror but to see through a material.
  112924. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112925. */
  112926. export class RefractionTexture extends RenderTargetTexture {
  112927. /**
  112928. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  112929. * 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.
  112930. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112931. */
  112932. refractionPlane: Plane;
  112933. /**
  112934. * Define how deep under the surface we should see.
  112935. */
  112936. depth: number;
  112937. /**
  112938. * Creates a refraction texture used by refraction channel of the standard material.
  112939. * It is like a mirror but to see through a material.
  112940. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112941. * @param name Define the texture name
  112942. * @param size Define the size of the underlying texture
  112943. * @param scene Define the scene the refraction belongs to
  112944. * @param generateMipMaps Define if we need to generate mips level for the refraction
  112945. */
  112946. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  112947. /**
  112948. * Clone the refraction texture.
  112949. * @returns the cloned texture
  112950. */
  112951. clone(): RefractionTexture;
  112952. /**
  112953. * Serialize the texture to a JSON representation you could use in Parse later on
  112954. * @returns the serialized JSON representation
  112955. */
  112956. serialize(): any;
  112957. }
  112958. }
  112959. declare module BABYLON {
  112960. /**
  112961. * Defines the options related to the creation of an HtmlElementTexture
  112962. */
  112963. export interface IHtmlElementTextureOptions {
  112964. /**
  112965. * Defines wether mip maps should be created or not.
  112966. */
  112967. generateMipMaps?: boolean;
  112968. /**
  112969. * Defines the sampling mode of the texture.
  112970. */
  112971. samplingMode?: number;
  112972. /**
  112973. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  112974. */
  112975. engine: Nullable<Engine>;
  112976. /**
  112977. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  112978. */
  112979. scene: Nullable<Scene>;
  112980. }
  112981. /**
  112982. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  112983. * To be as efficient as possible depending on your constraints nothing aside the first upload
  112984. * is automatically managed.
  112985. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  112986. * in your application.
  112987. *
  112988. * As the update is not automatic, you need to call them manually.
  112989. */
  112990. export class HtmlElementTexture extends BaseTexture {
  112991. /**
  112992. * The texture URL.
  112993. */
  112994. element: HTMLVideoElement | HTMLCanvasElement;
  112995. private static readonly DefaultOptions;
  112996. private _textureMatrix;
  112997. private _engine;
  112998. private _isVideo;
  112999. private _generateMipMaps;
  113000. private _samplingMode;
  113001. /**
  113002. * Instantiates a HtmlElementTexture from the following parameters.
  113003. *
  113004. * @param name Defines the name of the texture
  113005. * @param element Defines the video or canvas the texture is filled with
  113006. * @param options Defines the other none mandatory texture creation options
  113007. */
  113008. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113009. private _createInternalTexture;
  113010. /**
  113011. * Returns the texture matrix used in most of the material.
  113012. */
  113013. getTextureMatrix(): Matrix;
  113014. /**
  113015. * Updates the content of the texture.
  113016. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113017. */
  113018. update(invertY?: Nullable<boolean>): void;
  113019. }
  113020. }
  113021. declare module BABYLON {
  113022. /**
  113023. * Enum used to define the target of a block
  113024. */
  113025. export enum NodeMaterialBlockTargets {
  113026. /** Vertex shader */
  113027. Vertex = 1,
  113028. /** Fragment shader */
  113029. Fragment = 2,
  113030. /** Vertex and Fragment */
  113031. VertexAndFragment = 3
  113032. }
  113033. }
  113034. declare module BABYLON {
  113035. /**
  113036. * Defines the kind of connection point for node based material
  113037. */
  113038. export enum NodeMaterialBlockConnectionPointTypes {
  113039. /** Float */
  113040. Float = 1,
  113041. /** Int */
  113042. Int = 2,
  113043. /** Vector2 */
  113044. Vector2 = 4,
  113045. /** Vector3 */
  113046. Vector3 = 8,
  113047. /** Vector4 */
  113048. Vector4 = 16,
  113049. /** Color3 */
  113050. Color3 = 32,
  113051. /** Color4 */
  113052. Color4 = 64,
  113053. /** Matrix */
  113054. Matrix = 128,
  113055. /** Texture */
  113056. Texture = 256,
  113057. /** Texture3D */
  113058. Texture3D = 512,
  113059. /** Vector3 or Color3 */
  113060. Vector3OrColor3 = 40,
  113061. /** Vector3 or Vector4 */
  113062. Vector3OrVector4 = 24,
  113063. /** Vector4 or Color4 */
  113064. Vector4OrColor4 = 80,
  113065. /** Color3 or Color4 */
  113066. Color3OrColor4 = 96,
  113067. /** Vector3 or Color3 */
  113068. Vector3OrColor3OrVector4OrColor4 = 120
  113069. }
  113070. }
  113071. declare module BABYLON {
  113072. /**
  113073. * Enum used to define well known values e.g. values automatically provided by the system
  113074. */
  113075. export enum NodeMaterialWellKnownValues {
  113076. /** World */
  113077. World = 1,
  113078. /** View */
  113079. View = 2,
  113080. /** Projection */
  113081. Projection = 3,
  113082. /** ViewProjection */
  113083. ViewProjection = 4,
  113084. /** WorldView */
  113085. WorldView = 5,
  113086. /** WorldViewProjection */
  113087. WorldViewProjection = 6,
  113088. /** Will be filled by the block itself */
  113089. Automatic = 7
  113090. }
  113091. }
  113092. declare module BABYLON {
  113093. /**
  113094. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113095. */
  113096. export enum NodeMaterialBlockConnectionPointMode {
  113097. /** Value is an uniform */
  113098. Uniform = 0,
  113099. /** Value is a mesh attribute */
  113100. Attribute = 1,
  113101. /** Value is a varying between vertex and fragment shaders */
  113102. Varying = 2,
  113103. /** Mode is undefined */
  113104. Undefined = 3
  113105. }
  113106. }
  113107. declare module BABYLON {
  113108. /**
  113109. * Class used to store shared data between 2 NodeMaterialBuildState
  113110. */
  113111. export class NodeMaterialBuildStateSharedData {
  113112. /**
  113113. * Gets the list of emitted varyings
  113114. */
  113115. varyings: string[];
  113116. /**
  113117. * Gets the varying declaration string
  113118. */
  113119. varyingDeclaration: string;
  113120. /**
  113121. * Uniform connection points
  113122. */
  113123. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113124. /**
  113125. * Bindable blocks (Blocks that need to set data to the effect)
  113126. */
  113127. bindableBlocks: NodeMaterialBlock[];
  113128. /**
  113129. * List of blocks that can provide a compilation fallback
  113130. */
  113131. blocksWithFallbacks: NodeMaterialBlock[];
  113132. /**
  113133. * List of blocks that can provide a define update
  113134. */
  113135. blocksWithDefines: NodeMaterialBlock[];
  113136. /**
  113137. * List of blocks that can provide a repeatable content
  113138. */
  113139. repeatableContentBlocks: NodeMaterialBlock[];
  113140. /**
  113141. * List of blocks that can block the isReady function for the material
  113142. */
  113143. blockingBlocks: NodeMaterialBlock[];
  113144. /**
  113145. * Build Id used to avoid multiple recompilations
  113146. */
  113147. buildId: number;
  113148. /** List of emitted variables */
  113149. variableNames: {
  113150. [key: string]: number;
  113151. };
  113152. /** List of emitted defines */
  113153. defineNames: {
  113154. [key: string]: number;
  113155. };
  113156. /** Should emit comments? */
  113157. emitComments: boolean;
  113158. /** Emit build activity */
  113159. verbose: boolean;
  113160. /**
  113161. * Gets the compilation hints emitted at compilation time
  113162. */
  113163. hints: {
  113164. needWorldViewMatrix: boolean;
  113165. needWorldViewProjectionMatrix: boolean;
  113166. needAlphaBlending: boolean;
  113167. needAlphaTesting: boolean;
  113168. };
  113169. /**
  113170. * List of compilation checks
  113171. */
  113172. checks: {
  113173. emitVertex: boolean;
  113174. emitFragment: boolean;
  113175. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113176. };
  113177. /** Creates a new shared data */
  113178. constructor();
  113179. /**
  113180. * Emits console errors and exceptions if there is a failing check
  113181. */
  113182. emitErrors(): void;
  113183. }
  113184. }
  113185. declare module BABYLON {
  113186. /**
  113187. * Class used to store node based material build state
  113188. */
  113189. export class NodeMaterialBuildState {
  113190. /**
  113191. * Gets the list of emitted attributes
  113192. */
  113193. attributes: string[];
  113194. /**
  113195. * Gets the list of emitted uniforms
  113196. */
  113197. uniforms: string[];
  113198. /**
  113199. * Gets the list of emitted samplers
  113200. */
  113201. samplers: string[];
  113202. /**
  113203. * Gets the list of emitted functions
  113204. */
  113205. functions: {
  113206. [key: string]: string;
  113207. };
  113208. /**
  113209. * Gets the target of the compilation state
  113210. */
  113211. target: NodeMaterialBlockTargets;
  113212. /**
  113213. * Shared data between multiple NodeMaterialBuildState instances
  113214. */
  113215. sharedData: NodeMaterialBuildStateSharedData;
  113216. /** @hidden */
  113217. _vertexState: NodeMaterialBuildState;
  113218. private _attributeDeclaration;
  113219. private _uniformDeclaration;
  113220. private _samplerDeclaration;
  113221. private _varyingTransfer;
  113222. private _repeatableContentAnchorIndex;
  113223. /** @hidden */
  113224. _builtCompilationString: string;
  113225. /**
  113226. * Gets the emitted compilation strings
  113227. */
  113228. compilationString: string;
  113229. /**
  113230. * Finalize the compilation strings
  113231. * @param state defines the current compilation state
  113232. */
  113233. finalize(state: NodeMaterialBuildState): void;
  113234. /** @hidden */
  113235. readonly _repeatableContentAnchor: string;
  113236. /** @hidden */
  113237. _getFreeVariableName(prefix: string): string;
  113238. /** @hidden */
  113239. _getFreeDefineName(prefix: string): string;
  113240. /** @hidden */
  113241. _excludeVariableName(name: string): void;
  113242. /** @hidden */
  113243. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113244. /** @hidden */
  113245. _emitFunction(name: string, code: string, comments: string): void;
  113246. /** @hidden */
  113247. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113248. replaceStrings?: {
  113249. search: RegExp;
  113250. replace: string;
  113251. }[];
  113252. }): string;
  113253. /** @hidden */
  113254. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113255. repeatKey?: string;
  113256. removeAttributes?: boolean;
  113257. removeUniforms?: boolean;
  113258. removeVaryings?: boolean;
  113259. removeIfDef?: boolean;
  113260. replaceStrings?: {
  113261. search: RegExp;
  113262. replace: string;
  113263. }[];
  113264. }): void;
  113265. /** @hidden */
  113266. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  113267. private _emitDefine;
  113268. /** @hidden */
  113269. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113270. }
  113271. }
  113272. declare module BABYLON {
  113273. /**
  113274. * Root class for all node material optimizers
  113275. */
  113276. export class NodeMaterialOptimizer {
  113277. /**
  113278. * Function used to optimize a NodeMaterial graph
  113279. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113280. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113281. */
  113282. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113283. }
  113284. }
  113285. declare module BABYLON {
  113286. /**
  113287. * Block used to transform a vector4 with a matrix
  113288. */
  113289. export class Vector4TransformBlock extends NodeMaterialBlock {
  113290. /**
  113291. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113292. */
  113293. complementW: number;
  113294. /**
  113295. * Creates a new Vector4TransformBlock
  113296. * @param name defines the block name
  113297. */
  113298. constructor(name: string);
  113299. /**
  113300. * Gets the current class name
  113301. * @returns the class name
  113302. */
  113303. getClassName(): string;
  113304. /**
  113305. * Gets the vector input
  113306. */
  113307. readonly vector: NodeMaterialConnectionPoint;
  113308. /**
  113309. * Gets the matrix transform input
  113310. */
  113311. readonly transform: NodeMaterialConnectionPoint;
  113312. protected _buildBlock(state: NodeMaterialBuildState): this;
  113313. }
  113314. }
  113315. declare module BABYLON {
  113316. /**
  113317. * Block used to output the vertex position
  113318. */
  113319. export class VertexOutputBlock extends NodeMaterialBlock {
  113320. /**
  113321. * Creates a new VertexOutputBlock
  113322. * @param name defines the block name
  113323. */
  113324. constructor(name: string);
  113325. /**
  113326. * Gets the current class name
  113327. * @returns the class name
  113328. */
  113329. getClassName(): string;
  113330. /**
  113331. * Gets the vector input component
  113332. */
  113333. readonly vector: NodeMaterialConnectionPoint;
  113334. protected _buildBlock(state: NodeMaterialBuildState): this;
  113335. }
  113336. }
  113337. declare module BABYLON {
  113338. /**
  113339. * Block used to output the final color
  113340. */
  113341. export class FragmentOutputBlock extends NodeMaterialBlock {
  113342. /**
  113343. * Gets or sets a boolean indicating if this block will output an alpha value
  113344. */
  113345. alphaBlendingEnabled: boolean;
  113346. /**
  113347. * Create a new FragmentOutputBlock
  113348. * @param name defines the block name
  113349. */
  113350. constructor(name: string);
  113351. /**
  113352. * Gets the current class name
  113353. * @returns the class name
  113354. */
  113355. getClassName(): string;
  113356. /**
  113357. * Gets the color input component
  113358. */
  113359. readonly color: NodeMaterialConnectionPoint;
  113360. protected _buildBlock(state: NodeMaterialBuildState): this;
  113361. }
  113362. }
  113363. declare module BABYLON {
  113364. /**
  113365. * Interface used to configure the node material editor
  113366. */
  113367. export interface INodeMaterialEditorOptions {
  113368. /** Define the URl to load node editor script */
  113369. editorURL?: string;
  113370. }
  113371. /** @hidden */
  113372. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113373. /** BONES */
  113374. NUM_BONE_INFLUENCERS: number;
  113375. BonesPerMesh: number;
  113376. BONETEXTURE: boolean;
  113377. /** MORPH TARGETS */
  113378. MORPHTARGETS: boolean;
  113379. MORPHTARGETS_NORMAL: boolean;
  113380. MORPHTARGETS_TANGENT: boolean;
  113381. NUM_MORPH_INFLUENCERS: number;
  113382. /** IMAGE PROCESSING */
  113383. IMAGEPROCESSING: boolean;
  113384. VIGNETTE: boolean;
  113385. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113386. VIGNETTEBLENDMODEOPAQUE: boolean;
  113387. TONEMAPPING: boolean;
  113388. TONEMAPPING_ACES: boolean;
  113389. CONTRAST: boolean;
  113390. EXPOSURE: boolean;
  113391. COLORCURVES: boolean;
  113392. COLORGRADING: boolean;
  113393. COLORGRADING3D: boolean;
  113394. SAMPLER3DGREENDEPTH: boolean;
  113395. SAMPLER3DBGRMAP: boolean;
  113396. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113397. constructor();
  113398. setValue(name: string, value: boolean): void;
  113399. }
  113400. /**
  113401. * Class used to configure NodeMaterial
  113402. */
  113403. export interface INodeMaterialOptions {
  113404. /**
  113405. * Defines if blocks should emit comments
  113406. */
  113407. emitComments: boolean;
  113408. }
  113409. /**
  113410. * Class used to create a node based material built by assembling shader blocks
  113411. */
  113412. export class NodeMaterial extends PushMaterial {
  113413. private _options;
  113414. private _vertexCompilationState;
  113415. private _fragmentCompilationState;
  113416. private _sharedData;
  113417. private _buildId;
  113418. private _buildWasSuccessful;
  113419. private _cachedWorldViewMatrix;
  113420. private _cachedWorldViewProjectionMatrix;
  113421. private _textureConnectionPoints;
  113422. private _optimizers;
  113423. /** Define the URl to load node editor script */
  113424. static EditorURL: string;
  113425. private BJSNODEMATERIALEDITOR;
  113426. /** Get the inspector from bundle or global */
  113427. private _getGlobalNodeMaterialEditor;
  113428. /**
  113429. * Defines the maximum number of lights that can be used in the material
  113430. */
  113431. maxSimultaneousLights: number;
  113432. /**
  113433. * Observable raised when the material is built
  113434. */
  113435. onBuildObservable: Observable<NodeMaterial>;
  113436. /**
  113437. * Gets or sets the root nodes of the material vertex shader
  113438. */
  113439. _vertexOutputNodes: NodeMaterialBlock[];
  113440. /**
  113441. * Gets or sets the root nodes of the material fragment (pixel) shader
  113442. */
  113443. _fragmentOutputNodes: NodeMaterialBlock[];
  113444. /** Gets or sets options to control the node material overall behavior */
  113445. options: INodeMaterialOptions;
  113446. /**
  113447. * Default configuration related to image processing available in the standard Material.
  113448. */
  113449. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113450. /**
  113451. * Gets the image processing configuration used either in this material.
  113452. */
  113453. /**
  113454. * Sets the Default image processing configuration used either in the this material.
  113455. *
  113456. * If sets to null, the scene one is in use.
  113457. */
  113458. imageProcessingConfiguration: ImageProcessingConfiguration;
  113459. /**
  113460. * Create a new node based material
  113461. * @param name defines the material name
  113462. * @param scene defines the hosting scene
  113463. * @param options defines creation option
  113464. */
  113465. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113466. /**
  113467. * Gets the current class name of the material e.g. "NodeMaterial"
  113468. * @returns the class name
  113469. */
  113470. getClassName(): string;
  113471. /**
  113472. * Keep track of the image processing observer to allow dispose and replace.
  113473. */
  113474. private _imageProcessingObserver;
  113475. /**
  113476. * Attaches a new image processing configuration to the Standard Material.
  113477. * @param configuration
  113478. */
  113479. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113480. /**
  113481. * Adds a new optimizer to the list of optimizers
  113482. * @param optimizer defines the optimizers to add
  113483. * @returns the current material
  113484. */
  113485. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113486. /**
  113487. * Remove an optimizer from the list of optimizers
  113488. * @param optimizer defines the optimizers to remove
  113489. * @returns the current material
  113490. */
  113491. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113492. /**
  113493. * Add a new block to the list of output nodes
  113494. * @param node defines the node to add
  113495. * @returns the current material
  113496. */
  113497. addOutputNode(node: NodeMaterialBlock): this;
  113498. /**
  113499. * Remove a block from the list of root nodes
  113500. * @param node defines the node to remove
  113501. * @returns the current material
  113502. */
  113503. removeOutputNode(node: NodeMaterialBlock): this;
  113504. private _addVertexOutputNode;
  113505. private _removeVertexOutputNode;
  113506. private _addFragmentOutputNode;
  113507. private _removeFragmentOutputNode;
  113508. /**
  113509. * Specifies if the material will require alpha blending
  113510. * @returns a boolean specifying if alpha blending is needed
  113511. */
  113512. needAlphaBlending(): boolean;
  113513. /**
  113514. * Specifies if this material should be rendered in alpha test mode
  113515. * @returns a boolean specifying if an alpha test is needed.
  113516. */
  113517. needAlphaTesting(): boolean;
  113518. private _initializeBlock;
  113519. private _resetDualBlocks;
  113520. /**
  113521. * Build the material and generates the inner effect
  113522. * @param verbose defines if the build should log activity
  113523. */
  113524. build(verbose?: boolean): void;
  113525. /**
  113526. * Runs an otpimization phase to try to improve the shader code
  113527. */
  113528. optimize(): void;
  113529. private _prepareDefinesForAttributes;
  113530. /**
  113531. * Get if the submesh is ready to be used and all its information available.
  113532. * Child classes can use it to update shaders
  113533. * @param mesh defines the mesh to check
  113534. * @param subMesh defines which submesh to check
  113535. * @param useInstances specifies that instances should be used
  113536. * @returns a boolean indicating that the submesh is ready or not
  113537. */
  113538. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113539. /**
  113540. * Binds the world matrix to the material
  113541. * @param world defines the world transformation matrix
  113542. */
  113543. bindOnlyWorldMatrix(world: Matrix): void;
  113544. /**
  113545. * Binds the submesh to this material by preparing the effect and shader to draw
  113546. * @param world defines the world transformation matrix
  113547. * @param mesh defines the mesh containing the submesh
  113548. * @param subMesh defines the submesh to bind the material to
  113549. */
  113550. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113551. /**
  113552. * Gets the active textures from the material
  113553. * @returns an array of textures
  113554. */
  113555. getActiveTextures(): BaseTexture[];
  113556. /**
  113557. * Specifies if the material uses a texture
  113558. * @param texture defines the texture to check against the material
  113559. * @returns a boolean specifying if the material uses the texture
  113560. */
  113561. hasTexture(texture: BaseTexture): boolean;
  113562. /**
  113563. * Disposes the material
  113564. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113565. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113566. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113567. */
  113568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113569. /** Creates the node editor window. */
  113570. private _createNodeEditor;
  113571. /**
  113572. * Launch the node material editor
  113573. * @param config Define the configuration of the editor
  113574. * @return a promise fulfilled when the node editor is visible
  113575. */
  113576. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113577. /**
  113578. * Clear the current material
  113579. */
  113580. clear(): void;
  113581. /**
  113582. * Clear the current material and set it to a default state
  113583. */
  113584. setToDefault(): void;
  113585. }
  113586. }
  113587. declare module BABYLON {
  113588. /**
  113589. * Defines a block that can be used inside a node based material
  113590. */
  113591. export class NodeMaterialBlock {
  113592. private _buildId;
  113593. private _target;
  113594. private _isFinalMerger;
  113595. /** @hidden */
  113596. _inputs: NodeMaterialConnectionPoint[];
  113597. /** @hidden */
  113598. _outputs: NodeMaterialConnectionPoint[];
  113599. /**
  113600. * Gets or sets the name of the block
  113601. */
  113602. name: string;
  113603. /**
  113604. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  113605. */
  113606. readonly isFinalMerger: boolean;
  113607. /**
  113608. * Gets or sets the build Id
  113609. */
  113610. buildId: number;
  113611. /**
  113612. * Gets or sets the target of the block
  113613. */
  113614. target: NodeMaterialBlockTargets;
  113615. /**
  113616. * Gets the list of input points
  113617. */
  113618. readonly inputs: NodeMaterialConnectionPoint[];
  113619. /** Gets the list of output points */
  113620. readonly outputs: NodeMaterialConnectionPoint[];
  113621. /**
  113622. * Find an input by its name
  113623. * @param name defines the name of the input to look for
  113624. * @returns the input or null if not found
  113625. */
  113626. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113627. /**
  113628. * Find an output by its name
  113629. * @param name defines the name of the outputto look for
  113630. * @returns the output or null if not found
  113631. */
  113632. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113633. /**
  113634. * Creates a new NodeMaterialBlock
  113635. * @param name defines the block name
  113636. * @param target defines the target of that block (Vertex by default)
  113637. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  113638. */
  113639. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  113640. /**
  113641. * Initialize the block and prepare the context for build
  113642. * @param state defines the state that will be used for the build
  113643. */
  113644. initialize(state: NodeMaterialBuildState): void;
  113645. /**
  113646. * Bind data to effect. Will only be called for blocks with isBindable === true
  113647. * @param effect defines the effect to bind data to
  113648. * @param nodeMaterial defines the hosting NodeMaterial
  113649. * @param mesh defines the mesh that will be rendered
  113650. */
  113651. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113652. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  113653. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  113654. protected _writeFloat(value: number): string;
  113655. /**
  113656. * Gets the current class name e.g. "NodeMaterialBlock"
  113657. * @returns the class name
  113658. */
  113659. getClassName(): string;
  113660. /**
  113661. * Register a new input. Must be called inside a block constructor
  113662. * @param name defines the connection point name
  113663. * @param type defines the connection point type
  113664. * @param isOptional defines a boolean indicating that this input can be omitted
  113665. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113666. * @returns the current block
  113667. */
  113668. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  113669. /**
  113670. * Register a new output. Must be called inside a block constructor
  113671. * @param name defines the connection point name
  113672. * @param type defines the connection point type
  113673. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113674. * @returns the current block
  113675. */
  113676. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  113677. /**
  113678. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  113679. * @param forOutput defines an optional connection point to check compatibility with
  113680. * @returns the first available input or null
  113681. */
  113682. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  113683. /**
  113684. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  113685. * @param forBlock defines an optional block to check compatibility with
  113686. * @returns the first available input or null
  113687. */
  113688. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  113689. /**
  113690. * Connect current block with another block
  113691. * @param other defines the block to connect with
  113692. * @param options define the various options to help pick the right connections
  113693. * @returns the current block
  113694. */
  113695. connectTo(other: NodeMaterialBlock, options?: {
  113696. input?: string;
  113697. output?: string;
  113698. outputSwizzle?: string;
  113699. }): this | undefined;
  113700. protected _buildBlock(state: NodeMaterialBuildState): void;
  113701. /**
  113702. * Add potential fallbacks if shader compilation fails
  113703. * @param mesh defines the mesh to be rendered
  113704. * @param fallbacks defines the current prioritized list of fallbacks
  113705. */
  113706. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113707. /**
  113708. * Update defines for shader compilation
  113709. * @param mesh defines the mesh to be rendered
  113710. * @param nodeMaterial defines the node material requesting the update
  113711. * @param defines defines the material defines to update
  113712. * @param useInstances specifies that instances should be used
  113713. */
  113714. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113715. /**
  113716. * Lets the block try to connect some inputs automatically
  113717. */
  113718. autoConfigure(): void;
  113719. /**
  113720. * Function called when a block is declared as repeatable content generator
  113721. * @param vertexShaderState defines the current compilation state for the vertex shader
  113722. * @param fragmentShaderState defines the current compilation state for the fragment shader
  113723. * @param mesh defines the mesh to be rendered
  113724. * @param defines defines the material defines to update
  113725. */
  113726. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113727. /**
  113728. * Checks if the block is ready
  113729. * @param mesh defines the mesh to be rendered
  113730. * @param nodeMaterial defines the node material requesting the update
  113731. * @param defines defines the material defines to update
  113732. * @param useInstances specifies that instances should be used
  113733. * @returns true if the block is ready
  113734. */
  113735. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  113736. /**
  113737. * Compile the current node and generate the shader code
  113738. * @param state defines the current compilation state (uniforms, samplers, current string)
  113739. * @returns the current block
  113740. */
  113741. build(state: NodeMaterialBuildState): this | undefined;
  113742. }
  113743. }
  113744. declare module BABYLON {
  113745. /**
  113746. * Defines a connection point for a block
  113747. */
  113748. export class NodeMaterialConnectionPoint {
  113749. /** @hidden */
  113750. _ownerBlock: NodeMaterialBlock;
  113751. /** @hidden */
  113752. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113753. private _associatedVariableName;
  113754. private _endpoints;
  113755. private _storedValue;
  113756. private _valueCallback;
  113757. private _mode;
  113758. /** @hidden */
  113759. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113760. /** @hidden */
  113761. _needToEmitVarying: boolean;
  113762. /**
  113763. * Gets or sets the connection point type (default is float)
  113764. */
  113765. type: NodeMaterialBlockConnectionPointTypes;
  113766. /**
  113767. * Gets or sets the connection point name
  113768. */
  113769. name: string;
  113770. /**
  113771. * Gets or sets the swizzle to apply to this connection point when reading or writing
  113772. */
  113773. swizzle: string;
  113774. /**
  113775. * Gets or sets a boolean indicating that this connection point can be omitted
  113776. */
  113777. isOptional: boolean;
  113778. /**
  113779. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  113780. */
  113781. define: string;
  113782. /** Gets or sets the target of that connection point */
  113783. target: NodeMaterialBlockTargets;
  113784. /**
  113785. * Gets or sets the value of that point.
  113786. * Please note that this value will be ignored if valueCallback is defined
  113787. */
  113788. value: any;
  113789. /**
  113790. * Gets or sets a callback used to get the value of that point.
  113791. * Please note that setting this value will force the connection point to ignore the value property
  113792. */
  113793. valueCallback: () => any;
  113794. /**
  113795. * Gets or sets the associated variable name in the shader
  113796. */
  113797. associatedVariableName: string;
  113798. /**
  113799. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  113800. * In this case the connection point name must be the name of the uniform to use.
  113801. * Can only be set on inputs
  113802. */
  113803. isUniform: boolean;
  113804. /**
  113805. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  113806. * In this case the connection point name must be the name of the attribute to use
  113807. * Can only be set on inputs
  113808. */
  113809. isAttribute: boolean;
  113810. /**
  113811. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  113812. * Can only be set on exit points
  113813. */
  113814. isVarying: boolean;
  113815. /** Get the other side of the connection (if any) */
  113816. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113817. /** Get the block that owns this connection point */
  113818. readonly ownerBlock: NodeMaterialBlock;
  113819. /** Get the block connected on the other side of this connection (if any) */
  113820. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  113821. /** Get the block connected on the endpoints of this connection (if any) */
  113822. readonly connectedBlocks: Array<NodeMaterialBlock>;
  113823. /**
  113824. * Creates a new connection point
  113825. * @param name defines the connection point name
  113826. * @param ownerBlock defines the block hosting this connection point
  113827. */
  113828. constructor(name: string, ownerBlock: NodeMaterialBlock);
  113829. /**
  113830. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  113831. * @returns the class name
  113832. */
  113833. getClassName(): string;
  113834. /**
  113835. * Set the source of this connection point to a vertex attribute
  113836. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  113837. * @returns the current connection point
  113838. */
  113839. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  113840. /**
  113841. * Set the source of this connection point to a well known value
  113842. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  113843. * @returns the current connection point
  113844. */
  113845. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  113846. /**
  113847. * Gets a boolean indicating that the current connection point is a well known value
  113848. */
  113849. readonly isWellKnownValue: boolean;
  113850. /**
  113851. * Gets or sets the current well known value or null if not defined as well know value
  113852. */
  113853. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113854. private _getTypeLength;
  113855. /**
  113856. * Connect this point to another connection point
  113857. * @param connectionPoint defines the other connection point
  113858. * @returns the current connection point
  113859. */
  113860. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113861. /**
  113862. * Disconnect this point from one of his endpoint
  113863. * @param endpoint defines the other connection point
  113864. * @returns the current connection point
  113865. */
  113866. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113867. /**
  113868. * When connection point is an uniform, this function will send its value to the effect
  113869. * @param effect defines the effect to transmit value to
  113870. * @param world defines the world matrix
  113871. * @param worldView defines the worldxview matrix
  113872. * @param worldViewProjection defines the worldxviewxprojection matrix
  113873. */
  113874. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  113875. /**
  113876. * When connection point is an uniform, this function will send its value to the effect
  113877. * @param effect defines the effect to transmit value to
  113878. * @param scene defines the hosting scene
  113879. */
  113880. transmit(effect: Effect, scene: Scene): void;
  113881. }
  113882. }
  113883. declare module BABYLON {
  113884. /**
  113885. * Block used to add support for vertex skinning (bones)
  113886. */
  113887. export class BonesBlock extends NodeMaterialBlock {
  113888. /**
  113889. * Creates a new BonesBlock
  113890. * @param name defines the block name
  113891. */
  113892. constructor(name: string);
  113893. /**
  113894. * Initialize the block and prepare the context for build
  113895. * @param state defines the state that will be used for the build
  113896. */
  113897. initialize(state: NodeMaterialBuildState): void;
  113898. /**
  113899. * Gets the current class name
  113900. * @returns the class name
  113901. */
  113902. getClassName(): string;
  113903. /**
  113904. * Gets the matrix indices input component
  113905. */
  113906. readonly matricesIndices: NodeMaterialConnectionPoint;
  113907. /**
  113908. * Gets the matrix weights input component
  113909. */
  113910. readonly matricesWeights: NodeMaterialConnectionPoint;
  113911. /**
  113912. * Gets the extra matrix indices input component
  113913. */
  113914. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  113915. /**
  113916. * Gets the extra matrix weights input component
  113917. */
  113918. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  113919. /**
  113920. * Gets the world input component
  113921. */
  113922. readonly world: NodeMaterialConnectionPoint;
  113923. autoConfigure(): void;
  113924. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113925. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113927. protected _buildBlock(state: NodeMaterialBuildState): this;
  113928. }
  113929. }
  113930. declare module BABYLON {
  113931. /**
  113932. * Block used to add support for instances
  113933. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113934. */
  113935. export class InstancesBlock extends NodeMaterialBlock {
  113936. /**
  113937. * Creates a new InstancesBlock
  113938. * @param name defines the block name
  113939. */
  113940. constructor(name: string);
  113941. /**
  113942. * Gets the current class name
  113943. * @returns the class name
  113944. */
  113945. getClassName(): string;
  113946. /**
  113947. * Gets the first world row input component
  113948. */
  113949. readonly world0: NodeMaterialConnectionPoint;
  113950. /**
  113951. * Gets the second world row input component
  113952. */
  113953. readonly world1: NodeMaterialConnectionPoint;
  113954. /**
  113955. * Gets the third world row input component
  113956. */
  113957. readonly world2: NodeMaterialConnectionPoint;
  113958. /**
  113959. * Gets the forth world row input component
  113960. */
  113961. readonly world3: NodeMaterialConnectionPoint;
  113962. /**
  113963. * Gets the world input component
  113964. */
  113965. readonly world: NodeMaterialConnectionPoint;
  113966. /**
  113967. * Gets the output component
  113968. */
  113969. readonly output: NodeMaterialConnectionPoint;
  113970. autoConfigure(): void;
  113971. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113972. protected _buildBlock(state: NodeMaterialBuildState): this;
  113973. }
  113974. }
  113975. declare module BABYLON {
  113976. /**
  113977. * Block used to add morph targets support to vertex shader
  113978. */
  113979. export class MorphTargetsBlock extends NodeMaterialBlock {
  113980. private _repeatableContentAnchor;
  113981. private _repeatebleContentGenerated;
  113982. /**
  113983. * Create a new MorphTargetsBlock
  113984. * @param name defines the block name
  113985. */
  113986. constructor(name: string);
  113987. /**
  113988. * Gets the current class name
  113989. * @returns the class name
  113990. */
  113991. getClassName(): string;
  113992. /**
  113993. * Gets the position input component
  113994. */
  113995. readonly position: NodeMaterialConnectionPoint;
  113996. /**
  113997. * Gets the normal input component
  113998. */
  113999. readonly normal: NodeMaterialConnectionPoint;
  114000. /**
  114001. * Gets the tangent input component
  114002. */
  114003. readonly tangent: NodeMaterialConnectionPoint;
  114004. /**
  114005. * Gets the position output component
  114006. */
  114007. readonly positionOutput: NodeMaterialConnectionPoint;
  114008. /**
  114009. * Gets the normal output component
  114010. */
  114011. readonly normalOutput: NodeMaterialConnectionPoint;
  114012. /**
  114013. * Gets the tangent output component
  114014. */
  114015. readonly tangentOutput: NodeMaterialConnectionPoint;
  114016. initialize(state: NodeMaterialBuildState): void;
  114017. autoConfigure(): void;
  114018. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114019. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114020. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114021. protected _buildBlock(state: NodeMaterialBuildState): this;
  114022. }
  114023. }
  114024. declare module BABYLON {
  114025. /**
  114026. * Block used to add an alpha test in the fragment shader
  114027. */
  114028. export class AlphaTestBlock extends NodeMaterialBlock {
  114029. /**
  114030. * Gets or sets the alpha value where alpha testing happens
  114031. */
  114032. alphaCutOff: number;
  114033. /**
  114034. * Create a new AlphaTestBlock
  114035. * @param name defines the block name
  114036. */
  114037. constructor(name: string);
  114038. /**
  114039. * Gets the current class name
  114040. * @returns the class name
  114041. */
  114042. getClassName(): string;
  114043. /**
  114044. * Gets the color input component
  114045. */
  114046. readonly color: NodeMaterialConnectionPoint;
  114047. protected _buildBlock(state: NodeMaterialBuildState): this;
  114048. }
  114049. }
  114050. declare module BABYLON {
  114051. /**
  114052. * Block used to create a Color4 out of 4 inputs (one for each component)
  114053. */
  114054. export class RGBAMergerBlock extends NodeMaterialBlock {
  114055. /**
  114056. * Create a new RGBAMergerBlock
  114057. * @param name defines the block name
  114058. */
  114059. constructor(name: string);
  114060. /**
  114061. * Gets the current class name
  114062. * @returns the class name
  114063. */
  114064. getClassName(): string;
  114065. /**
  114066. * Gets the R input component
  114067. */
  114068. readonly r: NodeMaterialConnectionPoint;
  114069. /**
  114070. * Gets the G input component
  114071. */
  114072. readonly g: NodeMaterialConnectionPoint;
  114073. /**
  114074. * Gets the B input component
  114075. */
  114076. readonly b: NodeMaterialConnectionPoint;
  114077. /**
  114078. * Gets the RGB input component
  114079. */
  114080. readonly rgb: NodeMaterialConnectionPoint;
  114081. /**
  114082. * Gets the R input component
  114083. */
  114084. readonly a: NodeMaterialConnectionPoint;
  114085. protected _buildBlock(state: NodeMaterialBuildState): this;
  114086. }
  114087. }
  114088. declare module BABYLON {
  114089. /**
  114090. * Block used to create a Color3 out of 3 inputs (one for each component)
  114091. */
  114092. export class RGBMergerBlock extends NodeMaterialBlock {
  114093. /**
  114094. * Create a new RGBMergerBlock
  114095. * @param name defines the block name
  114096. */
  114097. constructor(name: string);
  114098. /**
  114099. * Gets the current class name
  114100. * @returns the class name
  114101. */
  114102. getClassName(): string;
  114103. /**
  114104. * Gets the R component input
  114105. */
  114106. readonly r: NodeMaterialConnectionPoint;
  114107. /**
  114108. * Gets the G component input
  114109. */
  114110. readonly g: NodeMaterialConnectionPoint;
  114111. /**
  114112. * Gets the B component input
  114113. */
  114114. readonly b: NodeMaterialConnectionPoint;
  114115. protected _buildBlock(state: NodeMaterialBuildState): this;
  114116. }
  114117. }
  114118. declare module BABYLON {
  114119. /**
  114120. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114121. */
  114122. export class RGBASplitterBlock extends NodeMaterialBlock {
  114123. /**
  114124. * Create a new RGBASplitterBlock
  114125. * @param name defines the block name
  114126. */
  114127. constructor(name: string);
  114128. /**
  114129. * Gets the current class name
  114130. * @returns the class name
  114131. */
  114132. getClassName(): string;
  114133. /**
  114134. * Gets the input component
  114135. */
  114136. readonly input: NodeMaterialConnectionPoint;
  114137. protected _buildBlock(state: NodeMaterialBuildState): this;
  114138. }
  114139. }
  114140. declare module BABYLON {
  114141. /**
  114142. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114143. */
  114144. export class RGBSplitterBlock extends NodeMaterialBlock {
  114145. /**
  114146. * Create a new RGBSplitterBlock
  114147. * @param name defines the block name
  114148. */
  114149. constructor(name: string);
  114150. /**
  114151. * Gets the current class name
  114152. * @returns the class name
  114153. */
  114154. getClassName(): string;
  114155. /**
  114156. * Gets the input component
  114157. */
  114158. readonly input: NodeMaterialConnectionPoint;
  114159. protected _buildBlock(state: NodeMaterialBuildState): this;
  114160. }
  114161. }
  114162. declare module BABYLON {
  114163. /**
  114164. * Block used to read a texture from a sampler
  114165. */
  114166. export class TextureBlock extends NodeMaterialBlock {
  114167. private _defineName;
  114168. /**
  114169. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114170. */
  114171. autoConnectTextureMatrix: boolean;
  114172. /**
  114173. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114174. */
  114175. autoSelectUV: boolean;
  114176. /**
  114177. * Create a new TextureBlock
  114178. * @param name defines the block name
  114179. */
  114180. constructor(name: string);
  114181. /**
  114182. * Gets the current class name
  114183. * @returns the class name
  114184. */
  114185. getClassName(): string;
  114186. /**
  114187. * Gets the uv input component
  114188. */
  114189. readonly uv: NodeMaterialConnectionPoint;
  114190. /**
  114191. * Gets the texture information input component
  114192. */
  114193. readonly textureInfo: NodeMaterialConnectionPoint;
  114194. /**
  114195. * Gets the transformed uv input component
  114196. */
  114197. readonly transformedUV: NodeMaterialConnectionPoint;
  114198. /**
  114199. * Gets the texture input component
  114200. */
  114201. readonly texture: NodeMaterialConnectionPoint;
  114202. /**
  114203. * Gets the texture transform input component
  114204. */
  114205. readonly textureTransform: NodeMaterialConnectionPoint;
  114206. autoConfigure(): void;
  114207. initialize(state: NodeMaterialBuildState): void;
  114208. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114209. isReady(): boolean;
  114210. private _injectVertexCode;
  114211. protected _buildBlock(state: NodeMaterialBuildState): this;
  114212. }
  114213. }
  114214. declare module BABYLON {
  114215. /**
  114216. * Block used to add image processing support to fragment shader
  114217. */
  114218. export class ImageProcessingBlock extends NodeMaterialBlock {
  114219. /**
  114220. * Create a new ImageProcessingBlock
  114221. * @param name defines the block name
  114222. */
  114223. constructor(name: string);
  114224. /**
  114225. * Gets the current class name
  114226. * @returns the class name
  114227. */
  114228. getClassName(): string;
  114229. /**
  114230. * Gets the color input component
  114231. */
  114232. readonly color: NodeMaterialConnectionPoint;
  114233. /**
  114234. * Initialize the block and prepare the context for build
  114235. * @param state defines the state that will be used for the build
  114236. */
  114237. initialize(state: NodeMaterialBuildState): void;
  114238. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114240. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114241. protected _buildBlock(state: NodeMaterialBuildState): this;
  114242. }
  114243. }
  114244. declare module BABYLON {
  114245. /**
  114246. * Block used to add support for scene fog
  114247. */
  114248. export class FogBlock extends NodeMaterialBlock {
  114249. /**
  114250. * Create a new FogBlock
  114251. * @param name defines the block name
  114252. */
  114253. constructor(name: string);
  114254. /**
  114255. * Gets the current class name
  114256. * @returns the class name
  114257. */
  114258. getClassName(): string;
  114259. /**
  114260. * Gets the world position input component
  114261. */
  114262. readonly worldPosition: NodeMaterialConnectionPoint;
  114263. /**
  114264. * Gets the view input component
  114265. */
  114266. readonly view: NodeMaterialConnectionPoint;
  114267. /**
  114268. * Gets the color input component
  114269. */
  114270. readonly color: NodeMaterialConnectionPoint;
  114271. /**
  114272. * Gets the fog color input component
  114273. */
  114274. readonly fogColor: NodeMaterialConnectionPoint;
  114275. /**
  114276. * Gets the for parameter input component
  114277. */
  114278. readonly fogParameters: NodeMaterialConnectionPoint;
  114279. autoConfigure(): void;
  114280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114281. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114282. protected _buildBlock(state: NodeMaterialBuildState): this;
  114283. }
  114284. }
  114285. declare module BABYLON {
  114286. /**
  114287. * Block used to multiply 2 vector4
  114288. */
  114289. export class MultiplyBlock extends NodeMaterialBlock {
  114290. /**
  114291. * Creates a new MultiplyBlock
  114292. * @param name defines the block name
  114293. */
  114294. constructor(name: string);
  114295. /**
  114296. * Gets the current class name
  114297. * @returns the class name
  114298. */
  114299. getClassName(): string;
  114300. /**
  114301. * Gets the left operand input component
  114302. */
  114303. readonly left: NodeMaterialConnectionPoint;
  114304. /**
  114305. * Gets the right operand input component
  114306. */
  114307. readonly right: NodeMaterialConnectionPoint;
  114308. protected _buildBlock(state: NodeMaterialBuildState): this;
  114309. }
  114310. }
  114311. declare module BABYLON {
  114312. /**
  114313. * Block used to add 2 vector4
  114314. */
  114315. export class AddBlock extends NodeMaterialBlock {
  114316. /**
  114317. * Creates a new AddBlock
  114318. * @param name defines the block name
  114319. */
  114320. constructor(name: string);
  114321. /**
  114322. * Gets the current class name
  114323. * @returns the class name
  114324. */
  114325. getClassName(): string;
  114326. /**
  114327. * Gets the left operand input component
  114328. */
  114329. readonly left: NodeMaterialConnectionPoint;
  114330. /**
  114331. * Gets the right operand input component
  114332. */
  114333. readonly right: NodeMaterialConnectionPoint;
  114334. protected _buildBlock(state: NodeMaterialBuildState): this;
  114335. }
  114336. }
  114337. declare module BABYLON {
  114338. /**
  114339. * Block used to clamp a float
  114340. */
  114341. export class ClampBlock extends NodeMaterialBlock {
  114342. /** Gets or sets the minimum range */
  114343. minimum: number;
  114344. /** Gets or sets the maximum range */
  114345. maximum: number;
  114346. /**
  114347. * Creates a new ClampBlock
  114348. * @param name defines the block name
  114349. */
  114350. constructor(name: string);
  114351. /**
  114352. * Gets the current class name
  114353. * @returns the class name
  114354. */
  114355. getClassName(): string;
  114356. /**
  114357. * Gets the value input component
  114358. */
  114359. readonly value: NodeMaterialConnectionPoint;
  114360. protected _buildBlock(state: NodeMaterialBuildState): this;
  114361. }
  114362. }
  114363. declare module BABYLON {
  114364. /**
  114365. * Block used to transform a vector2 with a matrix
  114366. */
  114367. export class Vector2TransformBlock extends NodeMaterialBlock {
  114368. /**
  114369. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114370. */
  114371. complementZ: number;
  114372. /**
  114373. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114374. */
  114375. complementW: number;
  114376. /**
  114377. * Creates a new Vector2TransformBlock
  114378. * @param name defines the block name
  114379. */
  114380. constructor(name: string);
  114381. /**
  114382. * Gets the vector input
  114383. */
  114384. readonly vector: NodeMaterialConnectionPoint;
  114385. /**
  114386. * Gets the matrix transform input
  114387. */
  114388. readonly transform: NodeMaterialConnectionPoint;
  114389. /**
  114390. * Gets the current class name
  114391. * @returns the class name
  114392. */
  114393. getClassName(): string;
  114394. protected _buildBlock(state: NodeMaterialBuildState): this;
  114395. }
  114396. }
  114397. declare module BABYLON {
  114398. /**
  114399. * Block used to transform a vector3 with a matrix
  114400. */
  114401. export class Vector3TransformBlock extends NodeMaterialBlock {
  114402. /**
  114403. * Defines the value to use to complement Vector3 to transform it to a Vector4
  114404. */
  114405. complement: number;
  114406. /**
  114407. * Creates a new Vector3TransformBlock
  114408. * @param name defines the block name
  114409. */
  114410. constructor(name: string);
  114411. /**
  114412. * Gets the vector input
  114413. */
  114414. readonly vector: NodeMaterialConnectionPoint;
  114415. /**
  114416. * Gets the matrix transform input
  114417. */
  114418. readonly transform: NodeMaterialConnectionPoint;
  114419. /**
  114420. * Gets the current class name
  114421. * @returns the class name
  114422. */
  114423. getClassName(): string;
  114424. protected _buildBlock(state: NodeMaterialBuildState): this;
  114425. }
  114426. }
  114427. declare module BABYLON {
  114428. /**
  114429. * Block used to multiply two matrices
  114430. */
  114431. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  114432. /**
  114433. * Creates a new MatrixMultiplicationBlock
  114434. * @param name defines the block name
  114435. */
  114436. constructor(name: string);
  114437. /**
  114438. * Gets the left operand
  114439. */
  114440. readonly left: NodeMaterialConnectionPoint;
  114441. /**
  114442. * Gets the right operand
  114443. */
  114444. readonly right: NodeMaterialConnectionPoint;
  114445. /**
  114446. * Gets the current class name
  114447. * @returns the class name
  114448. */
  114449. getClassName(): string;
  114450. protected _buildBlock(state: NodeMaterialBuildState): this;
  114451. }
  114452. }
  114453. declare module BABYLON {
  114454. /**
  114455. * Helper class to push actions to a pool of workers.
  114456. */
  114457. export class WorkerPool implements IDisposable {
  114458. private _workerInfos;
  114459. private _pendingActions;
  114460. /**
  114461. * Constructor
  114462. * @param workers Array of workers to use for actions
  114463. */
  114464. constructor(workers: Array<Worker>);
  114465. /**
  114466. * Terminates all workers and clears any pending actions.
  114467. */
  114468. dispose(): void;
  114469. /**
  114470. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114471. * pended until a worker has completed its action.
  114472. * @param action The action to perform. Call onComplete when the action is complete.
  114473. */
  114474. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114475. private _execute;
  114476. }
  114477. }
  114478. declare module BABYLON {
  114479. /**
  114480. * Configuration for Draco compression
  114481. */
  114482. export interface IDracoCompressionConfiguration {
  114483. /**
  114484. * Configuration for the decoder.
  114485. */
  114486. decoder: {
  114487. /**
  114488. * The url to the WebAssembly module.
  114489. */
  114490. wasmUrl?: string;
  114491. /**
  114492. * The url to the WebAssembly binary.
  114493. */
  114494. wasmBinaryUrl?: string;
  114495. /**
  114496. * The url to the fallback JavaScript module.
  114497. */
  114498. fallbackUrl?: string;
  114499. };
  114500. }
  114501. /**
  114502. * Draco compression (https://google.github.io/draco/)
  114503. *
  114504. * This class wraps the Draco module.
  114505. *
  114506. * **Encoder**
  114507. *
  114508. * The encoder is not currently implemented.
  114509. *
  114510. * **Decoder**
  114511. *
  114512. * 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.
  114513. *
  114514. * To update the configuration, use the following code:
  114515. * ```javascript
  114516. * DracoCompression.Configuration = {
  114517. * decoder: {
  114518. * wasmUrl: "<url to the WebAssembly library>",
  114519. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  114520. * fallbackUrl: "<url to the fallback JavaScript library>",
  114521. * }
  114522. * };
  114523. * ```
  114524. *
  114525. * 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.
  114526. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  114527. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  114528. *
  114529. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  114530. * ```javascript
  114531. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  114532. * ```
  114533. *
  114534. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  114535. */
  114536. export class DracoCompression implements IDisposable {
  114537. private _workerPoolPromise?;
  114538. private _decoderModulePromise?;
  114539. /**
  114540. * The configuration. Defaults to the following urls:
  114541. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  114542. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  114543. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  114544. */
  114545. static Configuration: IDracoCompressionConfiguration;
  114546. /**
  114547. * Returns true if the decoder configuration is available.
  114548. */
  114549. static readonly DecoderAvailable: boolean;
  114550. /**
  114551. * Default number of workers to create when creating the draco compression object.
  114552. */
  114553. static DefaultNumWorkers: number;
  114554. private static GetDefaultNumWorkers;
  114555. private static _Default;
  114556. /**
  114557. * Default instance for the draco compression object.
  114558. */
  114559. static readonly Default: DracoCompression;
  114560. /**
  114561. * Constructor
  114562. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  114563. */
  114564. constructor(numWorkers?: number);
  114565. /**
  114566. * Stop all async operations and release resources.
  114567. */
  114568. dispose(): void;
  114569. /**
  114570. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  114571. * @returns a promise that resolves when ready
  114572. */
  114573. whenReadyAsync(): Promise<void>;
  114574. /**
  114575. * Decode Draco compressed mesh data to vertex data.
  114576. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  114577. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  114578. * @returns A promise that resolves with the decoded vertex data
  114579. */
  114580. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  114581. [kind: string]: number;
  114582. }): Promise<VertexData>;
  114583. }
  114584. }
  114585. declare module BABYLON {
  114586. /**
  114587. * Class for building Constructive Solid Geometry
  114588. */
  114589. export class CSG {
  114590. private polygons;
  114591. /**
  114592. * The world matrix
  114593. */
  114594. matrix: Matrix;
  114595. /**
  114596. * Stores the position
  114597. */
  114598. position: Vector3;
  114599. /**
  114600. * Stores the rotation
  114601. */
  114602. rotation: Vector3;
  114603. /**
  114604. * Stores the rotation quaternion
  114605. */
  114606. rotationQuaternion: Nullable<Quaternion>;
  114607. /**
  114608. * Stores the scaling vector
  114609. */
  114610. scaling: Vector3;
  114611. /**
  114612. * Convert the Mesh to CSG
  114613. * @param mesh The Mesh to convert to CSG
  114614. * @returns A new CSG from the Mesh
  114615. */
  114616. static FromMesh(mesh: Mesh): CSG;
  114617. /**
  114618. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  114619. * @param polygons Polygons used to construct a CSG solid
  114620. */
  114621. private static FromPolygons;
  114622. /**
  114623. * Clones, or makes a deep copy, of the CSG
  114624. * @returns A new CSG
  114625. */
  114626. clone(): CSG;
  114627. /**
  114628. * Unions this CSG with another CSG
  114629. * @param csg The CSG to union against this CSG
  114630. * @returns The unioned CSG
  114631. */
  114632. union(csg: CSG): CSG;
  114633. /**
  114634. * Unions this CSG with another CSG in place
  114635. * @param csg The CSG to union against this CSG
  114636. */
  114637. unionInPlace(csg: CSG): void;
  114638. /**
  114639. * Subtracts this CSG with another CSG
  114640. * @param csg The CSG to subtract against this CSG
  114641. * @returns A new CSG
  114642. */
  114643. subtract(csg: CSG): CSG;
  114644. /**
  114645. * Subtracts this CSG with another CSG in place
  114646. * @param csg The CSG to subtact against this CSG
  114647. */
  114648. subtractInPlace(csg: CSG): void;
  114649. /**
  114650. * Intersect this CSG with another CSG
  114651. * @param csg The CSG to intersect against this CSG
  114652. * @returns A new CSG
  114653. */
  114654. intersect(csg: CSG): CSG;
  114655. /**
  114656. * Intersects this CSG with another CSG in place
  114657. * @param csg The CSG to intersect against this CSG
  114658. */
  114659. intersectInPlace(csg: CSG): void;
  114660. /**
  114661. * Return a new CSG solid with solid and empty space switched. This solid is
  114662. * not modified.
  114663. * @returns A new CSG solid with solid and empty space switched
  114664. */
  114665. inverse(): CSG;
  114666. /**
  114667. * Inverses the CSG in place
  114668. */
  114669. inverseInPlace(): void;
  114670. /**
  114671. * This is used to keep meshes transformations so they can be restored
  114672. * when we build back a Babylon Mesh
  114673. * NB : All CSG operations are performed in world coordinates
  114674. * @param csg The CSG to copy the transform attributes from
  114675. * @returns This CSG
  114676. */
  114677. copyTransformAttributes(csg: CSG): CSG;
  114678. /**
  114679. * Build Raw mesh from CSG
  114680. * Coordinates here are in world space
  114681. * @param name The name of the mesh geometry
  114682. * @param scene The Scene
  114683. * @param keepSubMeshes Specifies if the submeshes should be kept
  114684. * @returns A new Mesh
  114685. */
  114686. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  114687. /**
  114688. * Build Mesh from CSG taking material and transforms into account
  114689. * @param name The name of the Mesh
  114690. * @param material The material of the Mesh
  114691. * @param scene The Scene
  114692. * @param keepSubMeshes Specifies if submeshes should be kept
  114693. * @returns The new Mesh
  114694. */
  114695. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  114696. }
  114697. }
  114698. declare module BABYLON {
  114699. /**
  114700. * Class used to create a trail following a mesh
  114701. */
  114702. export class TrailMesh extends Mesh {
  114703. private _generator;
  114704. private _autoStart;
  114705. private _running;
  114706. private _diameter;
  114707. private _length;
  114708. private _sectionPolygonPointsCount;
  114709. private _sectionVectors;
  114710. private _sectionNormalVectors;
  114711. private _beforeRenderObserver;
  114712. /**
  114713. * @constructor
  114714. * @param name The value used by scene.getMeshByName() to do a lookup.
  114715. * @param generator The mesh to generate a trail.
  114716. * @param scene The scene to add this mesh to.
  114717. * @param diameter Diameter of trailing mesh. Default is 1.
  114718. * @param length Length of trailing mesh. Default is 60.
  114719. * @param autoStart Automatically start trailing mesh. Default true.
  114720. */
  114721. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  114722. /**
  114723. * "TrailMesh"
  114724. * @returns "TrailMesh"
  114725. */
  114726. getClassName(): string;
  114727. private _createMesh;
  114728. /**
  114729. * Start trailing mesh.
  114730. */
  114731. start(): void;
  114732. /**
  114733. * Stop trailing mesh.
  114734. */
  114735. stop(): void;
  114736. /**
  114737. * Update trailing mesh geometry.
  114738. */
  114739. update(): void;
  114740. /**
  114741. * Returns a new TrailMesh object.
  114742. * @param name is a string, the name given to the new mesh
  114743. * @param newGenerator use new generator object for cloned trail mesh
  114744. * @returns a new mesh
  114745. */
  114746. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  114747. /**
  114748. * Serializes this trail mesh
  114749. * @param serializationObject object to write serialization to
  114750. */
  114751. serialize(serializationObject: any): void;
  114752. /**
  114753. * Parses a serialized trail mesh
  114754. * @param parsedMesh the serialized mesh
  114755. * @param scene the scene to create the trail mesh in
  114756. * @returns the created trail mesh
  114757. */
  114758. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  114759. }
  114760. }
  114761. declare module BABYLON {
  114762. /**
  114763. * Class containing static functions to help procedurally build meshes
  114764. */
  114765. export class TiledBoxBuilder {
  114766. /**
  114767. * Creates a box mesh
  114768. * 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)
  114769. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114773. * @param name defines the name of the mesh
  114774. * @param options defines the options used to create the mesh
  114775. * @param scene defines the hosting scene
  114776. * @returns the box mesh
  114777. */
  114778. static CreateTiledBox(name: string, options: {
  114779. pattern?: number;
  114780. width?: number;
  114781. height?: number;
  114782. depth?: number;
  114783. tileSize?: number;
  114784. tileWidth?: number;
  114785. tileHeight?: number;
  114786. alignHorizontal?: number;
  114787. alignVertical?: number;
  114788. faceUV?: Vector4[];
  114789. faceColors?: Color4[];
  114790. sideOrientation?: number;
  114791. updatable?: boolean;
  114792. }, scene?: Nullable<Scene>): Mesh;
  114793. }
  114794. }
  114795. declare module BABYLON {
  114796. /**
  114797. * Class containing static functions to help procedurally build meshes
  114798. */
  114799. export class TorusKnotBuilder {
  114800. /**
  114801. * Creates a torus knot mesh
  114802. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  114803. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  114804. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  114805. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  114806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114809. * @param name defines the name of the mesh
  114810. * @param options defines the options used to create the mesh
  114811. * @param scene defines the hosting scene
  114812. * @returns the torus knot mesh
  114813. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  114814. */
  114815. static CreateTorusKnot(name: string, options: {
  114816. radius?: number;
  114817. tube?: number;
  114818. radialSegments?: number;
  114819. tubularSegments?: number;
  114820. p?: number;
  114821. q?: number;
  114822. updatable?: boolean;
  114823. sideOrientation?: number;
  114824. frontUVs?: Vector4;
  114825. backUVs?: Vector4;
  114826. }, scene: any): Mesh;
  114827. }
  114828. }
  114829. declare module BABYLON {
  114830. /**
  114831. * Polygon
  114832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114833. */
  114834. export class Polygon {
  114835. /**
  114836. * Creates a rectangle
  114837. * @param xmin bottom X coord
  114838. * @param ymin bottom Y coord
  114839. * @param xmax top X coord
  114840. * @param ymax top Y coord
  114841. * @returns points that make the resulting rectation
  114842. */
  114843. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  114844. /**
  114845. * Creates a circle
  114846. * @param radius radius of circle
  114847. * @param cx scale in x
  114848. * @param cy scale in y
  114849. * @param numberOfSides number of sides that make up the circle
  114850. * @returns points that make the resulting circle
  114851. */
  114852. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  114853. /**
  114854. * Creates a polygon from input string
  114855. * @param input Input polygon data
  114856. * @returns the parsed points
  114857. */
  114858. static Parse(input: string): Vector2[];
  114859. /**
  114860. * Starts building a polygon from x and y coordinates
  114861. * @param x x coordinate
  114862. * @param y y coordinate
  114863. * @returns the started path2
  114864. */
  114865. static StartingAt(x: number, y: number): Path2;
  114866. }
  114867. /**
  114868. * Builds a polygon
  114869. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  114870. */
  114871. export class PolygonMeshBuilder {
  114872. private _points;
  114873. private _outlinepoints;
  114874. private _holes;
  114875. private _name;
  114876. private _scene;
  114877. private _epoints;
  114878. private _eholes;
  114879. private _addToepoint;
  114880. /**
  114881. * Babylon reference to the earcut plugin.
  114882. */
  114883. bjsEarcut: any;
  114884. /**
  114885. * Creates a PolygonMeshBuilder
  114886. * @param name name of the builder
  114887. * @param contours Path of the polygon
  114888. * @param scene scene to add to when creating the mesh
  114889. * @param earcutInjection can be used to inject your own earcut reference
  114890. */
  114891. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  114892. /**
  114893. * Adds a whole within the polygon
  114894. * @param hole Array of points defining the hole
  114895. * @returns this
  114896. */
  114897. addHole(hole: Vector2[]): PolygonMeshBuilder;
  114898. /**
  114899. * Creates the polygon
  114900. * @param updatable If the mesh should be updatable
  114901. * @param depth The depth of the mesh created
  114902. * @returns the created mesh
  114903. */
  114904. build(updatable?: boolean, depth?: number): Mesh;
  114905. /**
  114906. * Creates the polygon
  114907. * @param depth The depth of the mesh created
  114908. * @returns the created VertexData
  114909. */
  114910. buildVertexData(depth?: number): VertexData;
  114911. /**
  114912. * Adds a side to the polygon
  114913. * @param positions points that make the polygon
  114914. * @param normals normals of the polygon
  114915. * @param uvs uvs of the polygon
  114916. * @param indices indices of the polygon
  114917. * @param bounds bounds of the polygon
  114918. * @param points points of the polygon
  114919. * @param depth depth of the polygon
  114920. * @param flip flip of the polygon
  114921. */
  114922. private addSide;
  114923. }
  114924. }
  114925. declare module BABYLON {
  114926. /**
  114927. * Class containing static functions to help procedurally build meshes
  114928. */
  114929. export class PolygonBuilder {
  114930. /**
  114931. * Creates a polygon mesh
  114932. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  114933. * * 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
  114934. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  114937. * * Remember you can only change the shape positions, not their number when updating a polygon
  114938. * @param name defines the name of the mesh
  114939. * @param options defines the options used to create the mesh
  114940. * @param scene defines the hosting scene
  114941. * @param earcutInjection can be used to inject your own earcut reference
  114942. * @returns the polygon mesh
  114943. */
  114944. static CreatePolygon(name: string, options: {
  114945. shape: Vector3[];
  114946. holes?: Vector3[][];
  114947. depth?: number;
  114948. faceUV?: Vector4[];
  114949. faceColors?: Color4[];
  114950. updatable?: boolean;
  114951. sideOrientation?: number;
  114952. frontUVs?: Vector4;
  114953. backUVs?: Vector4;
  114954. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114955. /**
  114956. * Creates an extruded polygon mesh, with depth in the Y direction.
  114957. * * 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)
  114958. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114959. * @param name defines the name of the mesh
  114960. * @param options defines the options used to create the mesh
  114961. * @param scene defines the hosting scene
  114962. * @param earcutInjection can be used to inject your own earcut reference
  114963. * @returns the polygon mesh
  114964. */
  114965. static ExtrudePolygon(name: string, options: {
  114966. shape: Vector3[];
  114967. holes?: Vector3[][];
  114968. depth?: number;
  114969. faceUV?: Vector4[];
  114970. faceColors?: Color4[];
  114971. updatable?: boolean;
  114972. sideOrientation?: number;
  114973. frontUVs?: Vector4;
  114974. backUVs?: Vector4;
  114975. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114976. }
  114977. }
  114978. declare module BABYLON {
  114979. /**
  114980. * Class containing static functions to help procedurally build meshes
  114981. */
  114982. export class LatheBuilder {
  114983. /**
  114984. * Creates lathe mesh.
  114985. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  114986. * * 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
  114987. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  114988. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  114989. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  114990. * * 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
  114991. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  114992. * * 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
  114993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114997. * @param name defines the name of the mesh
  114998. * @param options defines the options used to create the mesh
  114999. * @param scene defines the hosting scene
  115000. * @returns the lathe mesh
  115001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115002. */
  115003. static CreateLathe(name: string, options: {
  115004. shape: Vector3[];
  115005. radius?: number;
  115006. tessellation?: number;
  115007. clip?: number;
  115008. arc?: number;
  115009. closed?: boolean;
  115010. updatable?: boolean;
  115011. sideOrientation?: number;
  115012. frontUVs?: Vector4;
  115013. backUVs?: Vector4;
  115014. cap?: number;
  115015. invertUV?: boolean;
  115016. }, scene?: Nullable<Scene>): Mesh;
  115017. }
  115018. }
  115019. declare module BABYLON {
  115020. /**
  115021. * Class containing static functions to help procedurally build meshes
  115022. */
  115023. export class TiledPlaneBuilder {
  115024. /**
  115025. * Creates a tiled plane mesh
  115026. * * The parameter `pattern` will, depending on value, do nothing or
  115027. * * * flip (reflect about central vertical) alternate tiles across and up
  115028. * * * flip every tile on alternate rows
  115029. * * * rotate (180 degs) alternate tiles across and up
  115030. * * * rotate every tile on alternate rows
  115031. * * * flip and rotate alternate tiles across and up
  115032. * * * flip and rotate every tile on alternate rows
  115033. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115034. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115036. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115037. * * 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)
  115038. * * 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)
  115039. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115040. * @param name defines the name of the mesh
  115041. * @param options defines the options used to create the mesh
  115042. * @param scene defines the hosting scene
  115043. * @returns the box mesh
  115044. */
  115045. static CreateTiledPlane(name: string, options: {
  115046. pattern?: number;
  115047. tileSize?: number;
  115048. tileWidth?: number;
  115049. tileHeight?: number;
  115050. size?: number;
  115051. width?: number;
  115052. height?: number;
  115053. alignHorizontal?: number;
  115054. alignVertical?: number;
  115055. sideOrientation?: number;
  115056. frontUVs?: Vector4;
  115057. backUVs?: Vector4;
  115058. updatable?: boolean;
  115059. }, scene?: Nullable<Scene>): Mesh;
  115060. }
  115061. }
  115062. declare module BABYLON {
  115063. /**
  115064. * Class containing static functions to help procedurally build meshes
  115065. */
  115066. export class TubeBuilder {
  115067. /**
  115068. * Creates a tube mesh.
  115069. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115070. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115071. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115072. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115073. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115074. * * 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)
  115075. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115076. * * 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
  115077. * * 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
  115078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115082. * @param name defines the name of the mesh
  115083. * @param options defines the options used to create the mesh
  115084. * @param scene defines the hosting scene
  115085. * @returns the tube mesh
  115086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115087. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115088. */
  115089. static CreateTube(name: string, options: {
  115090. path: Vector3[];
  115091. radius?: number;
  115092. tessellation?: number;
  115093. radiusFunction?: {
  115094. (i: number, distance: number): number;
  115095. };
  115096. cap?: number;
  115097. arc?: number;
  115098. updatable?: boolean;
  115099. sideOrientation?: number;
  115100. frontUVs?: Vector4;
  115101. backUVs?: Vector4;
  115102. instance?: Mesh;
  115103. invertUV?: boolean;
  115104. }, scene?: Nullable<Scene>): Mesh;
  115105. }
  115106. }
  115107. declare module BABYLON {
  115108. /**
  115109. * Class containing static functions to help procedurally build meshes
  115110. */
  115111. export class IcoSphereBuilder {
  115112. /**
  115113. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115114. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115115. * * 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`)
  115116. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115117. * * 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
  115118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115121. * @param name defines the name of the mesh
  115122. * @param options defines the options used to create the mesh
  115123. * @param scene defines the hosting scene
  115124. * @returns the icosahedron mesh
  115125. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115126. */
  115127. static CreateIcoSphere(name: string, options: {
  115128. radius?: number;
  115129. radiusX?: number;
  115130. radiusY?: number;
  115131. radiusZ?: number;
  115132. flat?: boolean;
  115133. subdivisions?: number;
  115134. sideOrientation?: number;
  115135. frontUVs?: Vector4;
  115136. backUVs?: Vector4;
  115137. updatable?: boolean;
  115138. }, scene?: Nullable<Scene>): Mesh;
  115139. }
  115140. }
  115141. declare module BABYLON {
  115142. /**
  115143. * Class containing static functions to help procedurally build meshes
  115144. */
  115145. export class DecalBuilder {
  115146. /**
  115147. * Creates a decal mesh.
  115148. * 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
  115149. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115150. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115151. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115152. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115153. * @param name defines the name of the mesh
  115154. * @param sourceMesh defines the mesh where the decal must be applied
  115155. * @param options defines the options used to create the mesh
  115156. * @param scene defines the hosting scene
  115157. * @returns the decal mesh
  115158. * @see https://doc.babylonjs.com/how_to/decals
  115159. */
  115160. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115161. position?: Vector3;
  115162. normal?: Vector3;
  115163. size?: Vector3;
  115164. angle?: number;
  115165. }): Mesh;
  115166. }
  115167. }
  115168. declare module BABYLON {
  115169. /**
  115170. * Class containing static functions to help procedurally build meshes
  115171. */
  115172. export class MeshBuilder {
  115173. /**
  115174. * Creates a box mesh
  115175. * * The parameter `size` sets the size (float) of each box side (default 1)
  115176. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115177. * * 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)
  115178. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115182. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115183. * @param name defines the name of the mesh
  115184. * @param options defines the options used to create the mesh
  115185. * @param scene defines the hosting scene
  115186. * @returns the box mesh
  115187. */
  115188. static CreateBox(name: string, options: {
  115189. size?: number;
  115190. width?: number;
  115191. height?: number;
  115192. depth?: number;
  115193. faceUV?: Vector4[];
  115194. faceColors?: Color4[];
  115195. sideOrientation?: number;
  115196. frontUVs?: Vector4;
  115197. backUVs?: Vector4;
  115198. updatable?: boolean;
  115199. }, scene?: Nullable<Scene>): Mesh;
  115200. /**
  115201. * Creates a tiled box mesh
  115202. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115204. * @param name defines the name of the mesh
  115205. * @param options defines the options used to create the mesh
  115206. * @param scene defines the hosting scene
  115207. * @returns the tiled box mesh
  115208. */
  115209. static CreateTiledBox(name: string, options: {
  115210. pattern?: number;
  115211. size?: number;
  115212. width?: number;
  115213. height?: number;
  115214. depth: number;
  115215. tileSize?: number;
  115216. tileWidth?: number;
  115217. tileHeight?: number;
  115218. faceUV?: Vector4[];
  115219. faceColors?: Color4[];
  115220. alignHorizontal?: number;
  115221. alignVertical?: number;
  115222. sideOrientation?: number;
  115223. updatable?: boolean;
  115224. }, scene?: Nullable<Scene>): Mesh;
  115225. /**
  115226. * Creates a sphere mesh
  115227. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115228. * * 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`)
  115229. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115230. * * 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
  115231. * * 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)
  115232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115235. * @param name defines the name of the mesh
  115236. * @param options defines the options used to create the mesh
  115237. * @param scene defines the hosting scene
  115238. * @returns the sphere mesh
  115239. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115240. */
  115241. static CreateSphere(name: string, options: {
  115242. segments?: number;
  115243. diameter?: number;
  115244. diameterX?: number;
  115245. diameterY?: number;
  115246. diameterZ?: number;
  115247. arc?: number;
  115248. slice?: number;
  115249. sideOrientation?: number;
  115250. frontUVs?: Vector4;
  115251. backUVs?: Vector4;
  115252. updatable?: boolean;
  115253. }, scene?: Nullable<Scene>): Mesh;
  115254. /**
  115255. * Creates a plane polygonal mesh. By default, this is a disc
  115256. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115257. * * 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
  115258. * * 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
  115259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115262. * @param name defines the name of the mesh
  115263. * @param options defines the options used to create the mesh
  115264. * @param scene defines the hosting scene
  115265. * @returns the plane polygonal mesh
  115266. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115267. */
  115268. static CreateDisc(name: string, options: {
  115269. radius?: number;
  115270. tessellation?: number;
  115271. arc?: number;
  115272. updatable?: boolean;
  115273. sideOrientation?: number;
  115274. frontUVs?: Vector4;
  115275. backUVs?: Vector4;
  115276. }, scene?: Nullable<Scene>): Mesh;
  115277. /**
  115278. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115279. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115280. * * 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`)
  115281. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115282. * * 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
  115283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115286. * @param name defines the name of the mesh
  115287. * @param options defines the options used to create the mesh
  115288. * @param scene defines the hosting scene
  115289. * @returns the icosahedron mesh
  115290. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115291. */
  115292. static CreateIcoSphere(name: string, options: {
  115293. radius?: number;
  115294. radiusX?: number;
  115295. radiusY?: number;
  115296. radiusZ?: number;
  115297. flat?: boolean;
  115298. subdivisions?: number;
  115299. sideOrientation?: number;
  115300. frontUVs?: Vector4;
  115301. backUVs?: Vector4;
  115302. updatable?: boolean;
  115303. }, scene?: Nullable<Scene>): Mesh;
  115304. /**
  115305. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115306. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115307. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115308. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115309. * * 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
  115310. * * 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
  115311. * * 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
  115312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115314. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115315. * * 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
  115316. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115317. * * 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
  115318. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115320. * @param name defines the name of the mesh
  115321. * @param options defines the options used to create the mesh
  115322. * @param scene defines the hosting scene
  115323. * @returns the ribbon mesh
  115324. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115326. */
  115327. static CreateRibbon(name: string, options: {
  115328. pathArray: Vector3[][];
  115329. closeArray?: boolean;
  115330. closePath?: boolean;
  115331. offset?: number;
  115332. updatable?: boolean;
  115333. sideOrientation?: number;
  115334. frontUVs?: Vector4;
  115335. backUVs?: Vector4;
  115336. instance?: Mesh;
  115337. invertUV?: boolean;
  115338. uvs?: Vector2[];
  115339. colors?: Color4[];
  115340. }, scene?: Nullable<Scene>): Mesh;
  115341. /**
  115342. * Creates a cylinder or a cone mesh
  115343. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115344. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115345. * * 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.
  115346. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115347. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115348. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115349. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115350. * * 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).
  115351. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115352. * * 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).
  115353. * * 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
  115354. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115355. * * 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
  115356. * * 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.
  115357. * * If `enclose` is false, a ring surface is one element.
  115358. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115359. * * 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
  115360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115363. * @param name defines the name of the mesh
  115364. * @param options defines the options used to create the mesh
  115365. * @param scene defines the hosting scene
  115366. * @returns the cylinder mesh
  115367. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115368. */
  115369. static CreateCylinder(name: string, options: {
  115370. height?: number;
  115371. diameterTop?: number;
  115372. diameterBottom?: number;
  115373. diameter?: number;
  115374. tessellation?: number;
  115375. subdivisions?: number;
  115376. arc?: number;
  115377. faceColors?: Color4[];
  115378. faceUV?: Vector4[];
  115379. updatable?: boolean;
  115380. hasRings?: boolean;
  115381. enclose?: boolean;
  115382. cap?: number;
  115383. sideOrientation?: number;
  115384. frontUVs?: Vector4;
  115385. backUVs?: Vector4;
  115386. }, scene?: Nullable<Scene>): Mesh;
  115387. /**
  115388. * Creates a torus mesh
  115389. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115390. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115391. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115395. * @param name defines the name of the mesh
  115396. * @param options defines the options used to create the mesh
  115397. * @param scene defines the hosting scene
  115398. * @returns the torus mesh
  115399. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115400. */
  115401. static CreateTorus(name: string, options: {
  115402. diameter?: number;
  115403. thickness?: number;
  115404. tessellation?: number;
  115405. updatable?: boolean;
  115406. sideOrientation?: number;
  115407. frontUVs?: Vector4;
  115408. backUVs?: Vector4;
  115409. }, scene?: Nullable<Scene>): Mesh;
  115410. /**
  115411. * Creates a torus knot mesh
  115412. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115413. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115414. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115415. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115419. * @param name defines the name of the mesh
  115420. * @param options defines the options used to create the mesh
  115421. * @param scene defines the hosting scene
  115422. * @returns the torus knot mesh
  115423. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115424. */
  115425. static CreateTorusKnot(name: string, options: {
  115426. radius?: number;
  115427. tube?: number;
  115428. radialSegments?: number;
  115429. tubularSegments?: number;
  115430. p?: number;
  115431. q?: number;
  115432. updatable?: boolean;
  115433. sideOrientation?: number;
  115434. frontUVs?: Vector4;
  115435. backUVs?: Vector4;
  115436. }, scene?: Nullable<Scene>): Mesh;
  115437. /**
  115438. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115439. * * 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
  115440. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115441. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  115442. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  115443. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  115444. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  115445. * * 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
  115446. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  115447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115448. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  115449. * @param name defines the name of the new line system
  115450. * @param options defines the options used to create the line system
  115451. * @param scene defines the hosting scene
  115452. * @returns a new line system mesh
  115453. */
  115454. static CreateLineSystem(name: string, options: {
  115455. lines: Vector3[][];
  115456. updatable?: boolean;
  115457. instance?: Nullable<LinesMesh>;
  115458. colors?: Nullable<Color4[][]>;
  115459. useVertexAlpha?: boolean;
  115460. }, scene: Nullable<Scene>): LinesMesh;
  115461. /**
  115462. * Creates a line mesh
  115463. * 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
  115464. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115465. * * The parameter `points` is an array successive Vector3
  115466. * * 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
  115467. * * The optional parameter `colors` is an array of successive Color4, one per line point
  115468. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  115469. * * When updating an instance, remember that only point positions can change, not the number of points
  115470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  115472. * @param name defines the name of the new line system
  115473. * @param options defines the options used to create the line system
  115474. * @param scene defines the hosting scene
  115475. * @returns a new line mesh
  115476. */
  115477. static CreateLines(name: string, options: {
  115478. points: Vector3[];
  115479. updatable?: boolean;
  115480. instance?: Nullable<LinesMesh>;
  115481. colors?: Color4[];
  115482. useVertexAlpha?: boolean;
  115483. }, scene?: Nullable<Scene>): LinesMesh;
  115484. /**
  115485. * Creates a dashed line mesh
  115486. * * 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
  115487. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115488. * * The parameter `points` is an array successive Vector3
  115489. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  115490. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  115491. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  115492. * * 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
  115493. * * When updating an instance, remember that only point positions can change, not the number of points
  115494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115495. * @param name defines the name of the mesh
  115496. * @param options defines the options used to create the mesh
  115497. * @param scene defines the hosting scene
  115498. * @returns the dashed line mesh
  115499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  115500. */
  115501. static CreateDashedLines(name: string, options: {
  115502. points: Vector3[];
  115503. dashSize?: number;
  115504. gapSize?: number;
  115505. dashNb?: number;
  115506. updatable?: boolean;
  115507. instance?: LinesMesh;
  115508. }, scene?: Nullable<Scene>): LinesMesh;
  115509. /**
  115510. * 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.
  115511. * * 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.
  115512. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115513. * * 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.
  115514. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115515. * * 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
  115516. * * 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
  115517. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115520. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115522. * @param name defines the name of the mesh
  115523. * @param options defines the options used to create the mesh
  115524. * @param scene defines the hosting scene
  115525. * @returns the extruded shape mesh
  115526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115528. */
  115529. static ExtrudeShape(name: string, options: {
  115530. shape: Vector3[];
  115531. path: Vector3[];
  115532. scale?: number;
  115533. rotation?: number;
  115534. cap?: number;
  115535. updatable?: boolean;
  115536. sideOrientation?: number;
  115537. frontUVs?: Vector4;
  115538. backUVs?: Vector4;
  115539. instance?: Mesh;
  115540. invertUV?: boolean;
  115541. }, scene?: Nullable<Scene>): Mesh;
  115542. /**
  115543. * Creates an custom extruded shape mesh.
  115544. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115545. * * 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.
  115546. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115547. * * 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
  115548. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115549. * * 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
  115550. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115551. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115552. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115553. * * 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
  115554. * * 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
  115555. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115558. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115560. * @param name defines the name of the mesh
  115561. * @param options defines the options used to create the mesh
  115562. * @param scene defines the hosting scene
  115563. * @returns the custom extruded shape mesh
  115564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115565. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115567. */
  115568. static ExtrudeShapeCustom(name: string, options: {
  115569. shape: Vector3[];
  115570. path: Vector3[];
  115571. scaleFunction?: any;
  115572. rotationFunction?: any;
  115573. ribbonCloseArray?: boolean;
  115574. ribbonClosePath?: boolean;
  115575. cap?: number;
  115576. updatable?: boolean;
  115577. sideOrientation?: number;
  115578. frontUVs?: Vector4;
  115579. backUVs?: Vector4;
  115580. instance?: Mesh;
  115581. invertUV?: boolean;
  115582. }, scene?: Nullable<Scene>): Mesh;
  115583. /**
  115584. * Creates lathe mesh.
  115585. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115586. * * 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
  115587. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115588. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115589. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115590. * * 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
  115591. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115592. * * 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
  115593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115595. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115597. * @param name defines the name of the mesh
  115598. * @param options defines the options used to create the mesh
  115599. * @param scene defines the hosting scene
  115600. * @returns the lathe mesh
  115601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115602. */
  115603. static CreateLathe(name: string, options: {
  115604. shape: Vector3[];
  115605. radius?: number;
  115606. tessellation?: number;
  115607. clip?: number;
  115608. arc?: number;
  115609. closed?: boolean;
  115610. updatable?: boolean;
  115611. sideOrientation?: number;
  115612. frontUVs?: Vector4;
  115613. backUVs?: Vector4;
  115614. cap?: number;
  115615. invertUV?: boolean;
  115616. }, scene?: Nullable<Scene>): Mesh;
  115617. /**
  115618. * Creates a tiled plane mesh
  115619. * * You can set a limited pattern arrangement with the tiles
  115620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115623. * @param name defines the name of the mesh
  115624. * @param options defines the options used to create the mesh
  115625. * @param scene defines the hosting scene
  115626. * @returns the plane mesh
  115627. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115628. */
  115629. static CreateTiledPlane(name: string, options: {
  115630. pattern?: number;
  115631. tileSize?: number;
  115632. tileWidth?: number;
  115633. tileHeight?: number;
  115634. size?: number;
  115635. width?: number;
  115636. height?: number;
  115637. alignHorizontal?: number;
  115638. alignVertical?: number;
  115639. sideOrientation?: number;
  115640. frontUVs?: Vector4;
  115641. backUVs?: Vector4;
  115642. updatable?: boolean;
  115643. }, scene?: Nullable<Scene>): Mesh;
  115644. /**
  115645. * Creates a plane mesh
  115646. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115647. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115648. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115652. * @param name defines the name of the mesh
  115653. * @param options defines the options used to create the mesh
  115654. * @param scene defines the hosting scene
  115655. * @returns the plane mesh
  115656. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115657. */
  115658. static CreatePlane(name: string, options: {
  115659. size?: number;
  115660. width?: number;
  115661. height?: number;
  115662. sideOrientation?: number;
  115663. frontUVs?: Vector4;
  115664. backUVs?: Vector4;
  115665. updatable?: boolean;
  115666. sourcePlane?: Plane;
  115667. }, scene?: Nullable<Scene>): Mesh;
  115668. /**
  115669. * Creates a ground mesh
  115670. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115671. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115673. * @param name defines the name of the mesh
  115674. * @param options defines the options used to create the mesh
  115675. * @param scene defines the hosting scene
  115676. * @returns the ground mesh
  115677. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115678. */
  115679. static CreateGround(name: string, options: {
  115680. width?: number;
  115681. height?: number;
  115682. subdivisions?: number;
  115683. subdivisionsX?: number;
  115684. subdivisionsY?: number;
  115685. updatable?: boolean;
  115686. }, scene?: Nullable<Scene>): Mesh;
  115687. /**
  115688. * Creates a tiled ground mesh
  115689. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115690. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115691. * * 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
  115692. * * 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
  115693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115694. * @param name defines the name of the mesh
  115695. * @param options defines the options used to create the mesh
  115696. * @param scene defines the hosting scene
  115697. * @returns the tiled ground mesh
  115698. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115699. */
  115700. static CreateTiledGround(name: string, options: {
  115701. xmin: number;
  115702. zmin: number;
  115703. xmax: number;
  115704. zmax: number;
  115705. subdivisions?: {
  115706. w: number;
  115707. h: number;
  115708. };
  115709. precision?: {
  115710. w: number;
  115711. h: number;
  115712. };
  115713. updatable?: boolean;
  115714. }, scene?: Nullable<Scene>): Mesh;
  115715. /**
  115716. * Creates a ground mesh from a height map
  115717. * * The parameter `url` sets the URL of the height map image resource.
  115718. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115719. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115720. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115721. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115722. * * 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.
  115723. * * 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).
  115724. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115726. * @param name defines the name of the mesh
  115727. * @param url defines the url to the height map
  115728. * @param options defines the options used to create the mesh
  115729. * @param scene defines the hosting scene
  115730. * @returns the ground mesh
  115731. * @see https://doc.babylonjs.com/babylon101/height_map
  115732. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115733. */
  115734. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115735. width?: number;
  115736. height?: number;
  115737. subdivisions?: number;
  115738. minHeight?: number;
  115739. maxHeight?: number;
  115740. colorFilter?: Color3;
  115741. alphaFilter?: number;
  115742. updatable?: boolean;
  115743. onReady?: (mesh: GroundMesh) => void;
  115744. }, scene?: Nullable<Scene>): GroundMesh;
  115745. /**
  115746. * Creates a polygon mesh
  115747. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115748. * * 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
  115749. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115752. * * Remember you can only change the shape positions, not their number when updating a polygon
  115753. * @param name defines the name of the mesh
  115754. * @param options defines the options used to create the mesh
  115755. * @param scene defines the hosting scene
  115756. * @param earcutInjection can be used to inject your own earcut reference
  115757. * @returns the polygon mesh
  115758. */
  115759. static CreatePolygon(name: string, options: {
  115760. shape: Vector3[];
  115761. holes?: Vector3[][];
  115762. depth?: number;
  115763. faceUV?: Vector4[];
  115764. faceColors?: Color4[];
  115765. updatable?: boolean;
  115766. sideOrientation?: number;
  115767. frontUVs?: Vector4;
  115768. backUVs?: Vector4;
  115769. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115770. /**
  115771. * Creates an extruded polygon mesh, with depth in the Y direction.
  115772. * * 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)
  115773. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115774. * @param name defines the name of the mesh
  115775. * @param options defines the options used to create the mesh
  115776. * @param scene defines the hosting scene
  115777. * @param earcutInjection can be used to inject your own earcut reference
  115778. * @returns the polygon mesh
  115779. */
  115780. static ExtrudePolygon(name: string, options: {
  115781. shape: Vector3[];
  115782. holes?: Vector3[][];
  115783. depth?: number;
  115784. faceUV?: Vector4[];
  115785. faceColors?: Color4[];
  115786. updatable?: boolean;
  115787. sideOrientation?: number;
  115788. frontUVs?: Vector4;
  115789. backUVs?: Vector4;
  115790. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115791. /**
  115792. * Creates a tube mesh.
  115793. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115794. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115795. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115796. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115797. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115798. * * 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)
  115799. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115800. * * 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
  115801. * * 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
  115802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115804. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115806. * @param name defines the name of the mesh
  115807. * @param options defines the options used to create the mesh
  115808. * @param scene defines the hosting scene
  115809. * @returns the tube mesh
  115810. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115811. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115812. */
  115813. static CreateTube(name: string, options: {
  115814. path: Vector3[];
  115815. radius?: number;
  115816. tessellation?: number;
  115817. radiusFunction?: {
  115818. (i: number, distance: number): number;
  115819. };
  115820. cap?: number;
  115821. arc?: number;
  115822. updatable?: boolean;
  115823. sideOrientation?: number;
  115824. frontUVs?: Vector4;
  115825. backUVs?: Vector4;
  115826. instance?: Mesh;
  115827. invertUV?: boolean;
  115828. }, scene?: Nullable<Scene>): Mesh;
  115829. /**
  115830. * Creates a polyhedron mesh
  115831. * * 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
  115832. * * The parameter `size` (positive float, default 1) sets the polygon size
  115833. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115834. * * 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`
  115835. * * 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
  115836. * * 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)`)
  115837. * * 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
  115838. * * 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
  115839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115842. * @param name defines the name of the mesh
  115843. * @param options defines the options used to create the mesh
  115844. * @param scene defines the hosting scene
  115845. * @returns the polyhedron mesh
  115846. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115847. */
  115848. static CreatePolyhedron(name: string, options: {
  115849. type?: number;
  115850. size?: number;
  115851. sizeX?: number;
  115852. sizeY?: number;
  115853. sizeZ?: number;
  115854. custom?: any;
  115855. faceUV?: Vector4[];
  115856. faceColors?: Color4[];
  115857. flat?: boolean;
  115858. updatable?: boolean;
  115859. sideOrientation?: number;
  115860. frontUVs?: Vector4;
  115861. backUVs?: Vector4;
  115862. }, scene?: Nullable<Scene>): Mesh;
  115863. /**
  115864. * Creates a decal mesh.
  115865. * 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
  115866. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115867. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115868. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115869. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115870. * @param name defines the name of the mesh
  115871. * @param sourceMesh defines the mesh where the decal must be applied
  115872. * @param options defines the options used to create the mesh
  115873. * @param scene defines the hosting scene
  115874. * @returns the decal mesh
  115875. * @see https://doc.babylonjs.com/how_to/decals
  115876. */
  115877. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115878. position?: Vector3;
  115879. normal?: Vector3;
  115880. size?: Vector3;
  115881. angle?: number;
  115882. }): Mesh;
  115883. }
  115884. }
  115885. declare module BABYLON {
  115886. /**
  115887. * A simplifier interface for future simplification implementations
  115888. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115889. */
  115890. export interface ISimplifier {
  115891. /**
  115892. * Simplification of a given mesh according to the given settings.
  115893. * Since this requires computation, it is assumed that the function runs async.
  115894. * @param settings The settings of the simplification, including quality and distance
  115895. * @param successCallback A callback that will be called after the mesh was simplified.
  115896. * @param errorCallback in case of an error, this callback will be called. optional.
  115897. */
  115898. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  115899. }
  115900. /**
  115901. * Expected simplification settings.
  115902. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  115903. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115904. */
  115905. export interface ISimplificationSettings {
  115906. /**
  115907. * Gets or sets the expected quality
  115908. */
  115909. quality: number;
  115910. /**
  115911. * Gets or sets the distance when this optimized version should be used
  115912. */
  115913. distance: number;
  115914. /**
  115915. * Gets an already optimized mesh
  115916. */
  115917. optimizeMesh?: boolean;
  115918. }
  115919. /**
  115920. * Class used to specify simplification options
  115921. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115922. */
  115923. export class SimplificationSettings implements ISimplificationSettings {
  115924. /** expected quality */
  115925. quality: number;
  115926. /** distance when this optimized version should be used */
  115927. distance: number;
  115928. /** already optimized mesh */
  115929. optimizeMesh?: boolean | undefined;
  115930. /**
  115931. * Creates a SimplificationSettings
  115932. * @param quality expected quality
  115933. * @param distance distance when this optimized version should be used
  115934. * @param optimizeMesh already optimized mesh
  115935. */
  115936. constructor(
  115937. /** expected quality */
  115938. quality: number,
  115939. /** distance when this optimized version should be used */
  115940. distance: number,
  115941. /** already optimized mesh */
  115942. optimizeMesh?: boolean | undefined);
  115943. }
  115944. /**
  115945. * Interface used to define a simplification task
  115946. */
  115947. export interface ISimplificationTask {
  115948. /**
  115949. * Array of settings
  115950. */
  115951. settings: Array<ISimplificationSettings>;
  115952. /**
  115953. * Simplification type
  115954. */
  115955. simplificationType: SimplificationType;
  115956. /**
  115957. * Mesh to simplify
  115958. */
  115959. mesh: Mesh;
  115960. /**
  115961. * Callback called on success
  115962. */
  115963. successCallback?: () => void;
  115964. /**
  115965. * Defines if parallel processing can be used
  115966. */
  115967. parallelProcessing: boolean;
  115968. }
  115969. /**
  115970. * Queue used to order the simplification tasks
  115971. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115972. */
  115973. export class SimplificationQueue {
  115974. private _simplificationArray;
  115975. /**
  115976. * Gets a boolean indicating that the process is still running
  115977. */
  115978. running: boolean;
  115979. /**
  115980. * Creates a new queue
  115981. */
  115982. constructor();
  115983. /**
  115984. * Adds a new simplification task
  115985. * @param task defines a task to add
  115986. */
  115987. addTask(task: ISimplificationTask): void;
  115988. /**
  115989. * Execute next task
  115990. */
  115991. executeNext(): void;
  115992. /**
  115993. * Execute a simplification task
  115994. * @param task defines the task to run
  115995. */
  115996. runSimplification(task: ISimplificationTask): void;
  115997. private getSimplifier;
  115998. }
  115999. /**
  116000. * The implemented types of simplification
  116001. * At the moment only Quadratic Error Decimation is implemented
  116002. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116003. */
  116004. export enum SimplificationType {
  116005. /** Quadratic error decimation */
  116006. QUADRATIC = 0
  116007. }
  116008. }
  116009. declare module BABYLON {
  116010. interface Scene {
  116011. /** @hidden (Backing field) */
  116012. _simplificationQueue: SimplificationQueue;
  116013. /**
  116014. * Gets or sets the simplification queue attached to the scene
  116015. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116016. */
  116017. simplificationQueue: SimplificationQueue;
  116018. }
  116019. interface Mesh {
  116020. /**
  116021. * Simplify the mesh according to the given array of settings.
  116022. * Function will return immediately and will simplify async
  116023. * @param settings a collection of simplification settings
  116024. * @param parallelProcessing should all levels calculate parallel or one after the other
  116025. * @param simplificationType the type of simplification to run
  116026. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116027. * @returns the current mesh
  116028. */
  116029. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116030. }
  116031. /**
  116032. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116033. * created in a scene
  116034. */
  116035. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116036. /**
  116037. * The component name helpfull to identify the component in the list of scene components.
  116038. */
  116039. readonly name: string;
  116040. /**
  116041. * The scene the component belongs to.
  116042. */
  116043. scene: Scene;
  116044. /**
  116045. * Creates a new instance of the component for the given scene
  116046. * @param scene Defines the scene to register the component in
  116047. */
  116048. constructor(scene: Scene);
  116049. /**
  116050. * Registers the component in a given scene
  116051. */
  116052. register(): void;
  116053. /**
  116054. * Rebuilds the elements related to this component in case of
  116055. * context lost for instance.
  116056. */
  116057. rebuild(): void;
  116058. /**
  116059. * Disposes the component and the associated ressources
  116060. */
  116061. dispose(): void;
  116062. private _beforeCameraUpdate;
  116063. }
  116064. }
  116065. declare module BABYLON {
  116066. /**
  116067. * Class used to enable access to IndexedDB
  116068. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116069. */
  116070. export class Database implements IOfflineProvider {
  116071. private _callbackManifestChecked;
  116072. private _currentSceneUrl;
  116073. private _db;
  116074. private _enableSceneOffline;
  116075. private _enableTexturesOffline;
  116076. private _manifestVersionFound;
  116077. private _mustUpdateRessources;
  116078. private _hasReachedQuota;
  116079. private _isSupported;
  116080. private _idbFactory;
  116081. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116082. private static IsUASupportingBlobStorage;
  116083. /**
  116084. * Gets a boolean indicating if Database storate is enabled (off by default)
  116085. */
  116086. static IDBStorageEnabled: boolean;
  116087. /**
  116088. * Gets a boolean indicating if scene must be saved in the database
  116089. */
  116090. readonly enableSceneOffline: boolean;
  116091. /**
  116092. * Gets a boolean indicating if textures must be saved in the database
  116093. */
  116094. readonly enableTexturesOffline: boolean;
  116095. /**
  116096. * Creates a new Database
  116097. * @param urlToScene defines the url to load the scene
  116098. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116099. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116100. */
  116101. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116102. private static _ParseURL;
  116103. private static _ReturnFullUrlLocation;
  116104. private _checkManifestFile;
  116105. /**
  116106. * Open the database and make it available
  116107. * @param successCallback defines the callback to call on success
  116108. * @param errorCallback defines the callback to call on error
  116109. */
  116110. open(successCallback: () => void, errorCallback: () => void): void;
  116111. /**
  116112. * Loads an image from the database
  116113. * @param url defines the url to load from
  116114. * @param image defines the target DOM image
  116115. */
  116116. loadImage(url: string, image: HTMLImageElement): void;
  116117. private _loadImageFromDBAsync;
  116118. private _saveImageIntoDBAsync;
  116119. private _checkVersionFromDB;
  116120. private _loadVersionFromDBAsync;
  116121. private _saveVersionIntoDBAsync;
  116122. /**
  116123. * Loads a file from database
  116124. * @param url defines the URL to load from
  116125. * @param sceneLoaded defines a callback to call on success
  116126. * @param progressCallBack defines a callback to call when progress changed
  116127. * @param errorCallback defines a callback to call on error
  116128. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116129. */
  116130. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116131. private _loadFileAsync;
  116132. private _saveFileAsync;
  116133. /**
  116134. * Validates if xhr data is correct
  116135. * @param xhr defines the request to validate
  116136. * @param dataType defines the expected data type
  116137. * @returns true if data is correct
  116138. */
  116139. private static _ValidateXHRData;
  116140. }
  116141. }
  116142. declare module BABYLON {
  116143. /** @hidden */
  116144. export var gpuUpdateParticlesPixelShader: {
  116145. name: string;
  116146. shader: string;
  116147. };
  116148. }
  116149. declare module BABYLON {
  116150. /** @hidden */
  116151. export var gpuUpdateParticlesVertexShader: {
  116152. name: string;
  116153. shader: string;
  116154. };
  116155. }
  116156. declare module BABYLON {
  116157. /** @hidden */
  116158. export var clipPlaneFragmentDeclaration2: {
  116159. name: string;
  116160. shader: string;
  116161. };
  116162. }
  116163. declare module BABYLON {
  116164. /** @hidden */
  116165. export var gpuRenderParticlesPixelShader: {
  116166. name: string;
  116167. shader: string;
  116168. };
  116169. }
  116170. declare module BABYLON {
  116171. /** @hidden */
  116172. export var clipPlaneVertexDeclaration2: {
  116173. name: string;
  116174. shader: string;
  116175. };
  116176. }
  116177. declare module BABYLON {
  116178. /** @hidden */
  116179. export var gpuRenderParticlesVertexShader: {
  116180. name: string;
  116181. shader: string;
  116182. };
  116183. }
  116184. declare module BABYLON {
  116185. /**
  116186. * This represents a GPU particle system in Babylon
  116187. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116188. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116189. */
  116190. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116191. /**
  116192. * The layer mask we are rendering the particles through.
  116193. */
  116194. layerMask: number;
  116195. private _capacity;
  116196. private _activeCount;
  116197. private _currentActiveCount;
  116198. private _accumulatedCount;
  116199. private _renderEffect;
  116200. private _updateEffect;
  116201. private _buffer0;
  116202. private _buffer1;
  116203. private _spriteBuffer;
  116204. private _updateVAO;
  116205. private _renderVAO;
  116206. private _targetIndex;
  116207. private _sourceBuffer;
  116208. private _targetBuffer;
  116209. private _engine;
  116210. private _currentRenderId;
  116211. private _started;
  116212. private _stopped;
  116213. private _timeDelta;
  116214. private _randomTexture;
  116215. private _randomTexture2;
  116216. private _attributesStrideSize;
  116217. private _updateEffectOptions;
  116218. private _randomTextureSize;
  116219. private _actualFrame;
  116220. private readonly _rawTextureWidth;
  116221. /**
  116222. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116223. */
  116224. static readonly IsSupported: boolean;
  116225. /**
  116226. * An event triggered when the system is disposed.
  116227. */
  116228. onDisposeObservable: Observable<GPUParticleSystem>;
  116229. /**
  116230. * Gets the maximum number of particles active at the same time.
  116231. * @returns The max number of active particles.
  116232. */
  116233. getCapacity(): number;
  116234. /**
  116235. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116236. * to override the particles.
  116237. */
  116238. forceDepthWrite: boolean;
  116239. /**
  116240. * Gets or set the number of active particles
  116241. */
  116242. activeParticleCount: number;
  116243. private _preWarmDone;
  116244. /**
  116245. * Is this system ready to be used/rendered
  116246. * @return true if the system is ready
  116247. */
  116248. isReady(): boolean;
  116249. /**
  116250. * Gets if the system has been started. (Note: this will still be true after stop is called)
  116251. * @returns True if it has been started, otherwise false.
  116252. */
  116253. isStarted(): boolean;
  116254. /**
  116255. * Starts the particle system and begins to emit
  116256. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  116257. */
  116258. start(delay?: number): void;
  116259. /**
  116260. * Stops the particle system.
  116261. */
  116262. stop(): void;
  116263. /**
  116264. * Remove all active particles
  116265. */
  116266. reset(): void;
  116267. /**
  116268. * Returns the string "GPUParticleSystem"
  116269. * @returns a string containing the class name
  116270. */
  116271. getClassName(): string;
  116272. private _colorGradientsTexture;
  116273. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  116274. /**
  116275. * Adds a new color gradient
  116276. * @param gradient defines the gradient to use (between 0 and 1)
  116277. * @param color1 defines the color to affect to the specified gradient
  116278. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  116279. * @returns the current particle system
  116280. */
  116281. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  116282. /**
  116283. * Remove a specific color gradient
  116284. * @param gradient defines the gradient to remove
  116285. * @returns the current particle system
  116286. */
  116287. removeColorGradient(gradient: number): GPUParticleSystem;
  116288. private _angularSpeedGradientsTexture;
  116289. private _sizeGradientsTexture;
  116290. private _velocityGradientsTexture;
  116291. private _limitVelocityGradientsTexture;
  116292. private _dragGradientsTexture;
  116293. private _addFactorGradient;
  116294. /**
  116295. * Adds a new size gradient
  116296. * @param gradient defines the gradient to use (between 0 and 1)
  116297. * @param factor defines the size factor to affect to the specified gradient
  116298. * @returns the current particle system
  116299. */
  116300. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  116301. /**
  116302. * Remove a specific size gradient
  116303. * @param gradient defines the gradient to remove
  116304. * @returns the current particle system
  116305. */
  116306. removeSizeGradient(gradient: number): GPUParticleSystem;
  116307. /**
  116308. * Adds a new angular speed gradient
  116309. * @param gradient defines the gradient to use (between 0 and 1)
  116310. * @param factor defines the angular speed to affect to the specified gradient
  116311. * @returns the current particle system
  116312. */
  116313. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  116314. /**
  116315. * Remove a specific angular speed gradient
  116316. * @param gradient defines the gradient to remove
  116317. * @returns the current particle system
  116318. */
  116319. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  116320. /**
  116321. * Adds a new velocity gradient
  116322. * @param gradient defines the gradient to use (between 0 and 1)
  116323. * @param factor defines the velocity to affect to the specified gradient
  116324. * @returns the current particle system
  116325. */
  116326. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116327. /**
  116328. * Remove a specific velocity gradient
  116329. * @param gradient defines the gradient to remove
  116330. * @returns the current particle system
  116331. */
  116332. removeVelocityGradient(gradient: number): GPUParticleSystem;
  116333. /**
  116334. * Adds a new limit velocity gradient
  116335. * @param gradient defines the gradient to use (between 0 and 1)
  116336. * @param factor defines the limit velocity value to affect to the specified gradient
  116337. * @returns the current particle system
  116338. */
  116339. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116340. /**
  116341. * Remove a specific limit velocity gradient
  116342. * @param gradient defines the gradient to remove
  116343. * @returns the current particle system
  116344. */
  116345. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  116346. /**
  116347. * Adds a new drag gradient
  116348. * @param gradient defines the gradient to use (between 0 and 1)
  116349. * @param factor defines the drag value to affect to the specified gradient
  116350. * @returns the current particle system
  116351. */
  116352. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  116353. /**
  116354. * Remove a specific drag gradient
  116355. * @param gradient defines the gradient to remove
  116356. * @returns the current particle system
  116357. */
  116358. removeDragGradient(gradient: number): GPUParticleSystem;
  116359. /**
  116360. * Not supported by GPUParticleSystem
  116361. * @param gradient defines the gradient to use (between 0 and 1)
  116362. * @param factor defines the emit rate value to affect to the specified gradient
  116363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116364. * @returns the current particle system
  116365. */
  116366. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116367. /**
  116368. * Not supported by GPUParticleSystem
  116369. * @param gradient defines the gradient to remove
  116370. * @returns the current particle system
  116371. */
  116372. removeEmitRateGradient(gradient: number): IParticleSystem;
  116373. /**
  116374. * Not supported by GPUParticleSystem
  116375. * @param gradient defines the gradient to use (between 0 and 1)
  116376. * @param factor defines the start size value to affect to the specified gradient
  116377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116378. * @returns the current particle system
  116379. */
  116380. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116381. /**
  116382. * Not supported by GPUParticleSystem
  116383. * @param gradient defines the gradient to remove
  116384. * @returns the current particle system
  116385. */
  116386. removeStartSizeGradient(gradient: number): IParticleSystem;
  116387. /**
  116388. * Not supported by GPUParticleSystem
  116389. * @param gradient defines the gradient to use (between 0 and 1)
  116390. * @param min defines the color remap minimal range
  116391. * @param max defines the color remap maximal range
  116392. * @returns the current particle system
  116393. */
  116394. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116395. /**
  116396. * Not supported by GPUParticleSystem
  116397. * @param gradient defines the gradient to remove
  116398. * @returns the current particle system
  116399. */
  116400. removeColorRemapGradient(): IParticleSystem;
  116401. /**
  116402. * Not supported by GPUParticleSystem
  116403. * @param gradient defines the gradient to use (between 0 and 1)
  116404. * @param min defines the alpha remap minimal range
  116405. * @param max defines the alpha remap maximal range
  116406. * @returns the current particle system
  116407. */
  116408. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116409. /**
  116410. * Not supported by GPUParticleSystem
  116411. * @param gradient defines the gradient to remove
  116412. * @returns the current particle system
  116413. */
  116414. removeAlphaRemapGradient(): IParticleSystem;
  116415. /**
  116416. * Not supported by GPUParticleSystem
  116417. * @param gradient defines the gradient to use (between 0 and 1)
  116418. * @param color defines the color to affect to the specified gradient
  116419. * @returns the current particle system
  116420. */
  116421. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  116422. /**
  116423. * Not supported by GPUParticleSystem
  116424. * @param gradient defines the gradient to remove
  116425. * @returns the current particle system
  116426. */
  116427. removeRampGradient(): IParticleSystem;
  116428. /**
  116429. * Not supported by GPUParticleSystem
  116430. * @returns the list of ramp gradients
  116431. */
  116432. getRampGradients(): Nullable<Array<Color3Gradient>>;
  116433. /**
  116434. * Not supported by GPUParticleSystem
  116435. * Gets or sets a boolean indicating that ramp gradients must be used
  116436. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  116437. */
  116438. useRampGradients: boolean;
  116439. /**
  116440. * Not supported by GPUParticleSystem
  116441. * @param gradient defines the gradient to use (between 0 and 1)
  116442. * @param factor defines the life time factor to affect to the specified gradient
  116443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116444. * @returns the current particle system
  116445. */
  116446. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116447. /**
  116448. * Not supported by GPUParticleSystem
  116449. * @param gradient defines the gradient to remove
  116450. * @returns the current particle system
  116451. */
  116452. removeLifeTimeGradient(gradient: number): IParticleSystem;
  116453. /**
  116454. * Instantiates a GPU particle system.
  116455. * 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.
  116456. * @param name The name of the particle system
  116457. * @param options The options used to create the system
  116458. * @param scene The scene the particle system belongs to
  116459. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  116460. */
  116461. constructor(name: string, options: Partial<{
  116462. capacity: number;
  116463. randomTextureSize: number;
  116464. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  116465. protected _reset(): void;
  116466. private _createUpdateVAO;
  116467. private _createRenderVAO;
  116468. private _initialize;
  116469. /** @hidden */
  116470. _recreateUpdateEffect(): void;
  116471. /** @hidden */
  116472. _recreateRenderEffect(): void;
  116473. /**
  116474. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  116475. * @param preWarm defines if we are in the pre-warmimg phase
  116476. */
  116477. animate(preWarm?: boolean): void;
  116478. private _createFactorGradientTexture;
  116479. private _createSizeGradientTexture;
  116480. private _createAngularSpeedGradientTexture;
  116481. private _createVelocityGradientTexture;
  116482. private _createLimitVelocityGradientTexture;
  116483. private _createDragGradientTexture;
  116484. private _createColorGradientTexture;
  116485. /**
  116486. * Renders the particle system in its current state
  116487. * @param preWarm defines if the system should only update the particles but not render them
  116488. * @returns the current number of particles
  116489. */
  116490. render(preWarm?: boolean): number;
  116491. /**
  116492. * Rebuilds the particle system
  116493. */
  116494. rebuild(): void;
  116495. private _releaseBuffers;
  116496. private _releaseVAOs;
  116497. /**
  116498. * Disposes the particle system and free the associated resources
  116499. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  116500. */
  116501. dispose(disposeTexture?: boolean): void;
  116502. /**
  116503. * Clones the particle system.
  116504. * @param name The name of the cloned object
  116505. * @param newEmitter The new emitter to use
  116506. * @returns the cloned particle system
  116507. */
  116508. clone(name: string, newEmitter: any): GPUParticleSystem;
  116509. /**
  116510. * Serializes the particle system to a JSON object.
  116511. * @returns the JSON object
  116512. */
  116513. serialize(): any;
  116514. /**
  116515. * Parses a JSON object to create a GPU particle system.
  116516. * @param parsedParticleSystem The JSON object to parse
  116517. * @param scene The scene to create the particle system in
  116518. * @param rootUrl The root url to use to load external dependencies like texture
  116519. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  116520. * @returns the parsed GPU particle system
  116521. */
  116522. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  116523. }
  116524. }
  116525. declare module BABYLON {
  116526. /**
  116527. * Represents a set of particle systems working together to create a specific effect
  116528. */
  116529. export class ParticleSystemSet implements IDisposable {
  116530. private _emitterCreationOptions;
  116531. private _emitterNode;
  116532. /**
  116533. * Gets the particle system list
  116534. */
  116535. systems: IParticleSystem[];
  116536. /**
  116537. * Gets the emitter node used with this set
  116538. */
  116539. readonly emitterNode: Nullable<TransformNode>;
  116540. /**
  116541. * Creates a new emitter mesh as a sphere
  116542. * @param options defines the options used to create the sphere
  116543. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  116544. * @param scene defines the hosting scene
  116545. */
  116546. setEmitterAsSphere(options: {
  116547. diameter: number;
  116548. segments: number;
  116549. color: Color3;
  116550. }, renderingGroupId: number, scene: Scene): void;
  116551. /**
  116552. * Starts all particle systems of the set
  116553. * @param emitter defines an optional mesh to use as emitter for the particle systems
  116554. */
  116555. start(emitter?: AbstractMesh): void;
  116556. /**
  116557. * Release all associated resources
  116558. */
  116559. dispose(): void;
  116560. /**
  116561. * Serialize the set into a JSON compatible object
  116562. * @returns a JSON compatible representation of the set
  116563. */
  116564. serialize(): any;
  116565. /**
  116566. * Parse a new ParticleSystemSet from a serialized source
  116567. * @param data defines a JSON compatible representation of the set
  116568. * @param scene defines the hosting scene
  116569. * @param gpu defines if we want GPU particles or CPU particles
  116570. * @returns a new ParticleSystemSet
  116571. */
  116572. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  116573. }
  116574. }
  116575. declare module BABYLON {
  116576. /**
  116577. * This class is made for on one-liner static method to help creating particle system set.
  116578. */
  116579. export class ParticleHelper {
  116580. /**
  116581. * Gets or sets base Assets URL
  116582. */
  116583. static BaseAssetsUrl: string;
  116584. /**
  116585. * Create a default particle system that you can tweak
  116586. * @param emitter defines the emitter to use
  116587. * @param capacity defines the system capacity (default is 500 particles)
  116588. * @param scene defines the hosting scene
  116589. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  116590. * @returns the new Particle system
  116591. */
  116592. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  116593. /**
  116594. * This is the main static method (one-liner) of this helper to create different particle systems
  116595. * @param type This string represents the type to the particle system to create
  116596. * @param scene The scene where the particle system should live
  116597. * @param gpu If the system will use gpu
  116598. * @returns the ParticleSystemSet created
  116599. */
  116600. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  116601. /**
  116602. * Static function used to export a particle system to a ParticleSystemSet variable.
  116603. * Please note that the emitter shape is not exported
  116604. * @param systems defines the particle systems to export
  116605. * @returns the created particle system set
  116606. */
  116607. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  116608. }
  116609. }
  116610. declare module BABYLON {
  116611. interface Engine {
  116612. /**
  116613. * Create an effect to use with particle systems.
  116614. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  116615. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  116616. * @param uniformsNames defines a list of attribute names
  116617. * @param samplers defines an array of string used to represent textures
  116618. * @param defines defines the string containing the defines to use to compile the shaders
  116619. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116620. * @param onCompiled defines a function to call when the effect creation is successful
  116621. * @param onError defines a function to call when the effect creation has failed
  116622. * @returns the new Effect
  116623. */
  116624. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  116625. }
  116626. interface Mesh {
  116627. /**
  116628. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  116629. * @returns an array of IParticleSystem
  116630. */
  116631. getEmittedParticleSystems(): IParticleSystem[];
  116632. /**
  116633. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  116634. * @returns an array of IParticleSystem
  116635. */
  116636. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  116637. }
  116638. /**
  116639. * @hidden
  116640. */
  116641. export var _IDoNeedToBeInTheBuild: number;
  116642. }
  116643. declare module BABYLON {
  116644. interface Scene {
  116645. /** @hidden (Backing field) */
  116646. _physicsEngine: Nullable<IPhysicsEngine>;
  116647. /**
  116648. * Gets the current physics engine
  116649. * @returns a IPhysicsEngine or null if none attached
  116650. */
  116651. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  116652. /**
  116653. * Enables physics to the current scene
  116654. * @param gravity defines the scene's gravity for the physics engine
  116655. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  116656. * @return a boolean indicating if the physics engine was initialized
  116657. */
  116658. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  116659. /**
  116660. * Disables and disposes the physics engine associated with the scene
  116661. */
  116662. disablePhysicsEngine(): void;
  116663. /**
  116664. * Gets a boolean indicating if there is an active physics engine
  116665. * @returns a boolean indicating if there is an active physics engine
  116666. */
  116667. isPhysicsEnabled(): boolean;
  116668. /**
  116669. * Deletes a physics compound impostor
  116670. * @param compound defines the compound to delete
  116671. */
  116672. deleteCompoundImpostor(compound: any): void;
  116673. /**
  116674. * An event triggered when physic simulation is about to be run
  116675. */
  116676. onBeforePhysicsObservable: Observable<Scene>;
  116677. /**
  116678. * An event triggered when physic simulation has been done
  116679. */
  116680. onAfterPhysicsObservable: Observable<Scene>;
  116681. }
  116682. interface AbstractMesh {
  116683. /** @hidden */
  116684. _physicsImpostor: Nullable<PhysicsImpostor>;
  116685. /**
  116686. * Gets or sets impostor used for physic simulation
  116687. * @see http://doc.babylonjs.com/features/physics_engine
  116688. */
  116689. physicsImpostor: Nullable<PhysicsImpostor>;
  116690. /**
  116691. * Gets the current physics impostor
  116692. * @see http://doc.babylonjs.com/features/physics_engine
  116693. * @returns a physics impostor or null
  116694. */
  116695. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  116696. /** Apply a physic impulse to the mesh
  116697. * @param force defines the force to apply
  116698. * @param contactPoint defines where to apply the force
  116699. * @returns the current mesh
  116700. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116701. */
  116702. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  116703. /**
  116704. * Creates a physic joint between two meshes
  116705. * @param otherMesh defines the other mesh to use
  116706. * @param pivot1 defines the pivot to use on this mesh
  116707. * @param pivot2 defines the pivot to use on the other mesh
  116708. * @param options defines additional options (can be plugin dependent)
  116709. * @returns the current mesh
  116710. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  116711. */
  116712. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  116713. /** @hidden */
  116714. _disposePhysicsObserver: Nullable<Observer<Node>>;
  116715. }
  116716. /**
  116717. * Defines the physics engine scene component responsible to manage a physics engine
  116718. */
  116719. export class PhysicsEngineSceneComponent implements ISceneComponent {
  116720. /**
  116721. * The component name helpful to identify the component in the list of scene components.
  116722. */
  116723. readonly name: string;
  116724. /**
  116725. * The scene the component belongs to.
  116726. */
  116727. scene: Scene;
  116728. /**
  116729. * Creates a new instance of the component for the given scene
  116730. * @param scene Defines the scene to register the component in
  116731. */
  116732. constructor(scene: Scene);
  116733. /**
  116734. * Registers the component in a given scene
  116735. */
  116736. register(): void;
  116737. /**
  116738. * Rebuilds the elements related to this component in case of
  116739. * context lost for instance.
  116740. */
  116741. rebuild(): void;
  116742. /**
  116743. * Disposes the component and the associated ressources
  116744. */
  116745. dispose(): void;
  116746. }
  116747. }
  116748. declare module BABYLON {
  116749. /**
  116750. * A helper for physics simulations
  116751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116752. */
  116753. export class PhysicsHelper {
  116754. private _scene;
  116755. private _physicsEngine;
  116756. /**
  116757. * Initializes the Physics helper
  116758. * @param scene Babylon.js scene
  116759. */
  116760. constructor(scene: Scene);
  116761. /**
  116762. * Applies a radial explosion impulse
  116763. * @param origin the origin of the explosion
  116764. * @param radiusOrEventOptions the radius or the options of radial explosion
  116765. * @param strength the explosion strength
  116766. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116767. * @returns A physics radial explosion event, or null
  116768. */
  116769. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116770. /**
  116771. * Applies a radial explosion force
  116772. * @param origin the origin of the explosion
  116773. * @param radiusOrEventOptions the radius or the options of radial explosion
  116774. * @param strength the explosion strength
  116775. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116776. * @returns A physics radial explosion event, or null
  116777. */
  116778. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116779. /**
  116780. * Creates a gravitational field
  116781. * @param origin the origin of the explosion
  116782. * @param radiusOrEventOptions the radius or the options of radial explosion
  116783. * @param strength the explosion strength
  116784. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116785. * @returns A physics gravitational field event, or null
  116786. */
  116787. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  116788. /**
  116789. * Creates a physics updraft event
  116790. * @param origin the origin of the updraft
  116791. * @param radiusOrEventOptions the radius or the options of the updraft
  116792. * @param strength the strength of the updraft
  116793. * @param height the height of the updraft
  116794. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  116795. * @returns A physics updraft event, or null
  116796. */
  116797. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  116798. /**
  116799. * Creates a physics vortex event
  116800. * @param origin the of the vortex
  116801. * @param radiusOrEventOptions the radius or the options of the vortex
  116802. * @param strength the strength of the vortex
  116803. * @param height the height of the vortex
  116804. * @returns a Physics vortex event, or null
  116805. * A physics vortex event or null
  116806. */
  116807. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  116808. }
  116809. /**
  116810. * Represents a physics radial explosion event
  116811. */
  116812. class PhysicsRadialExplosionEvent {
  116813. private _scene;
  116814. private _options;
  116815. private _sphere;
  116816. private _dataFetched;
  116817. /**
  116818. * Initializes a radial explosioin event
  116819. * @param _scene BabylonJS scene
  116820. * @param _options The options for the vortex event
  116821. */
  116822. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  116823. /**
  116824. * Returns the data related to the radial explosion event (sphere).
  116825. * @returns The radial explosion event data
  116826. */
  116827. getData(): PhysicsRadialExplosionEventData;
  116828. /**
  116829. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  116830. * @param impostor A physics imposter
  116831. * @param origin the origin of the explosion
  116832. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  116833. */
  116834. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  116835. /**
  116836. * Triggers affecterd impostors callbacks
  116837. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  116838. */
  116839. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  116840. /**
  116841. * Disposes the sphere.
  116842. * @param force Specifies if the sphere should be disposed by force
  116843. */
  116844. dispose(force?: boolean): void;
  116845. /*** Helpers ***/
  116846. private _prepareSphere;
  116847. private _intersectsWithSphere;
  116848. }
  116849. /**
  116850. * Represents a gravitational field event
  116851. */
  116852. class PhysicsGravitationalFieldEvent {
  116853. private _physicsHelper;
  116854. private _scene;
  116855. private _origin;
  116856. private _options;
  116857. private _tickCallback;
  116858. private _sphere;
  116859. private _dataFetched;
  116860. /**
  116861. * Initializes the physics gravitational field event
  116862. * @param _physicsHelper A physics helper
  116863. * @param _scene BabylonJS scene
  116864. * @param _origin The origin position of the gravitational field event
  116865. * @param _options The options for the vortex event
  116866. */
  116867. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  116868. /**
  116869. * Returns the data related to the gravitational field event (sphere).
  116870. * @returns A gravitational field event
  116871. */
  116872. getData(): PhysicsGravitationalFieldEventData;
  116873. /**
  116874. * Enables the gravitational field.
  116875. */
  116876. enable(): void;
  116877. /**
  116878. * Disables the gravitational field.
  116879. */
  116880. disable(): void;
  116881. /**
  116882. * Disposes the sphere.
  116883. * @param force The force to dispose from the gravitational field event
  116884. */
  116885. dispose(force?: boolean): void;
  116886. private _tick;
  116887. }
  116888. /**
  116889. * Represents a physics updraft event
  116890. */
  116891. class PhysicsUpdraftEvent {
  116892. private _scene;
  116893. private _origin;
  116894. private _options;
  116895. private _physicsEngine;
  116896. private _originTop;
  116897. private _originDirection;
  116898. private _tickCallback;
  116899. private _cylinder;
  116900. private _cylinderPosition;
  116901. private _dataFetched;
  116902. /**
  116903. * Initializes the physics updraft event
  116904. * @param _scene BabylonJS scene
  116905. * @param _origin The origin position of the updraft
  116906. * @param _options The options for the updraft event
  116907. */
  116908. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  116909. /**
  116910. * Returns the data related to the updraft event (cylinder).
  116911. * @returns A physics updraft event
  116912. */
  116913. getData(): PhysicsUpdraftEventData;
  116914. /**
  116915. * Enables the updraft.
  116916. */
  116917. enable(): void;
  116918. /**
  116919. * Disables the updraft.
  116920. */
  116921. disable(): void;
  116922. /**
  116923. * Disposes the cylinder.
  116924. * @param force Specifies if the updraft should be disposed by force
  116925. */
  116926. dispose(force?: boolean): void;
  116927. private getImpostorHitData;
  116928. private _tick;
  116929. /*** Helpers ***/
  116930. private _prepareCylinder;
  116931. private _intersectsWithCylinder;
  116932. }
  116933. /**
  116934. * Represents a physics vortex event
  116935. */
  116936. class PhysicsVortexEvent {
  116937. private _scene;
  116938. private _origin;
  116939. private _options;
  116940. private _physicsEngine;
  116941. private _originTop;
  116942. private _tickCallback;
  116943. private _cylinder;
  116944. private _cylinderPosition;
  116945. private _dataFetched;
  116946. /**
  116947. * Initializes the physics vortex event
  116948. * @param _scene The BabylonJS scene
  116949. * @param _origin The origin position of the vortex
  116950. * @param _options The options for the vortex event
  116951. */
  116952. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  116953. /**
  116954. * Returns the data related to the vortex event (cylinder).
  116955. * @returns The physics vortex event data
  116956. */
  116957. getData(): PhysicsVortexEventData;
  116958. /**
  116959. * Enables the vortex.
  116960. */
  116961. enable(): void;
  116962. /**
  116963. * Disables the cortex.
  116964. */
  116965. disable(): void;
  116966. /**
  116967. * Disposes the sphere.
  116968. * @param force
  116969. */
  116970. dispose(force?: boolean): void;
  116971. private getImpostorHitData;
  116972. private _tick;
  116973. /*** Helpers ***/
  116974. private _prepareCylinder;
  116975. private _intersectsWithCylinder;
  116976. }
  116977. /**
  116978. * Options fot the radial explosion event
  116979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116980. */
  116981. export class PhysicsRadialExplosionEventOptions {
  116982. /**
  116983. * The radius of the sphere for the radial explosion.
  116984. */
  116985. radius: number;
  116986. /**
  116987. * The strenth of the explosion.
  116988. */
  116989. strength: number;
  116990. /**
  116991. * The strenght of the force in correspondence to the distance of the affected object
  116992. */
  116993. falloff: PhysicsRadialImpulseFalloff;
  116994. /**
  116995. * Sphere options for the radial explosion.
  116996. */
  116997. sphere: {
  116998. segments: number;
  116999. diameter: number;
  117000. };
  117001. /**
  117002. * Sphere options for the radial explosion.
  117003. */
  117004. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117005. }
  117006. /**
  117007. * Options fot the updraft event
  117008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117009. */
  117010. export class PhysicsUpdraftEventOptions {
  117011. /**
  117012. * The radius of the cylinder for the vortex
  117013. */
  117014. radius: number;
  117015. /**
  117016. * The strenth of the updraft.
  117017. */
  117018. strength: number;
  117019. /**
  117020. * The height of the cylinder for the updraft.
  117021. */
  117022. height: number;
  117023. /**
  117024. * The mode for the the updraft.
  117025. */
  117026. updraftMode: PhysicsUpdraftMode;
  117027. }
  117028. /**
  117029. * Options fot the vortex event
  117030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117031. */
  117032. export class PhysicsVortexEventOptions {
  117033. /**
  117034. * The radius of the cylinder for the vortex
  117035. */
  117036. radius: number;
  117037. /**
  117038. * The strenth of the vortex.
  117039. */
  117040. strength: number;
  117041. /**
  117042. * The height of the cylinder for the vortex.
  117043. */
  117044. height: number;
  117045. /**
  117046. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117047. */
  117048. centripetalForceThreshold: number;
  117049. /**
  117050. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117051. */
  117052. centripetalForceMultiplier: number;
  117053. /**
  117054. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117055. */
  117056. centrifugalForceMultiplier: number;
  117057. /**
  117058. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117059. */
  117060. updraftForceMultiplier: number;
  117061. }
  117062. /**
  117063. * The strenght of the force in correspondence to the distance of the affected object
  117064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117065. */
  117066. export enum PhysicsRadialImpulseFalloff {
  117067. /** Defines that impulse is constant in strength across it's whole radius */
  117068. Constant = 0,
  117069. /** Defines that impulse gets weaker if it's further from the origin */
  117070. Linear = 1
  117071. }
  117072. /**
  117073. * The strength of the force in correspondence to the distance of the affected object
  117074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117075. */
  117076. export enum PhysicsUpdraftMode {
  117077. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117078. Center = 0,
  117079. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117080. Perpendicular = 1
  117081. }
  117082. /**
  117083. * Interface for a physics hit data
  117084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117085. */
  117086. export interface PhysicsHitData {
  117087. /**
  117088. * The force applied at the contact point
  117089. */
  117090. force: Vector3;
  117091. /**
  117092. * The contact point
  117093. */
  117094. contactPoint: Vector3;
  117095. /**
  117096. * The distance from the origin to the contact point
  117097. */
  117098. distanceFromOrigin: number;
  117099. }
  117100. /**
  117101. * Interface for radial explosion event data
  117102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117103. */
  117104. export interface PhysicsRadialExplosionEventData {
  117105. /**
  117106. * A sphere used for the radial explosion event
  117107. */
  117108. sphere: Mesh;
  117109. }
  117110. /**
  117111. * Interface for gravitational field event data
  117112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117113. */
  117114. export interface PhysicsGravitationalFieldEventData {
  117115. /**
  117116. * A sphere mesh used for the gravitational field event
  117117. */
  117118. sphere: Mesh;
  117119. }
  117120. /**
  117121. * Interface for updraft event data
  117122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117123. */
  117124. export interface PhysicsUpdraftEventData {
  117125. /**
  117126. * A cylinder used for the updraft event
  117127. */
  117128. cylinder: Mesh;
  117129. }
  117130. /**
  117131. * Interface for vortex event data
  117132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117133. */
  117134. export interface PhysicsVortexEventData {
  117135. /**
  117136. * A cylinder used for the vortex event
  117137. */
  117138. cylinder: Mesh;
  117139. }
  117140. /**
  117141. * Interface for an affected physics impostor
  117142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117143. */
  117144. export interface PhysicsAffectedImpostorWithData {
  117145. /**
  117146. * The impostor affected by the effect
  117147. */
  117148. impostor: PhysicsImpostor;
  117149. /**
  117150. * The data about the hit/horce from the explosion
  117151. */
  117152. hitData: PhysicsHitData;
  117153. }
  117154. }
  117155. declare module BABYLON {
  117156. /** @hidden */
  117157. export var blackAndWhitePixelShader: {
  117158. name: string;
  117159. shader: string;
  117160. };
  117161. }
  117162. declare module BABYLON {
  117163. /**
  117164. * Post process used to render in black and white
  117165. */
  117166. export class BlackAndWhitePostProcess extends PostProcess {
  117167. /**
  117168. * Linear about to convert he result to black and white (default: 1)
  117169. */
  117170. degree: number;
  117171. /**
  117172. * Creates a black and white post process
  117173. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117174. * @param name The name of the effect.
  117175. * @param options The required width/height ratio to downsize to before computing the render pass.
  117176. * @param camera The camera to apply the render pass to.
  117177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117178. * @param engine The engine which the post process will be applied. (default: current engine)
  117179. * @param reusable If the post process can be reused on the same frame. (default: false)
  117180. */
  117181. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117182. }
  117183. }
  117184. declare module BABYLON {
  117185. /**
  117186. * This represents a set of one or more post processes in Babylon.
  117187. * A post process can be used to apply a shader to a texture after it is rendered.
  117188. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117189. */
  117190. export class PostProcessRenderEffect {
  117191. private _postProcesses;
  117192. private _getPostProcesses;
  117193. private _singleInstance;
  117194. private _cameras;
  117195. private _indicesForCamera;
  117196. /**
  117197. * Name of the effect
  117198. * @hidden
  117199. */
  117200. _name: string;
  117201. /**
  117202. * Instantiates a post process render effect.
  117203. * A post process can be used to apply a shader to a texture after it is rendered.
  117204. * @param engine The engine the effect is tied to
  117205. * @param name The name of the effect
  117206. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117207. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117208. */
  117209. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117210. /**
  117211. * Checks if all the post processes in the effect are supported.
  117212. */
  117213. readonly isSupported: boolean;
  117214. /**
  117215. * Updates the current state of the effect
  117216. * @hidden
  117217. */
  117218. _update(): void;
  117219. /**
  117220. * Attaches the effect on cameras
  117221. * @param cameras The camera to attach to.
  117222. * @hidden
  117223. */
  117224. _attachCameras(cameras: Camera): void;
  117225. /**
  117226. * Attaches the effect on cameras
  117227. * @param cameras The camera to attach to.
  117228. * @hidden
  117229. */
  117230. _attachCameras(cameras: Camera[]): void;
  117231. /**
  117232. * Detaches the effect on cameras
  117233. * @param cameras The camera to detatch from.
  117234. * @hidden
  117235. */
  117236. _detachCameras(cameras: Camera): void;
  117237. /**
  117238. * Detatches the effect on cameras
  117239. * @param cameras The camera to detatch from.
  117240. * @hidden
  117241. */
  117242. _detachCameras(cameras: Camera[]): void;
  117243. /**
  117244. * Enables the effect on given cameras
  117245. * @param cameras The camera to enable.
  117246. * @hidden
  117247. */
  117248. _enable(cameras: Camera): void;
  117249. /**
  117250. * Enables the effect on given cameras
  117251. * @param cameras The camera to enable.
  117252. * @hidden
  117253. */
  117254. _enable(cameras: Nullable<Camera[]>): void;
  117255. /**
  117256. * Disables the effect on the given cameras
  117257. * @param cameras The camera to disable.
  117258. * @hidden
  117259. */
  117260. _disable(cameras: Camera): void;
  117261. /**
  117262. * Disables the effect on the given cameras
  117263. * @param cameras The camera to disable.
  117264. * @hidden
  117265. */
  117266. _disable(cameras: Nullable<Camera[]>): void;
  117267. /**
  117268. * Gets a list of the post processes contained in the effect.
  117269. * @param camera The camera to get the post processes on.
  117270. * @returns The list of the post processes in the effect.
  117271. */
  117272. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  117273. }
  117274. }
  117275. declare module BABYLON {
  117276. /** @hidden */
  117277. export var extractHighlightsPixelShader: {
  117278. name: string;
  117279. shader: string;
  117280. };
  117281. }
  117282. declare module BABYLON {
  117283. /**
  117284. * 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.
  117285. */
  117286. export class ExtractHighlightsPostProcess extends PostProcess {
  117287. /**
  117288. * The luminance threshold, pixels below this value will be set to black.
  117289. */
  117290. threshold: number;
  117291. /** @hidden */
  117292. _exposure: number;
  117293. /**
  117294. * Post process which has the input texture to be used when performing highlight extraction
  117295. * @hidden
  117296. */
  117297. _inputPostProcess: Nullable<PostProcess>;
  117298. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117299. }
  117300. }
  117301. declare module BABYLON {
  117302. /** @hidden */
  117303. export var bloomMergePixelShader: {
  117304. name: string;
  117305. shader: string;
  117306. };
  117307. }
  117308. declare module BABYLON {
  117309. /**
  117310. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117311. */
  117312. export class BloomMergePostProcess extends PostProcess {
  117313. /** Weight of the bloom to be added to the original input. */
  117314. weight: number;
  117315. /**
  117316. * Creates a new instance of @see BloomMergePostProcess
  117317. * @param name The name of the effect.
  117318. * @param originalFromInput Post process which's input will be used for the merge.
  117319. * @param blurred Blurred highlights post process which's output will be used.
  117320. * @param weight Weight of the bloom to be added to the original input.
  117321. * @param options The required width/height ratio to downsize to before computing the render pass.
  117322. * @param camera The camera to apply the render pass to.
  117323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117324. * @param engine The engine which the post process will be applied. (default: current engine)
  117325. * @param reusable If the post process can be reused on the same frame. (default: false)
  117326. * @param textureType Type of textures used when performing the post process. (default: 0)
  117327. * @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)
  117328. */
  117329. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  117330. /** Weight of the bloom to be added to the original input. */
  117331. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117332. }
  117333. }
  117334. declare module BABYLON {
  117335. /**
  117336. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  117337. */
  117338. export class BloomEffect extends PostProcessRenderEffect {
  117339. private bloomScale;
  117340. /**
  117341. * @hidden Internal
  117342. */
  117343. _effects: Array<PostProcess>;
  117344. /**
  117345. * @hidden Internal
  117346. */
  117347. _downscale: ExtractHighlightsPostProcess;
  117348. private _blurX;
  117349. private _blurY;
  117350. private _merge;
  117351. /**
  117352. * The luminance threshold to find bright areas of the image to bloom.
  117353. */
  117354. threshold: number;
  117355. /**
  117356. * The strength of the bloom.
  117357. */
  117358. weight: number;
  117359. /**
  117360. * Specifies the size of the bloom blur kernel, relative to the final output size
  117361. */
  117362. kernel: number;
  117363. /**
  117364. * Creates a new instance of @see BloomEffect
  117365. * @param scene The scene the effect belongs to.
  117366. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  117367. * @param bloomKernel The size of the kernel to be used when applying the blur.
  117368. * @param bloomWeight The the strength of bloom.
  117369. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117370. * @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)
  117371. */
  117372. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  117373. /**
  117374. * Disposes each of the internal effects for a given camera.
  117375. * @param camera The camera to dispose the effect on.
  117376. */
  117377. disposeEffects(camera: Camera): void;
  117378. /**
  117379. * @hidden Internal
  117380. */
  117381. _updateEffects(): void;
  117382. /**
  117383. * Internal
  117384. * @returns if all the contained post processes are ready.
  117385. * @hidden
  117386. */
  117387. _isReady(): boolean;
  117388. }
  117389. }
  117390. declare module BABYLON {
  117391. /** @hidden */
  117392. export var chromaticAberrationPixelShader: {
  117393. name: string;
  117394. shader: string;
  117395. };
  117396. }
  117397. declare module BABYLON {
  117398. /**
  117399. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  117400. */
  117401. export class ChromaticAberrationPostProcess extends PostProcess {
  117402. /**
  117403. * The amount of seperation of rgb channels (default: 30)
  117404. */
  117405. aberrationAmount: number;
  117406. /**
  117407. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  117408. */
  117409. radialIntensity: number;
  117410. /**
  117411. * 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))
  117412. */
  117413. direction: Vector2;
  117414. /**
  117415. * 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))
  117416. */
  117417. centerPosition: Vector2;
  117418. /**
  117419. * Creates a new instance ChromaticAberrationPostProcess
  117420. * @param name The name of the effect.
  117421. * @param screenWidth The width of the screen to apply the effect on.
  117422. * @param screenHeight The height of the screen to apply the effect on.
  117423. * @param options The required width/height ratio to downsize to before computing the render pass.
  117424. * @param camera The camera to apply the render pass to.
  117425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117426. * @param engine The engine which the post process will be applied. (default: current engine)
  117427. * @param reusable If the post process can be reused on the same frame. (default: false)
  117428. * @param textureType Type of textures used when performing the post process. (default: 0)
  117429. * @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)
  117430. */
  117431. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117432. }
  117433. }
  117434. declare module BABYLON {
  117435. /** @hidden */
  117436. export var circleOfConfusionPixelShader: {
  117437. name: string;
  117438. shader: string;
  117439. };
  117440. }
  117441. declare module BABYLON {
  117442. /**
  117443. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  117444. */
  117445. export class CircleOfConfusionPostProcess extends PostProcess {
  117446. /**
  117447. * 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.
  117448. */
  117449. lensSize: number;
  117450. /**
  117451. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117452. */
  117453. fStop: number;
  117454. /**
  117455. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117456. */
  117457. focusDistance: number;
  117458. /**
  117459. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  117460. */
  117461. focalLength: number;
  117462. private _depthTexture;
  117463. /**
  117464. * Creates a new instance CircleOfConfusionPostProcess
  117465. * @param name The name of the effect.
  117466. * @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.
  117467. * @param options The required width/height ratio to downsize to before computing the render pass.
  117468. * @param camera The camera to apply the render pass to.
  117469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117470. * @param engine The engine which the post process will be applied. (default: current engine)
  117471. * @param reusable If the post process can be reused on the same frame. (default: false)
  117472. * @param textureType Type of textures used when performing the post process. (default: 0)
  117473. * @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)
  117474. */
  117475. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117476. /**
  117477. * 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.
  117478. */
  117479. depthTexture: RenderTargetTexture;
  117480. }
  117481. }
  117482. declare module BABYLON {
  117483. /** @hidden */
  117484. export var colorCorrectionPixelShader: {
  117485. name: string;
  117486. shader: string;
  117487. };
  117488. }
  117489. declare module BABYLON {
  117490. /**
  117491. *
  117492. * This post-process allows the modification of rendered colors by using
  117493. * a 'look-up table' (LUT). This effect is also called Color Grading.
  117494. *
  117495. * The object needs to be provided an url to a texture containing the color
  117496. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  117497. * Use an image editing software to tweak the LUT to match your needs.
  117498. *
  117499. * For an example of a color LUT, see here:
  117500. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  117501. * For explanations on color grading, see here:
  117502. * @see http://udn.epicgames.com/Three/ColorGrading.html
  117503. *
  117504. */
  117505. export class ColorCorrectionPostProcess extends PostProcess {
  117506. private _colorTableTexture;
  117507. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117508. }
  117509. }
  117510. declare module BABYLON {
  117511. /** @hidden */
  117512. export var convolutionPixelShader: {
  117513. name: string;
  117514. shader: string;
  117515. };
  117516. }
  117517. declare module BABYLON {
  117518. /**
  117519. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117520. * input texture to perform effects such as edge detection or sharpening
  117521. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117522. */
  117523. export class ConvolutionPostProcess extends PostProcess {
  117524. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  117525. kernel: number[];
  117526. /**
  117527. * Creates a new instance ConvolutionPostProcess
  117528. * @param name The name of the effect.
  117529. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  117530. * @param options The required width/height ratio to downsize to before computing the render pass.
  117531. * @param camera The camera to apply the render pass to.
  117532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117533. * @param engine The engine which the post process will be applied. (default: current engine)
  117534. * @param reusable If the post process can be reused on the same frame. (default: false)
  117535. * @param textureType Type of textures used when performing the post process. (default: 0)
  117536. */
  117537. constructor(name: string,
  117538. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  117539. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117540. /**
  117541. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117542. */
  117543. static EdgeDetect0Kernel: number[];
  117544. /**
  117545. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117546. */
  117547. static EdgeDetect1Kernel: number[];
  117548. /**
  117549. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117550. */
  117551. static EdgeDetect2Kernel: number[];
  117552. /**
  117553. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117554. */
  117555. static SharpenKernel: number[];
  117556. /**
  117557. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117558. */
  117559. static EmbossKernel: number[];
  117560. /**
  117561. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117562. */
  117563. static GaussianKernel: number[];
  117564. }
  117565. }
  117566. declare module BABYLON {
  117567. /**
  117568. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117569. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117570. * based on samples that have a large difference in distance than the center pixel.
  117571. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117572. */
  117573. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  117574. direction: Vector2;
  117575. /**
  117576. * Creates a new instance CircleOfConfusionPostProcess
  117577. * @param name The name of the effect.
  117578. * @param scene The scene the effect belongs to.
  117579. * @param direction The direction the blur should be applied.
  117580. * @param kernel The size of the kernel used to blur.
  117581. * @param options The required width/height ratio to downsize to before computing the render pass.
  117582. * @param camera The camera to apply the render pass to.
  117583. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117584. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117586. * @param engine The engine which the post process will be applied. (default: current engine)
  117587. * @param reusable If the post process can be reused on the same frame. (default: false)
  117588. * @param textureType Type of textures used when performing the post process. (default: 0)
  117589. * @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)
  117590. */
  117591. 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);
  117592. }
  117593. }
  117594. declare module BABYLON {
  117595. /** @hidden */
  117596. export var depthOfFieldMergePixelShader: {
  117597. name: string;
  117598. shader: string;
  117599. };
  117600. }
  117601. declare module BABYLON {
  117602. /**
  117603. * Options to be set when merging outputs from the default pipeline.
  117604. */
  117605. export class DepthOfFieldMergePostProcessOptions {
  117606. /**
  117607. * The original image to merge on top of
  117608. */
  117609. originalFromInput: PostProcess;
  117610. /**
  117611. * Parameters to perform the merge of the depth of field effect
  117612. */
  117613. depthOfField?: {
  117614. circleOfConfusion: PostProcess;
  117615. blurSteps: Array<PostProcess>;
  117616. };
  117617. /**
  117618. * Parameters to perform the merge of bloom effect
  117619. */
  117620. bloom?: {
  117621. blurred: PostProcess;
  117622. weight: number;
  117623. };
  117624. }
  117625. /**
  117626. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117627. */
  117628. export class DepthOfFieldMergePostProcess extends PostProcess {
  117629. private blurSteps;
  117630. /**
  117631. * Creates a new instance of DepthOfFieldMergePostProcess
  117632. * @param name The name of the effect.
  117633. * @param originalFromInput Post process which's input will be used for the merge.
  117634. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117635. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117636. * @param options The required width/height ratio to downsize to before computing the render pass.
  117637. * @param camera The camera to apply the render pass to.
  117638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117639. * @param engine The engine which the post process will be applied. (default: current engine)
  117640. * @param reusable If the post process can be reused on the same frame. (default: false)
  117641. * @param textureType Type of textures used when performing the post process. (default: 0)
  117642. * @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)
  117643. */
  117644. 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);
  117645. /**
  117646. * Updates the effect with the current post process compile time values and recompiles the shader.
  117647. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117648. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117649. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117650. * @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
  117651. * @param onCompiled Called when the shader has been compiled.
  117652. * @param onError Called if there is an error when compiling a shader.
  117653. */
  117654. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  117655. }
  117656. }
  117657. declare module BABYLON {
  117658. /**
  117659. * Specifies the level of max blur that should be applied when using the depth of field effect
  117660. */
  117661. export enum DepthOfFieldEffectBlurLevel {
  117662. /**
  117663. * Subtle blur
  117664. */
  117665. Low = 0,
  117666. /**
  117667. * Medium blur
  117668. */
  117669. Medium = 1,
  117670. /**
  117671. * Large blur
  117672. */
  117673. High = 2
  117674. }
  117675. /**
  117676. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117677. */
  117678. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  117679. private _circleOfConfusion;
  117680. /**
  117681. * @hidden Internal, blurs from high to low
  117682. */
  117683. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  117684. private _depthOfFieldBlurY;
  117685. private _dofMerge;
  117686. /**
  117687. * @hidden Internal post processes in depth of field effect
  117688. */
  117689. _effects: Array<PostProcess>;
  117690. /**
  117691. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117692. */
  117693. focalLength: number;
  117694. /**
  117695. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117696. */
  117697. fStop: number;
  117698. /**
  117699. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117700. */
  117701. focusDistance: number;
  117702. /**
  117703. * 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.
  117704. */
  117705. lensSize: number;
  117706. /**
  117707. * Creates a new instance DepthOfFieldEffect
  117708. * @param scene The scene the effect belongs to.
  117709. * @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.
  117710. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117711. * @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)
  117712. */
  117713. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  117714. /**
  117715. * Get the current class name of the current effet
  117716. * @returns "DepthOfFieldEffect"
  117717. */
  117718. getClassName(): string;
  117719. /**
  117720. * 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.
  117721. */
  117722. depthTexture: RenderTargetTexture;
  117723. /**
  117724. * Disposes each of the internal effects for a given camera.
  117725. * @param camera The camera to dispose the effect on.
  117726. */
  117727. disposeEffects(camera: Camera): void;
  117728. /**
  117729. * @hidden Internal
  117730. */
  117731. _updateEffects(): void;
  117732. /**
  117733. * Internal
  117734. * @returns if all the contained post processes are ready.
  117735. * @hidden
  117736. */
  117737. _isReady(): boolean;
  117738. }
  117739. }
  117740. declare module BABYLON {
  117741. /** @hidden */
  117742. export var displayPassPixelShader: {
  117743. name: string;
  117744. shader: string;
  117745. };
  117746. }
  117747. declare module BABYLON {
  117748. /**
  117749. * DisplayPassPostProcess which produces an output the same as it's input
  117750. */
  117751. export class DisplayPassPostProcess extends PostProcess {
  117752. /**
  117753. * Creates the DisplayPassPostProcess
  117754. * @param name The name of the effect.
  117755. * @param options The required width/height ratio to downsize to before computing the render pass.
  117756. * @param camera The camera to apply the render pass to.
  117757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117758. * @param engine The engine which the post process will be applied. (default: current engine)
  117759. * @param reusable If the post process can be reused on the same frame. (default: false)
  117760. */
  117761. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117762. }
  117763. }
  117764. declare module BABYLON {
  117765. /** @hidden */
  117766. export var filterPixelShader: {
  117767. name: string;
  117768. shader: string;
  117769. };
  117770. }
  117771. declare module BABYLON {
  117772. /**
  117773. * Applies a kernel filter to the image
  117774. */
  117775. export class FilterPostProcess extends PostProcess {
  117776. /** The matrix to be applied to the image */
  117777. kernelMatrix: Matrix;
  117778. /**
  117779. *
  117780. * @param name The name of the effect.
  117781. * @param kernelMatrix The matrix to be applied to the image
  117782. * @param options The required width/height ratio to downsize to before computing the render pass.
  117783. * @param camera The camera to apply the render pass to.
  117784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117785. * @param engine The engine which the post process will be applied. (default: current engine)
  117786. * @param reusable If the post process can be reused on the same frame. (default: false)
  117787. */
  117788. constructor(name: string,
  117789. /** The matrix to be applied to the image */
  117790. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117791. }
  117792. }
  117793. declare module BABYLON {
  117794. /** @hidden */
  117795. export var fxaaPixelShader: {
  117796. name: string;
  117797. shader: string;
  117798. };
  117799. }
  117800. declare module BABYLON {
  117801. /** @hidden */
  117802. export var fxaaVertexShader: {
  117803. name: string;
  117804. shader: string;
  117805. };
  117806. }
  117807. declare module BABYLON {
  117808. /**
  117809. * Fxaa post process
  117810. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117811. */
  117812. export class FxaaPostProcess extends PostProcess {
  117813. /** @hidden */
  117814. texelWidth: number;
  117815. /** @hidden */
  117816. texelHeight: number;
  117817. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117818. private _getDefines;
  117819. }
  117820. }
  117821. declare module BABYLON {
  117822. /** @hidden */
  117823. export var grainPixelShader: {
  117824. name: string;
  117825. shader: string;
  117826. };
  117827. }
  117828. declare module BABYLON {
  117829. /**
  117830. * The GrainPostProcess adds noise to the image at mid luminance levels
  117831. */
  117832. export class GrainPostProcess extends PostProcess {
  117833. /**
  117834. * The intensity of the grain added (default: 30)
  117835. */
  117836. intensity: number;
  117837. /**
  117838. * If the grain should be randomized on every frame
  117839. */
  117840. animated: boolean;
  117841. /**
  117842. * Creates a new instance of @see GrainPostProcess
  117843. * @param name The name of the effect.
  117844. * @param options The required width/height ratio to downsize to before computing the render pass.
  117845. * @param camera The camera to apply the render pass to.
  117846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117847. * @param engine The engine which the post process will be applied. (default: current engine)
  117848. * @param reusable If the post process can be reused on the same frame. (default: false)
  117849. * @param textureType Type of textures used when performing the post process. (default: 0)
  117850. * @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)
  117851. */
  117852. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117853. }
  117854. }
  117855. declare module BABYLON {
  117856. /** @hidden */
  117857. export var highlightsPixelShader: {
  117858. name: string;
  117859. shader: string;
  117860. };
  117861. }
  117862. declare module BABYLON {
  117863. /**
  117864. * Extracts highlights from the image
  117865. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117866. */
  117867. export class HighlightsPostProcess extends PostProcess {
  117868. /**
  117869. * Extracts highlights from the image
  117870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117871. * @param name The name of the effect.
  117872. * @param options The required width/height ratio to downsize to before computing the render pass.
  117873. * @param camera The camera to apply the render pass to.
  117874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117875. * @param engine The engine which the post process will be applied. (default: current engine)
  117876. * @param reusable If the post process can be reused on the same frame. (default: false)
  117877. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117878. */
  117879. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117880. }
  117881. }
  117882. declare module BABYLON {
  117883. /** @hidden */
  117884. export var mrtFragmentDeclaration: {
  117885. name: string;
  117886. shader: string;
  117887. };
  117888. }
  117889. declare module BABYLON {
  117890. /** @hidden */
  117891. export var geometryPixelShader: {
  117892. name: string;
  117893. shader: string;
  117894. };
  117895. }
  117896. declare module BABYLON {
  117897. /** @hidden */
  117898. export var geometryVertexShader: {
  117899. name: string;
  117900. shader: string;
  117901. };
  117902. }
  117903. declare module BABYLON {
  117904. /** @hidden */
  117905. interface ISavedTransformationMatrix {
  117906. world: Matrix;
  117907. viewProjection: Matrix;
  117908. }
  117909. /**
  117910. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  117911. */
  117912. export class GeometryBufferRenderer {
  117913. /**
  117914. * Constant used to retrieve the position texture index in the G-Buffer textures array
  117915. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  117916. */
  117917. static readonly POSITION_TEXTURE_TYPE: number;
  117918. /**
  117919. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  117920. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  117921. */
  117922. static readonly VELOCITY_TEXTURE_TYPE: number;
  117923. /**
  117924. * Dictionary used to store the previous transformation matrices of each rendered mesh
  117925. * in order to compute objects velocities when enableVelocity is set to "true"
  117926. * @hidden
  117927. */
  117928. _previousTransformationMatrices: {
  117929. [index: number]: ISavedTransformationMatrix;
  117930. };
  117931. /**
  117932. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  117933. * in order to compute objects velocities when enableVelocity is set to "true"
  117934. * @hidden
  117935. */
  117936. _previousBonesTransformationMatrices: {
  117937. [index: number]: Float32Array;
  117938. };
  117939. /**
  117940. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  117941. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  117942. */
  117943. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  117944. private _scene;
  117945. private _multiRenderTarget;
  117946. private _ratio;
  117947. private _enablePosition;
  117948. private _enableVelocity;
  117949. private _positionIndex;
  117950. private _velocityIndex;
  117951. protected _effect: Effect;
  117952. protected _cachedDefines: string;
  117953. /**
  117954. * Set the render list (meshes to be rendered) used in the G buffer.
  117955. */
  117956. renderList: Mesh[];
  117957. /**
  117958. * Gets wether or not G buffer are supported by the running hardware.
  117959. * This requires draw buffer supports
  117960. */
  117961. readonly isSupported: boolean;
  117962. /**
  117963. * Returns the index of the given texture type in the G-Buffer textures array
  117964. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  117965. * @returns the index of the given texture type in the G-Buffer textures array
  117966. */
  117967. getTextureIndex(textureType: number): number;
  117968. /**
  117969. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  117970. */
  117971. /**
  117972. * Sets whether or not objects positions are enabled for the G buffer.
  117973. */
  117974. enablePosition: boolean;
  117975. /**
  117976. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  117977. */
  117978. /**
  117979. * Sets wether or not objects velocities are enabled for the G buffer.
  117980. */
  117981. enableVelocity: boolean;
  117982. /**
  117983. * Gets the scene associated with the buffer.
  117984. */
  117985. readonly scene: Scene;
  117986. /**
  117987. * Gets the ratio used by the buffer during its creation.
  117988. * How big is the buffer related to the main canvas.
  117989. */
  117990. readonly ratio: number;
  117991. /** @hidden */
  117992. static _SceneComponentInitialization: (scene: Scene) => void;
  117993. /**
  117994. * Creates a new G Buffer for the scene
  117995. * @param scene The scene the buffer belongs to
  117996. * @param ratio How big is the buffer related to the main canvas.
  117997. */
  117998. constructor(scene: Scene, ratio?: number);
  117999. /**
  118000. * Checks wether everything is ready to render a submesh to the G buffer.
  118001. * @param subMesh the submesh to check readiness for
  118002. * @param useInstances is the mesh drawn using instance or not
  118003. * @returns true if ready otherwise false
  118004. */
  118005. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118006. /**
  118007. * Gets the current underlying G Buffer.
  118008. * @returns the buffer
  118009. */
  118010. getGBuffer(): MultiRenderTarget;
  118011. /**
  118012. * Gets the number of samples used to render the buffer (anti aliasing).
  118013. */
  118014. /**
  118015. * Sets the number of samples used to render the buffer (anti aliasing).
  118016. */
  118017. samples: number;
  118018. /**
  118019. * Disposes the renderer and frees up associated resources.
  118020. */
  118021. dispose(): void;
  118022. protected _createRenderTargets(): void;
  118023. private _copyBonesTransformationMatrices;
  118024. }
  118025. }
  118026. declare module BABYLON {
  118027. interface Scene {
  118028. /** @hidden (Backing field) */
  118029. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118030. /**
  118031. * Gets or Sets the current geometry buffer associated to the scene.
  118032. */
  118033. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118034. /**
  118035. * Enables a GeometryBufferRender and associates it with the scene
  118036. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118037. * @returns the GeometryBufferRenderer
  118038. */
  118039. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118040. /**
  118041. * Disables the GeometryBufferRender associated with the scene
  118042. */
  118043. disableGeometryBufferRenderer(): void;
  118044. }
  118045. /**
  118046. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118047. * in several rendering techniques.
  118048. */
  118049. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118050. /**
  118051. * The component name helpful to identify the component in the list of scene components.
  118052. */
  118053. readonly name: string;
  118054. /**
  118055. * The scene the component belongs to.
  118056. */
  118057. scene: Scene;
  118058. /**
  118059. * Creates a new instance of the component for the given scene
  118060. * @param scene Defines the scene to register the component in
  118061. */
  118062. constructor(scene: Scene);
  118063. /**
  118064. * Registers the component in a given scene
  118065. */
  118066. register(): void;
  118067. /**
  118068. * Rebuilds the elements related to this component in case of
  118069. * context lost for instance.
  118070. */
  118071. rebuild(): void;
  118072. /**
  118073. * Disposes the component and the associated ressources
  118074. */
  118075. dispose(): void;
  118076. private _gatherRenderTargets;
  118077. }
  118078. }
  118079. declare module BABYLON {
  118080. /** @hidden */
  118081. export var motionBlurPixelShader: {
  118082. name: string;
  118083. shader: string;
  118084. };
  118085. }
  118086. declare module BABYLON {
  118087. /**
  118088. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118089. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118090. * As an example, all you have to do is to create the post-process:
  118091. * var mb = new BABYLON.MotionBlurPostProcess(
  118092. * 'mb', // The name of the effect.
  118093. * scene, // The scene containing the objects to blur according to their velocity.
  118094. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118095. * camera // The camera to apply the render pass to.
  118096. * );
  118097. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118098. */
  118099. export class MotionBlurPostProcess extends PostProcess {
  118100. /**
  118101. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118102. */
  118103. motionStrength: number;
  118104. /**
  118105. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118106. */
  118107. /**
  118108. * Sets the number of iterations to be used for motion blur quality
  118109. */
  118110. motionBlurSamples: number;
  118111. private _motionBlurSamples;
  118112. private _geometryBufferRenderer;
  118113. /**
  118114. * Creates a new instance MotionBlurPostProcess
  118115. * @param name The name of the effect.
  118116. * @param scene The scene containing the objects to blur according to their velocity.
  118117. * @param options The required width/height ratio to downsize to before computing the render pass.
  118118. * @param camera The camera to apply the render pass to.
  118119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118120. * @param engine The engine which the post process will be applied. (default: current engine)
  118121. * @param reusable If the post process can be reused on the same frame. (default: false)
  118122. * @param textureType Type of textures used when performing the post process. (default: 0)
  118123. * @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)
  118124. */
  118125. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118126. /**
  118127. * Excludes the given skinned mesh from computing bones velocities.
  118128. * 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.
  118129. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118130. */
  118131. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118132. /**
  118133. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118134. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118135. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118136. */
  118137. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118138. /**
  118139. * Disposes the post process.
  118140. * @param camera The camera to dispose the post process on.
  118141. */
  118142. dispose(camera?: Camera): void;
  118143. }
  118144. }
  118145. declare module BABYLON {
  118146. /** @hidden */
  118147. export var refractionPixelShader: {
  118148. name: string;
  118149. shader: string;
  118150. };
  118151. }
  118152. declare module BABYLON {
  118153. /**
  118154. * Post process which applies a refractin texture
  118155. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118156. */
  118157. export class RefractionPostProcess extends PostProcess {
  118158. /** the base color of the refraction (used to taint the rendering) */
  118159. color: Color3;
  118160. /** simulated refraction depth */
  118161. depth: number;
  118162. /** the coefficient of the base color (0 to remove base color tainting) */
  118163. colorLevel: number;
  118164. private _refTexture;
  118165. private _ownRefractionTexture;
  118166. /**
  118167. * Gets or sets the refraction texture
  118168. * Please note that you are responsible for disposing the texture if you set it manually
  118169. */
  118170. refractionTexture: Texture;
  118171. /**
  118172. * Initializes the RefractionPostProcess
  118173. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118174. * @param name The name of the effect.
  118175. * @param refractionTextureUrl Url of the refraction texture to use
  118176. * @param color the base color of the refraction (used to taint the rendering)
  118177. * @param depth simulated refraction depth
  118178. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118179. * @param camera The camera to apply the render pass to.
  118180. * @param options The required width/height ratio to downsize to before computing the render pass.
  118181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118182. * @param engine The engine which the post process will be applied. (default: current engine)
  118183. * @param reusable If the post process can be reused on the same frame. (default: false)
  118184. */
  118185. constructor(name: string, refractionTextureUrl: string,
  118186. /** the base color of the refraction (used to taint the rendering) */
  118187. color: Color3,
  118188. /** simulated refraction depth */
  118189. depth: number,
  118190. /** the coefficient of the base color (0 to remove base color tainting) */
  118191. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118192. /**
  118193. * Disposes of the post process
  118194. * @param camera Camera to dispose post process on
  118195. */
  118196. dispose(camera: Camera): void;
  118197. }
  118198. }
  118199. declare module BABYLON {
  118200. /** @hidden */
  118201. export var sharpenPixelShader: {
  118202. name: string;
  118203. shader: string;
  118204. };
  118205. }
  118206. declare module BABYLON {
  118207. /**
  118208. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118209. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118210. */
  118211. export class SharpenPostProcess extends PostProcess {
  118212. /**
  118213. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118214. */
  118215. colorAmount: number;
  118216. /**
  118217. * How much sharpness should be applied (default: 0.3)
  118218. */
  118219. edgeAmount: number;
  118220. /**
  118221. * Creates a new instance ConvolutionPostProcess
  118222. * @param name The name of the effect.
  118223. * @param options The required width/height ratio to downsize to before computing the render pass.
  118224. * @param camera The camera to apply the render pass to.
  118225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118226. * @param engine The engine which the post process will be applied. (default: current engine)
  118227. * @param reusable If the post process can be reused on the same frame. (default: false)
  118228. * @param textureType Type of textures used when performing the post process. (default: 0)
  118229. * @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)
  118230. */
  118231. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118232. }
  118233. }
  118234. declare module BABYLON {
  118235. /**
  118236. * PostProcessRenderPipeline
  118237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118238. */
  118239. export class PostProcessRenderPipeline {
  118240. private engine;
  118241. private _renderEffects;
  118242. private _renderEffectsForIsolatedPass;
  118243. /**
  118244. * List of inspectable custom properties (used by the Inspector)
  118245. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118246. */
  118247. inspectableCustomProperties: IInspectable[];
  118248. /**
  118249. * @hidden
  118250. */
  118251. protected _cameras: Camera[];
  118252. /** @hidden */
  118253. _name: string;
  118254. /**
  118255. * Gets pipeline name
  118256. */
  118257. readonly name: string;
  118258. /**
  118259. * Initializes a PostProcessRenderPipeline
  118260. * @param engine engine to add the pipeline to
  118261. * @param name name of the pipeline
  118262. */
  118263. constructor(engine: Engine, name: string);
  118264. /**
  118265. * Gets the class name
  118266. * @returns "PostProcessRenderPipeline"
  118267. */
  118268. getClassName(): string;
  118269. /**
  118270. * If all the render effects in the pipeline are supported
  118271. */
  118272. readonly isSupported: boolean;
  118273. /**
  118274. * Adds an effect to the pipeline
  118275. * @param renderEffect the effect to add
  118276. */
  118277. addEffect(renderEffect: PostProcessRenderEffect): void;
  118278. /** @hidden */
  118279. _rebuild(): void;
  118280. /** @hidden */
  118281. _enableEffect(renderEffectName: string, cameras: Camera): void;
  118282. /** @hidden */
  118283. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  118284. /** @hidden */
  118285. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118286. /** @hidden */
  118287. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118288. /** @hidden */
  118289. _attachCameras(cameras: Camera, unique: boolean): void;
  118290. /** @hidden */
  118291. _attachCameras(cameras: Camera[], unique: boolean): void;
  118292. /** @hidden */
  118293. _detachCameras(cameras: Camera): void;
  118294. /** @hidden */
  118295. _detachCameras(cameras: Nullable<Camera[]>): void;
  118296. /** @hidden */
  118297. _update(): void;
  118298. /** @hidden */
  118299. _reset(): void;
  118300. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  118301. /**
  118302. * Disposes of the pipeline
  118303. */
  118304. dispose(): void;
  118305. }
  118306. }
  118307. declare module BABYLON {
  118308. /**
  118309. * PostProcessRenderPipelineManager class
  118310. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118311. */
  118312. export class PostProcessRenderPipelineManager {
  118313. private _renderPipelines;
  118314. /**
  118315. * Initializes a PostProcessRenderPipelineManager
  118316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118317. */
  118318. constructor();
  118319. /**
  118320. * Gets the list of supported render pipelines
  118321. */
  118322. readonly supportedPipelines: PostProcessRenderPipeline[];
  118323. /**
  118324. * Adds a pipeline to the manager
  118325. * @param renderPipeline The pipeline to add
  118326. */
  118327. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  118328. /**
  118329. * Attaches a camera to the pipeline
  118330. * @param renderPipelineName The name of the pipeline to attach to
  118331. * @param cameras the camera to attach
  118332. * @param unique if the camera can be attached multiple times to the pipeline
  118333. */
  118334. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  118335. /**
  118336. * Detaches a camera from the pipeline
  118337. * @param renderPipelineName The name of the pipeline to detach from
  118338. * @param cameras the camera to detach
  118339. */
  118340. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  118341. /**
  118342. * Enables an effect by name on a pipeline
  118343. * @param renderPipelineName the name of the pipeline to enable the effect in
  118344. * @param renderEffectName the name of the effect to enable
  118345. * @param cameras the cameras that the effect should be enabled on
  118346. */
  118347. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118348. /**
  118349. * Disables an effect by name on a pipeline
  118350. * @param renderPipelineName the name of the pipeline to disable the effect in
  118351. * @param renderEffectName the name of the effect to disable
  118352. * @param cameras the cameras that the effect should be disabled on
  118353. */
  118354. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118355. /**
  118356. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  118357. */
  118358. update(): void;
  118359. /** @hidden */
  118360. _rebuild(): void;
  118361. /**
  118362. * Disposes of the manager and pipelines
  118363. */
  118364. dispose(): void;
  118365. }
  118366. }
  118367. declare module BABYLON {
  118368. interface Scene {
  118369. /** @hidden (Backing field) */
  118370. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118371. /**
  118372. * Gets the postprocess render pipeline manager
  118373. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118374. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118375. */
  118376. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118377. }
  118378. /**
  118379. * Defines the Render Pipeline scene component responsible to rendering pipelines
  118380. */
  118381. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  118382. /**
  118383. * The component name helpfull to identify the component in the list of scene components.
  118384. */
  118385. readonly name: string;
  118386. /**
  118387. * The scene the component belongs to.
  118388. */
  118389. scene: Scene;
  118390. /**
  118391. * Creates a new instance of the component for the given scene
  118392. * @param scene Defines the scene to register the component in
  118393. */
  118394. constructor(scene: Scene);
  118395. /**
  118396. * Registers the component in a given scene
  118397. */
  118398. register(): void;
  118399. /**
  118400. * Rebuilds the elements related to this component in case of
  118401. * context lost for instance.
  118402. */
  118403. rebuild(): void;
  118404. /**
  118405. * Disposes the component and the associated ressources
  118406. */
  118407. dispose(): void;
  118408. private _gatherRenderTargets;
  118409. }
  118410. }
  118411. declare module BABYLON {
  118412. /**
  118413. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118414. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118415. */
  118416. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118417. private _scene;
  118418. private _camerasToBeAttached;
  118419. /**
  118420. * ID of the sharpen post process,
  118421. */
  118422. private readonly SharpenPostProcessId;
  118423. /**
  118424. * @ignore
  118425. * ID of the image processing post process;
  118426. */
  118427. readonly ImageProcessingPostProcessId: string;
  118428. /**
  118429. * @ignore
  118430. * ID of the Fast Approximate Anti-Aliasing post process;
  118431. */
  118432. readonly FxaaPostProcessId: string;
  118433. /**
  118434. * ID of the chromatic aberration post process,
  118435. */
  118436. private readonly ChromaticAberrationPostProcessId;
  118437. /**
  118438. * ID of the grain post process
  118439. */
  118440. private readonly GrainPostProcessId;
  118441. /**
  118442. * Sharpen post process which will apply a sharpen convolution to enhance edges
  118443. */
  118444. sharpen: SharpenPostProcess;
  118445. private _sharpenEffect;
  118446. private bloom;
  118447. /**
  118448. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  118449. */
  118450. depthOfField: DepthOfFieldEffect;
  118451. /**
  118452. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118453. */
  118454. fxaa: FxaaPostProcess;
  118455. /**
  118456. * Image post processing pass used to perform operations such as tone mapping or color grading.
  118457. */
  118458. imageProcessing: ImageProcessingPostProcess;
  118459. /**
  118460. * Chromatic aberration post process which will shift rgb colors in the image
  118461. */
  118462. chromaticAberration: ChromaticAberrationPostProcess;
  118463. private _chromaticAberrationEffect;
  118464. /**
  118465. * Grain post process which add noise to the image
  118466. */
  118467. grain: GrainPostProcess;
  118468. private _grainEffect;
  118469. /**
  118470. * Glow post process which adds a glow to emissive areas of the image
  118471. */
  118472. private _glowLayer;
  118473. /**
  118474. * Animations which can be used to tweak settings over a period of time
  118475. */
  118476. animations: Animation[];
  118477. private _imageProcessingConfigurationObserver;
  118478. private _sharpenEnabled;
  118479. private _bloomEnabled;
  118480. private _depthOfFieldEnabled;
  118481. private _depthOfFieldBlurLevel;
  118482. private _fxaaEnabled;
  118483. private _imageProcessingEnabled;
  118484. private _defaultPipelineTextureType;
  118485. private _bloomScale;
  118486. private _chromaticAberrationEnabled;
  118487. private _grainEnabled;
  118488. private _buildAllowed;
  118489. /**
  118490. * Gets active scene
  118491. */
  118492. readonly scene: Scene;
  118493. /**
  118494. * Enable or disable the sharpen process from the pipeline
  118495. */
  118496. sharpenEnabled: boolean;
  118497. private _resizeObserver;
  118498. private _hardwareScaleLevel;
  118499. private _bloomKernel;
  118500. /**
  118501. * Specifies the size of the bloom blur kernel, relative to the final output size
  118502. */
  118503. bloomKernel: number;
  118504. /**
  118505. * Specifies the weight of the bloom in the final rendering
  118506. */
  118507. private _bloomWeight;
  118508. /**
  118509. * Specifies the luma threshold for the area that will be blurred by the bloom
  118510. */
  118511. private _bloomThreshold;
  118512. private _hdr;
  118513. /**
  118514. * The strength of the bloom.
  118515. */
  118516. bloomWeight: number;
  118517. /**
  118518. * The strength of the bloom.
  118519. */
  118520. bloomThreshold: number;
  118521. /**
  118522. * The scale of the bloom, lower value will provide better performance.
  118523. */
  118524. bloomScale: number;
  118525. /**
  118526. * Enable or disable the bloom from the pipeline
  118527. */
  118528. bloomEnabled: boolean;
  118529. private _rebuildBloom;
  118530. /**
  118531. * If the depth of field is enabled.
  118532. */
  118533. depthOfFieldEnabled: boolean;
  118534. /**
  118535. * Blur level of the depth of field effect. (Higher blur will effect performance)
  118536. */
  118537. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  118538. /**
  118539. * If the anti aliasing is enabled.
  118540. */
  118541. fxaaEnabled: boolean;
  118542. private _samples;
  118543. /**
  118544. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118545. */
  118546. samples: number;
  118547. /**
  118548. * If image processing is enabled.
  118549. */
  118550. imageProcessingEnabled: boolean;
  118551. /**
  118552. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  118553. */
  118554. glowLayerEnabled: boolean;
  118555. /**
  118556. * Gets the glow layer (or null if not defined)
  118557. */
  118558. readonly glowLayer: Nullable<GlowLayer>;
  118559. /**
  118560. * Enable or disable the chromaticAberration process from the pipeline
  118561. */
  118562. chromaticAberrationEnabled: boolean;
  118563. /**
  118564. * Enable or disable the grain process from the pipeline
  118565. */
  118566. grainEnabled: boolean;
  118567. /**
  118568. * @constructor
  118569. * @param name - The rendering pipeline name (default: "")
  118570. * @param hdr - If high dynamic range textures should be used (default: true)
  118571. * @param scene - The scene linked to this pipeline (default: the last created scene)
  118572. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  118573. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  118574. */
  118575. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  118576. /**
  118577. * Get the class name
  118578. * @returns "DefaultRenderingPipeline"
  118579. */
  118580. getClassName(): string;
  118581. /**
  118582. * Force the compilation of the entire pipeline.
  118583. */
  118584. prepare(): void;
  118585. private _hasCleared;
  118586. private _prevPostProcess;
  118587. private _prevPrevPostProcess;
  118588. private _setAutoClearAndTextureSharing;
  118589. private _depthOfFieldSceneObserver;
  118590. private _buildPipeline;
  118591. private _disposePostProcesses;
  118592. /**
  118593. * Adds a camera to the pipeline
  118594. * @param camera the camera to be added
  118595. */
  118596. addCamera(camera: Camera): void;
  118597. /**
  118598. * Removes a camera from the pipeline
  118599. * @param camera the camera to remove
  118600. */
  118601. removeCamera(camera: Camera): void;
  118602. /**
  118603. * Dispose of the pipeline and stop all post processes
  118604. */
  118605. dispose(): void;
  118606. /**
  118607. * Serialize the rendering pipeline (Used when exporting)
  118608. * @returns the serialized object
  118609. */
  118610. serialize(): any;
  118611. /**
  118612. * Parse the serialized pipeline
  118613. * @param source Source pipeline.
  118614. * @param scene The scene to load the pipeline to.
  118615. * @param rootUrl The URL of the serialized pipeline.
  118616. * @returns An instantiated pipeline from the serialized object.
  118617. */
  118618. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  118619. }
  118620. }
  118621. declare module BABYLON {
  118622. /** @hidden */
  118623. export var lensHighlightsPixelShader: {
  118624. name: string;
  118625. shader: string;
  118626. };
  118627. }
  118628. declare module BABYLON {
  118629. /** @hidden */
  118630. export var depthOfFieldPixelShader: {
  118631. name: string;
  118632. shader: string;
  118633. };
  118634. }
  118635. declare module BABYLON {
  118636. /**
  118637. * BABYLON.JS Chromatic Aberration GLSL Shader
  118638. * Author: Olivier Guyot
  118639. * Separates very slightly R, G and B colors on the edges of the screen
  118640. * Inspired by Francois Tarlier & Martins Upitis
  118641. */
  118642. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  118643. /**
  118644. * @ignore
  118645. * The chromatic aberration PostProcess id in the pipeline
  118646. */
  118647. LensChromaticAberrationEffect: string;
  118648. /**
  118649. * @ignore
  118650. * The highlights enhancing PostProcess id in the pipeline
  118651. */
  118652. HighlightsEnhancingEffect: string;
  118653. /**
  118654. * @ignore
  118655. * The depth-of-field PostProcess id in the pipeline
  118656. */
  118657. LensDepthOfFieldEffect: string;
  118658. private _scene;
  118659. private _depthTexture;
  118660. private _grainTexture;
  118661. private _chromaticAberrationPostProcess;
  118662. private _highlightsPostProcess;
  118663. private _depthOfFieldPostProcess;
  118664. private _edgeBlur;
  118665. private _grainAmount;
  118666. private _chromaticAberration;
  118667. private _distortion;
  118668. private _highlightsGain;
  118669. private _highlightsThreshold;
  118670. private _dofDistance;
  118671. private _dofAperture;
  118672. private _dofDarken;
  118673. private _dofPentagon;
  118674. private _blurNoise;
  118675. /**
  118676. * @constructor
  118677. *
  118678. * Effect parameters are as follow:
  118679. * {
  118680. * chromatic_aberration: number; // from 0 to x (1 for realism)
  118681. * edge_blur: number; // from 0 to x (1 for realism)
  118682. * distortion: number; // from 0 to x (1 for realism)
  118683. * grain_amount: number; // from 0 to 1
  118684. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  118685. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  118686. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  118687. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  118688. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  118689. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  118690. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  118691. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  118692. * }
  118693. * Note: if an effect parameter is unset, effect is disabled
  118694. *
  118695. * @param name The rendering pipeline name
  118696. * @param parameters - An object containing all parameters (see above)
  118697. * @param scene The scene linked to this pipeline
  118698. * @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)
  118699. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118700. */
  118701. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  118702. /**
  118703. * Get the class name
  118704. * @returns "LensRenderingPipeline"
  118705. */
  118706. getClassName(): string;
  118707. /**
  118708. * Gets associated scene
  118709. */
  118710. readonly scene: Scene;
  118711. /**
  118712. * Gets or sets the edge blur
  118713. */
  118714. edgeBlur: number;
  118715. /**
  118716. * Gets or sets the grain amount
  118717. */
  118718. grainAmount: number;
  118719. /**
  118720. * Gets or sets the chromatic aberration amount
  118721. */
  118722. chromaticAberration: number;
  118723. /**
  118724. * Gets or sets the depth of field aperture
  118725. */
  118726. dofAperture: number;
  118727. /**
  118728. * Gets or sets the edge distortion
  118729. */
  118730. edgeDistortion: number;
  118731. /**
  118732. * Gets or sets the depth of field distortion
  118733. */
  118734. dofDistortion: number;
  118735. /**
  118736. * Gets or sets the darken out of focus amount
  118737. */
  118738. darkenOutOfFocus: number;
  118739. /**
  118740. * Gets or sets a boolean indicating if blur noise is enabled
  118741. */
  118742. blurNoise: boolean;
  118743. /**
  118744. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  118745. */
  118746. pentagonBokeh: boolean;
  118747. /**
  118748. * Gets or sets the highlight grain amount
  118749. */
  118750. highlightsGain: number;
  118751. /**
  118752. * Gets or sets the highlight threshold
  118753. */
  118754. highlightsThreshold: number;
  118755. /**
  118756. * Sets the amount of blur at the edges
  118757. * @param amount blur amount
  118758. */
  118759. setEdgeBlur(amount: number): void;
  118760. /**
  118761. * Sets edge blur to 0
  118762. */
  118763. disableEdgeBlur(): void;
  118764. /**
  118765. * Sets the amout of grain
  118766. * @param amount Amount of grain
  118767. */
  118768. setGrainAmount(amount: number): void;
  118769. /**
  118770. * Set grain amount to 0
  118771. */
  118772. disableGrain(): void;
  118773. /**
  118774. * Sets the chromatic aberration amount
  118775. * @param amount amount of chromatic aberration
  118776. */
  118777. setChromaticAberration(amount: number): void;
  118778. /**
  118779. * Sets chromatic aberration amount to 0
  118780. */
  118781. disableChromaticAberration(): void;
  118782. /**
  118783. * Sets the EdgeDistortion amount
  118784. * @param amount amount of EdgeDistortion
  118785. */
  118786. setEdgeDistortion(amount: number): void;
  118787. /**
  118788. * Sets edge distortion to 0
  118789. */
  118790. disableEdgeDistortion(): void;
  118791. /**
  118792. * Sets the FocusDistance amount
  118793. * @param amount amount of FocusDistance
  118794. */
  118795. setFocusDistance(amount: number): void;
  118796. /**
  118797. * Disables depth of field
  118798. */
  118799. disableDepthOfField(): void;
  118800. /**
  118801. * Sets the Aperture amount
  118802. * @param amount amount of Aperture
  118803. */
  118804. setAperture(amount: number): void;
  118805. /**
  118806. * Sets the DarkenOutOfFocus amount
  118807. * @param amount amount of DarkenOutOfFocus
  118808. */
  118809. setDarkenOutOfFocus(amount: number): void;
  118810. private _pentagonBokehIsEnabled;
  118811. /**
  118812. * Creates a pentagon bokeh effect
  118813. */
  118814. enablePentagonBokeh(): void;
  118815. /**
  118816. * Disables the pentagon bokeh effect
  118817. */
  118818. disablePentagonBokeh(): void;
  118819. /**
  118820. * Enables noise blur
  118821. */
  118822. enableNoiseBlur(): void;
  118823. /**
  118824. * Disables noise blur
  118825. */
  118826. disableNoiseBlur(): void;
  118827. /**
  118828. * Sets the HighlightsGain amount
  118829. * @param amount amount of HighlightsGain
  118830. */
  118831. setHighlightsGain(amount: number): void;
  118832. /**
  118833. * Sets the HighlightsThreshold amount
  118834. * @param amount amount of HighlightsThreshold
  118835. */
  118836. setHighlightsThreshold(amount: number): void;
  118837. /**
  118838. * Disables highlights
  118839. */
  118840. disableHighlights(): void;
  118841. /**
  118842. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  118843. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  118844. */
  118845. dispose(disableDepthRender?: boolean): void;
  118846. private _createChromaticAberrationPostProcess;
  118847. private _createHighlightsPostProcess;
  118848. private _createDepthOfFieldPostProcess;
  118849. private _createGrainTexture;
  118850. }
  118851. }
  118852. declare module BABYLON {
  118853. /** @hidden */
  118854. export var ssao2PixelShader: {
  118855. name: string;
  118856. shader: string;
  118857. };
  118858. }
  118859. declare module BABYLON {
  118860. /** @hidden */
  118861. export var ssaoCombinePixelShader: {
  118862. name: string;
  118863. shader: string;
  118864. };
  118865. }
  118866. declare module BABYLON {
  118867. /**
  118868. * Render pipeline to produce ssao effect
  118869. */
  118870. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  118871. /**
  118872. * @ignore
  118873. * The PassPostProcess id in the pipeline that contains the original scene color
  118874. */
  118875. SSAOOriginalSceneColorEffect: string;
  118876. /**
  118877. * @ignore
  118878. * The SSAO PostProcess id in the pipeline
  118879. */
  118880. SSAORenderEffect: string;
  118881. /**
  118882. * @ignore
  118883. * The horizontal blur PostProcess id in the pipeline
  118884. */
  118885. SSAOBlurHRenderEffect: string;
  118886. /**
  118887. * @ignore
  118888. * The vertical blur PostProcess id in the pipeline
  118889. */
  118890. SSAOBlurVRenderEffect: string;
  118891. /**
  118892. * @ignore
  118893. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118894. */
  118895. SSAOCombineRenderEffect: string;
  118896. /**
  118897. * The output strength of the SSAO post-process. Default value is 1.0.
  118898. */
  118899. totalStrength: number;
  118900. /**
  118901. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  118902. */
  118903. maxZ: number;
  118904. /**
  118905. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  118906. */
  118907. minZAspect: number;
  118908. private _samples;
  118909. /**
  118910. * Number of samples used for the SSAO calculations. Default value is 8
  118911. */
  118912. samples: number;
  118913. private _textureSamples;
  118914. /**
  118915. * Number of samples to use for antialiasing
  118916. */
  118917. textureSamples: number;
  118918. /**
  118919. * Ratio object used for SSAO ratio and blur ratio
  118920. */
  118921. private _ratio;
  118922. /**
  118923. * Dynamically generated sphere sampler.
  118924. */
  118925. private _sampleSphere;
  118926. /**
  118927. * Blur filter offsets
  118928. */
  118929. private _samplerOffsets;
  118930. private _expensiveBlur;
  118931. /**
  118932. * If bilateral blur should be used
  118933. */
  118934. expensiveBlur: boolean;
  118935. /**
  118936. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  118937. */
  118938. radius: number;
  118939. /**
  118940. * The base color of the SSAO post-process
  118941. * The final result is "base + ssao" between [0, 1]
  118942. */
  118943. base: number;
  118944. /**
  118945. * Support test.
  118946. */
  118947. static readonly IsSupported: boolean;
  118948. private _scene;
  118949. private _depthTexture;
  118950. private _normalTexture;
  118951. private _randomTexture;
  118952. private _originalColorPostProcess;
  118953. private _ssaoPostProcess;
  118954. private _blurHPostProcess;
  118955. private _blurVPostProcess;
  118956. private _ssaoCombinePostProcess;
  118957. private _firstUpdate;
  118958. /**
  118959. * Gets active scene
  118960. */
  118961. readonly scene: Scene;
  118962. /**
  118963. * @constructor
  118964. * @param name The rendering pipeline name
  118965. * @param scene The scene linked to this pipeline
  118966. * @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 }
  118967. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118968. */
  118969. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  118970. /**
  118971. * Get the class name
  118972. * @returns "SSAO2RenderingPipeline"
  118973. */
  118974. getClassName(): string;
  118975. /**
  118976. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118977. */
  118978. dispose(disableGeometryBufferRenderer?: boolean): void;
  118979. private _createBlurPostProcess;
  118980. /** @hidden */
  118981. _rebuild(): void;
  118982. private _bits;
  118983. private _radicalInverse_VdC;
  118984. private _hammersley;
  118985. private _hemisphereSample_uniform;
  118986. private _generateHemisphere;
  118987. private _createSSAOPostProcess;
  118988. private _createSSAOCombinePostProcess;
  118989. private _createRandomTexture;
  118990. /**
  118991. * Serialize the rendering pipeline (Used when exporting)
  118992. * @returns the serialized object
  118993. */
  118994. serialize(): any;
  118995. /**
  118996. * Parse the serialized pipeline
  118997. * @param source Source pipeline.
  118998. * @param scene The scene to load the pipeline to.
  118999. * @param rootUrl The URL of the serialized pipeline.
  119000. * @returns An instantiated pipeline from the serialized object.
  119001. */
  119002. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119003. }
  119004. }
  119005. declare module BABYLON {
  119006. /** @hidden */
  119007. export var ssaoPixelShader: {
  119008. name: string;
  119009. shader: string;
  119010. };
  119011. }
  119012. declare module BABYLON {
  119013. /**
  119014. * Render pipeline to produce ssao effect
  119015. */
  119016. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119017. /**
  119018. * @ignore
  119019. * The PassPostProcess id in the pipeline that contains the original scene color
  119020. */
  119021. SSAOOriginalSceneColorEffect: string;
  119022. /**
  119023. * @ignore
  119024. * The SSAO PostProcess id in the pipeline
  119025. */
  119026. SSAORenderEffect: string;
  119027. /**
  119028. * @ignore
  119029. * The horizontal blur PostProcess id in the pipeline
  119030. */
  119031. SSAOBlurHRenderEffect: string;
  119032. /**
  119033. * @ignore
  119034. * The vertical blur PostProcess id in the pipeline
  119035. */
  119036. SSAOBlurVRenderEffect: string;
  119037. /**
  119038. * @ignore
  119039. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119040. */
  119041. SSAOCombineRenderEffect: string;
  119042. /**
  119043. * The output strength of the SSAO post-process. Default value is 1.0.
  119044. */
  119045. totalStrength: number;
  119046. /**
  119047. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119048. */
  119049. radius: number;
  119050. /**
  119051. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119052. * Must not be equal to fallOff and superior to fallOff.
  119053. * Default value is 0.0075
  119054. */
  119055. area: number;
  119056. /**
  119057. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119058. * Must not be equal to area and inferior to area.
  119059. * Default value is 0.000001
  119060. */
  119061. fallOff: number;
  119062. /**
  119063. * The base color of the SSAO post-process
  119064. * The final result is "base + ssao" between [0, 1]
  119065. */
  119066. base: number;
  119067. private _scene;
  119068. private _depthTexture;
  119069. private _randomTexture;
  119070. private _originalColorPostProcess;
  119071. private _ssaoPostProcess;
  119072. private _blurHPostProcess;
  119073. private _blurVPostProcess;
  119074. private _ssaoCombinePostProcess;
  119075. private _firstUpdate;
  119076. /**
  119077. * Gets active scene
  119078. */
  119079. readonly scene: Scene;
  119080. /**
  119081. * @constructor
  119082. * @param name - The rendering pipeline name
  119083. * @param scene - The scene linked to this pipeline
  119084. * @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 }
  119085. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119086. */
  119087. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119088. /**
  119089. * Get the class name
  119090. * @returns "SSAORenderingPipeline"
  119091. */
  119092. getClassName(): string;
  119093. /**
  119094. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119095. */
  119096. dispose(disableDepthRender?: boolean): void;
  119097. private _createBlurPostProcess;
  119098. /** @hidden */
  119099. _rebuild(): void;
  119100. private _createSSAOPostProcess;
  119101. private _createSSAOCombinePostProcess;
  119102. private _createRandomTexture;
  119103. }
  119104. }
  119105. declare module BABYLON {
  119106. /** @hidden */
  119107. export var standardPixelShader: {
  119108. name: string;
  119109. shader: string;
  119110. };
  119111. }
  119112. declare module BABYLON {
  119113. /**
  119114. * Standard rendering pipeline
  119115. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119116. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119117. */
  119118. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119119. /**
  119120. * Public members
  119121. */
  119122. /**
  119123. * Post-process which contains the original scene color before the pipeline applies all the effects
  119124. */
  119125. originalPostProcess: Nullable<PostProcess>;
  119126. /**
  119127. * Post-process used to down scale an image x4
  119128. */
  119129. downSampleX4PostProcess: Nullable<PostProcess>;
  119130. /**
  119131. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119132. */
  119133. brightPassPostProcess: Nullable<PostProcess>;
  119134. /**
  119135. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119136. */
  119137. blurHPostProcesses: PostProcess[];
  119138. /**
  119139. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119140. */
  119141. blurVPostProcesses: PostProcess[];
  119142. /**
  119143. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119144. */
  119145. textureAdderPostProcess: Nullable<PostProcess>;
  119146. /**
  119147. * Post-process used to create volumetric lighting effect
  119148. */
  119149. volumetricLightPostProcess: Nullable<PostProcess>;
  119150. /**
  119151. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119152. */
  119153. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119154. /**
  119155. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119156. */
  119157. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119158. /**
  119159. * Post-process used to merge the volumetric light effect and the real scene color
  119160. */
  119161. volumetricLightMergePostProces: Nullable<PostProcess>;
  119162. /**
  119163. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119164. */
  119165. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119166. /**
  119167. * Base post-process used to calculate the average luminance of the final image for HDR
  119168. */
  119169. luminancePostProcess: Nullable<PostProcess>;
  119170. /**
  119171. * Post-processes used to create down sample post-processes in order to get
  119172. * the average luminance of the final image for HDR
  119173. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119174. */
  119175. luminanceDownSamplePostProcesses: PostProcess[];
  119176. /**
  119177. * Post-process used to create a HDR effect (light adaptation)
  119178. */
  119179. hdrPostProcess: Nullable<PostProcess>;
  119180. /**
  119181. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119182. */
  119183. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119184. /**
  119185. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119186. */
  119187. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119188. /**
  119189. * Post-process used to merge the final HDR post-process and the real scene color
  119190. */
  119191. hdrFinalPostProcess: Nullable<PostProcess>;
  119192. /**
  119193. * Post-process used to create a lens flare effect
  119194. */
  119195. lensFlarePostProcess: Nullable<PostProcess>;
  119196. /**
  119197. * Post-process that merges the result of the lens flare post-process and the real scene color
  119198. */
  119199. lensFlareComposePostProcess: Nullable<PostProcess>;
  119200. /**
  119201. * Post-process used to create a motion blur effect
  119202. */
  119203. motionBlurPostProcess: Nullable<PostProcess>;
  119204. /**
  119205. * Post-process used to create a depth of field effect
  119206. */
  119207. depthOfFieldPostProcess: Nullable<PostProcess>;
  119208. /**
  119209. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119210. */
  119211. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119212. /**
  119213. * Represents the brightness threshold in order to configure the illuminated surfaces
  119214. */
  119215. brightThreshold: number;
  119216. /**
  119217. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119218. */
  119219. blurWidth: number;
  119220. /**
  119221. * Sets if the blur for highlighted surfaces must be only horizontal
  119222. */
  119223. horizontalBlur: boolean;
  119224. /**
  119225. * Gets the overall exposure used by the pipeline
  119226. */
  119227. /**
  119228. * Sets the overall exposure used by the pipeline
  119229. */
  119230. exposure: number;
  119231. /**
  119232. * Texture used typically to simulate "dirty" on camera lens
  119233. */
  119234. lensTexture: Nullable<Texture>;
  119235. /**
  119236. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119237. */
  119238. volumetricLightCoefficient: number;
  119239. /**
  119240. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119241. */
  119242. volumetricLightPower: number;
  119243. /**
  119244. * Used the set the blur intensity to smooth the volumetric lights
  119245. */
  119246. volumetricLightBlurScale: number;
  119247. /**
  119248. * Light (spot or directional) used to generate the volumetric lights rays
  119249. * The source light must have a shadow generate so the pipeline can get its
  119250. * depth map
  119251. */
  119252. sourceLight: Nullable<SpotLight | DirectionalLight>;
  119253. /**
  119254. * For eye adaptation, represents the minimum luminance the eye can see
  119255. */
  119256. hdrMinimumLuminance: number;
  119257. /**
  119258. * For eye adaptation, represents the decrease luminance speed
  119259. */
  119260. hdrDecreaseRate: number;
  119261. /**
  119262. * For eye adaptation, represents the increase luminance speed
  119263. */
  119264. hdrIncreaseRate: number;
  119265. /**
  119266. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119267. */
  119268. /**
  119269. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119270. */
  119271. hdrAutoExposure: boolean;
  119272. /**
  119273. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  119274. */
  119275. lensColorTexture: Nullable<Texture>;
  119276. /**
  119277. * The overall strengh for the lens flare effect
  119278. */
  119279. lensFlareStrength: number;
  119280. /**
  119281. * Dispersion coefficient for lens flare ghosts
  119282. */
  119283. lensFlareGhostDispersal: number;
  119284. /**
  119285. * Main lens flare halo width
  119286. */
  119287. lensFlareHaloWidth: number;
  119288. /**
  119289. * Based on the lens distortion effect, defines how much the lens flare result
  119290. * is distorted
  119291. */
  119292. lensFlareDistortionStrength: number;
  119293. /**
  119294. * Lens star texture must be used to simulate rays on the flares and is available
  119295. * in the documentation
  119296. */
  119297. lensStarTexture: Nullable<Texture>;
  119298. /**
  119299. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  119300. * flare effect by taking account of the dirt texture
  119301. */
  119302. lensFlareDirtTexture: Nullable<Texture>;
  119303. /**
  119304. * Represents the focal length for the depth of field effect
  119305. */
  119306. depthOfFieldDistance: number;
  119307. /**
  119308. * Represents the blur intensity for the blurred part of the depth of field effect
  119309. */
  119310. depthOfFieldBlurWidth: number;
  119311. /**
  119312. * Gets how much the image is blurred by the movement while using the motion blur post-process
  119313. */
  119314. /**
  119315. * Sets how much the image is blurred by the movement while using the motion blur post-process
  119316. */
  119317. motionStrength: number;
  119318. /**
  119319. * Gets wether or not the motion blur post-process is object based or screen based.
  119320. */
  119321. /**
  119322. * Sets wether or not the motion blur post-process should be object based or screen based
  119323. */
  119324. objectBasedMotionBlur: boolean;
  119325. /**
  119326. * List of animations for the pipeline (IAnimatable implementation)
  119327. */
  119328. animations: Animation[];
  119329. /**
  119330. * Private members
  119331. */
  119332. private _scene;
  119333. private _currentDepthOfFieldSource;
  119334. private _basePostProcess;
  119335. private _fixedExposure;
  119336. private _currentExposure;
  119337. private _hdrAutoExposure;
  119338. private _hdrCurrentLuminance;
  119339. private _motionStrength;
  119340. private _isObjectBasedMotionBlur;
  119341. private _floatTextureType;
  119342. private _ratio;
  119343. private _bloomEnabled;
  119344. private _depthOfFieldEnabled;
  119345. private _vlsEnabled;
  119346. private _lensFlareEnabled;
  119347. private _hdrEnabled;
  119348. private _motionBlurEnabled;
  119349. private _fxaaEnabled;
  119350. private _motionBlurSamples;
  119351. private _volumetricLightStepsCount;
  119352. private _samples;
  119353. /**
  119354. * @ignore
  119355. * Specifies if the bloom pipeline is enabled
  119356. */
  119357. BloomEnabled: boolean;
  119358. /**
  119359. * @ignore
  119360. * Specifies if the depth of field pipeline is enabed
  119361. */
  119362. DepthOfFieldEnabled: boolean;
  119363. /**
  119364. * @ignore
  119365. * Specifies if the lens flare pipeline is enabed
  119366. */
  119367. LensFlareEnabled: boolean;
  119368. /**
  119369. * @ignore
  119370. * Specifies if the HDR pipeline is enabled
  119371. */
  119372. HDREnabled: boolean;
  119373. /**
  119374. * @ignore
  119375. * Specifies if the volumetric lights scattering effect is enabled
  119376. */
  119377. VLSEnabled: boolean;
  119378. /**
  119379. * @ignore
  119380. * Specifies if the motion blur effect is enabled
  119381. */
  119382. MotionBlurEnabled: boolean;
  119383. /**
  119384. * Specifies if anti-aliasing is enabled
  119385. */
  119386. fxaaEnabled: boolean;
  119387. /**
  119388. * Specifies the number of steps used to calculate the volumetric lights
  119389. * Typically in interval [50, 200]
  119390. */
  119391. volumetricLightStepsCount: number;
  119392. /**
  119393. * Specifies the number of samples used for the motion blur effect
  119394. * Typically in interval [16, 64]
  119395. */
  119396. motionBlurSamples: number;
  119397. /**
  119398. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119399. */
  119400. samples: number;
  119401. /**
  119402. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119403. * @constructor
  119404. * @param name The rendering pipeline name
  119405. * @param scene The scene linked to this pipeline
  119406. * @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)
  119407. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119408. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119409. */
  119410. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  119411. private _buildPipeline;
  119412. private _createDownSampleX4PostProcess;
  119413. private _createBrightPassPostProcess;
  119414. private _createBlurPostProcesses;
  119415. private _createTextureAdderPostProcess;
  119416. private _createVolumetricLightPostProcess;
  119417. private _createLuminancePostProcesses;
  119418. private _createHdrPostProcess;
  119419. private _createLensFlarePostProcess;
  119420. private _createDepthOfFieldPostProcess;
  119421. private _createMotionBlurPostProcess;
  119422. private _getDepthTexture;
  119423. private _disposePostProcesses;
  119424. /**
  119425. * Dispose of the pipeline and stop all post processes
  119426. */
  119427. dispose(): void;
  119428. /**
  119429. * Serialize the rendering pipeline (Used when exporting)
  119430. * @returns the serialized object
  119431. */
  119432. serialize(): any;
  119433. /**
  119434. * Parse the serialized pipeline
  119435. * @param source Source pipeline.
  119436. * @param scene The scene to load the pipeline to.
  119437. * @param rootUrl The URL of the serialized pipeline.
  119438. * @returns An instantiated pipeline from the serialized object.
  119439. */
  119440. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  119441. /**
  119442. * Luminance steps
  119443. */
  119444. static LuminanceSteps: number;
  119445. }
  119446. }
  119447. declare module BABYLON {
  119448. /** @hidden */
  119449. export var tonemapPixelShader: {
  119450. name: string;
  119451. shader: string;
  119452. };
  119453. }
  119454. declare module BABYLON {
  119455. /** Defines operator used for tonemapping */
  119456. export enum TonemappingOperator {
  119457. /** Hable */
  119458. Hable = 0,
  119459. /** Reinhard */
  119460. Reinhard = 1,
  119461. /** HejiDawson */
  119462. HejiDawson = 2,
  119463. /** Photographic */
  119464. Photographic = 3
  119465. }
  119466. /**
  119467. * Defines a post process to apply tone mapping
  119468. */
  119469. export class TonemapPostProcess extends PostProcess {
  119470. private _operator;
  119471. /** Defines the required exposure adjustement */
  119472. exposureAdjustment: number;
  119473. /**
  119474. * Creates a new TonemapPostProcess
  119475. * @param name defines the name of the postprocess
  119476. * @param _operator defines the operator to use
  119477. * @param exposureAdjustment defines the required exposure adjustement
  119478. * @param camera defines the camera to use (can be null)
  119479. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119480. * @param engine defines the hosting engine (can be ignore if camera is set)
  119481. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119482. */
  119483. constructor(name: string, _operator: TonemappingOperator,
  119484. /** Defines the required exposure adjustement */
  119485. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  119486. }
  119487. }
  119488. declare module BABYLON {
  119489. /** @hidden */
  119490. export var depthVertexShader: {
  119491. name: string;
  119492. shader: string;
  119493. };
  119494. }
  119495. declare module BABYLON {
  119496. /** @hidden */
  119497. export var volumetricLightScatteringPixelShader: {
  119498. name: string;
  119499. shader: string;
  119500. };
  119501. }
  119502. declare module BABYLON {
  119503. /** @hidden */
  119504. export var volumetricLightScatteringPassPixelShader: {
  119505. name: string;
  119506. shader: string;
  119507. };
  119508. }
  119509. declare module BABYLON {
  119510. /**
  119511. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119512. */
  119513. export class VolumetricLightScatteringPostProcess extends PostProcess {
  119514. private _volumetricLightScatteringPass;
  119515. private _volumetricLightScatteringRTT;
  119516. private _viewPort;
  119517. private _screenCoordinates;
  119518. private _cachedDefines;
  119519. /**
  119520. * If not undefined, the mesh position is computed from the attached node position
  119521. */
  119522. attachedNode: {
  119523. position: Vector3;
  119524. };
  119525. /**
  119526. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119527. */
  119528. customMeshPosition: Vector3;
  119529. /**
  119530. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119531. */
  119532. useCustomMeshPosition: boolean;
  119533. /**
  119534. * If the post-process should inverse the light scattering direction
  119535. */
  119536. invert: boolean;
  119537. /**
  119538. * The internal mesh used by the post-process
  119539. */
  119540. mesh: Mesh;
  119541. /**
  119542. * @hidden
  119543. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119544. */
  119545. useDiffuseColor: boolean;
  119546. /**
  119547. * Array containing the excluded meshes not rendered in the internal pass
  119548. */
  119549. excludedMeshes: AbstractMesh[];
  119550. /**
  119551. * Controls the overall intensity of the post-process
  119552. */
  119553. exposure: number;
  119554. /**
  119555. * Dissipates each sample's contribution in range [0, 1]
  119556. */
  119557. decay: number;
  119558. /**
  119559. * Controls the overall intensity of each sample
  119560. */
  119561. weight: number;
  119562. /**
  119563. * Controls the density of each sample
  119564. */
  119565. density: number;
  119566. /**
  119567. * @constructor
  119568. * @param name The post-process name
  119569. * @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)
  119570. * @param camera The camera that the post-process will be attached to
  119571. * @param mesh The mesh used to create the light scattering
  119572. * @param samples The post-process quality, default 100
  119573. * @param samplingModeThe post-process filtering mode
  119574. * @param engine The babylon engine
  119575. * @param reusable If the post-process is reusable
  119576. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119577. */
  119578. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  119579. /**
  119580. * Returns the string "VolumetricLightScatteringPostProcess"
  119581. * @returns "VolumetricLightScatteringPostProcess"
  119582. */
  119583. getClassName(): string;
  119584. private _isReady;
  119585. /**
  119586. * Sets the new light position for light scattering effect
  119587. * @param position The new custom light position
  119588. */
  119589. setCustomMeshPosition(position: Vector3): void;
  119590. /**
  119591. * Returns the light position for light scattering effect
  119592. * @return Vector3 The custom light position
  119593. */
  119594. getCustomMeshPosition(): Vector3;
  119595. /**
  119596. * Disposes the internal assets and detaches the post-process from the camera
  119597. */
  119598. dispose(camera: Camera): void;
  119599. /**
  119600. * Returns the render target texture used by the post-process
  119601. * @return the render target texture used by the post-process
  119602. */
  119603. getPass(): RenderTargetTexture;
  119604. private _meshExcluded;
  119605. private _createPass;
  119606. private _updateMeshScreenCoordinates;
  119607. /**
  119608. * Creates a default mesh for the Volumeric Light Scattering post-process
  119609. * @param name The mesh name
  119610. * @param scene The scene where to create the mesh
  119611. * @return the default mesh
  119612. */
  119613. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  119614. }
  119615. }
  119616. declare module BABYLON {
  119617. interface Scene {
  119618. /** @hidden (Backing field) */
  119619. _boundingBoxRenderer: BoundingBoxRenderer;
  119620. /** @hidden (Backing field) */
  119621. _forceShowBoundingBoxes: boolean;
  119622. /**
  119623. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  119624. */
  119625. forceShowBoundingBoxes: boolean;
  119626. /**
  119627. * Gets the bounding box renderer associated with the scene
  119628. * @returns a BoundingBoxRenderer
  119629. */
  119630. getBoundingBoxRenderer(): BoundingBoxRenderer;
  119631. }
  119632. interface AbstractMesh {
  119633. /** @hidden (Backing field) */
  119634. _showBoundingBox: boolean;
  119635. /**
  119636. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  119637. */
  119638. showBoundingBox: boolean;
  119639. }
  119640. /**
  119641. * Component responsible of rendering the bounding box of the meshes in a scene.
  119642. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  119643. */
  119644. export class BoundingBoxRenderer implements ISceneComponent {
  119645. /**
  119646. * The component name helpfull to identify the component in the list of scene components.
  119647. */
  119648. readonly name: string;
  119649. /**
  119650. * The scene the component belongs to.
  119651. */
  119652. scene: Scene;
  119653. /**
  119654. * Color of the bounding box lines placed in front of an object
  119655. */
  119656. frontColor: Color3;
  119657. /**
  119658. * Color of the bounding box lines placed behind an object
  119659. */
  119660. backColor: Color3;
  119661. /**
  119662. * Defines if the renderer should show the back lines or not
  119663. */
  119664. showBackLines: boolean;
  119665. /**
  119666. * @hidden
  119667. */
  119668. renderList: SmartArray<BoundingBox>;
  119669. private _colorShader;
  119670. private _vertexBuffers;
  119671. private _indexBuffer;
  119672. private _fillIndexBuffer;
  119673. private _fillIndexData;
  119674. /**
  119675. * Instantiates a new bounding box renderer in a scene.
  119676. * @param scene the scene the renderer renders in
  119677. */
  119678. constructor(scene: Scene);
  119679. /**
  119680. * Registers the component in a given scene
  119681. */
  119682. register(): void;
  119683. private _evaluateSubMesh;
  119684. private _activeMesh;
  119685. private _prepareRessources;
  119686. private _createIndexBuffer;
  119687. /**
  119688. * Rebuilds the elements related to this component in case of
  119689. * context lost for instance.
  119690. */
  119691. rebuild(): void;
  119692. /**
  119693. * @hidden
  119694. */
  119695. reset(): void;
  119696. /**
  119697. * Render the bounding boxes of a specific rendering group
  119698. * @param renderingGroupId defines the rendering group to render
  119699. */
  119700. render(renderingGroupId: number): void;
  119701. /**
  119702. * In case of occlusion queries, we can render the occlusion bounding box through this method
  119703. * @param mesh Define the mesh to render the occlusion bounding box for
  119704. */
  119705. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  119706. /**
  119707. * Dispose and release the resources attached to this renderer.
  119708. */
  119709. dispose(): void;
  119710. }
  119711. }
  119712. declare module BABYLON {
  119713. /** @hidden */
  119714. export var depthPixelShader: {
  119715. name: string;
  119716. shader: string;
  119717. };
  119718. }
  119719. declare module BABYLON {
  119720. /**
  119721. * This represents a depth renderer in Babylon.
  119722. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119723. */
  119724. export class DepthRenderer {
  119725. private _scene;
  119726. private _depthMap;
  119727. private _effect;
  119728. private _cachedDefines;
  119729. private _camera;
  119730. /**
  119731. * Specifiess that the depth renderer will only be used within
  119732. * the camera it is created for.
  119733. * This can help forcing its rendering during the camera processing.
  119734. */
  119735. useOnlyInActiveCamera: boolean;
  119736. /** @hidden */
  119737. static _SceneComponentInitialization: (scene: Scene) => void;
  119738. /**
  119739. * Instantiates a depth renderer
  119740. * @param scene The scene the renderer belongs to
  119741. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119742. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119743. */
  119744. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  119745. /**
  119746. * Creates the depth rendering effect and checks if the effect is ready.
  119747. * @param subMesh The submesh to be used to render the depth map of
  119748. * @param useInstances If multiple world instances should be used
  119749. * @returns if the depth renderer is ready to render the depth map
  119750. */
  119751. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119752. /**
  119753. * Gets the texture which the depth map will be written to.
  119754. * @returns The depth map texture
  119755. */
  119756. getDepthMap(): RenderTargetTexture;
  119757. /**
  119758. * Disposes of the depth renderer.
  119759. */
  119760. dispose(): void;
  119761. }
  119762. }
  119763. declare module BABYLON {
  119764. interface Scene {
  119765. /** @hidden (Backing field) */
  119766. _depthRenderer: {
  119767. [id: string]: DepthRenderer;
  119768. };
  119769. /**
  119770. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  119771. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  119772. * @returns the created depth renderer
  119773. */
  119774. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  119775. /**
  119776. * Disables a depth renderer for a given camera
  119777. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  119778. */
  119779. disableDepthRenderer(camera?: Nullable<Camera>): void;
  119780. }
  119781. /**
  119782. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  119783. * in several rendering techniques.
  119784. */
  119785. export class DepthRendererSceneComponent implements ISceneComponent {
  119786. /**
  119787. * The component name helpfull to identify the component in the list of scene components.
  119788. */
  119789. readonly name: string;
  119790. /**
  119791. * The scene the component belongs to.
  119792. */
  119793. scene: Scene;
  119794. /**
  119795. * Creates a new instance of the component for the given scene
  119796. * @param scene Defines the scene to register the component in
  119797. */
  119798. constructor(scene: Scene);
  119799. /**
  119800. * Registers the component in a given scene
  119801. */
  119802. register(): void;
  119803. /**
  119804. * Rebuilds the elements related to this component in case of
  119805. * context lost for instance.
  119806. */
  119807. rebuild(): void;
  119808. /**
  119809. * Disposes the component and the associated ressources
  119810. */
  119811. dispose(): void;
  119812. private _gatherRenderTargets;
  119813. private _gatherActiveCameraRenderTargets;
  119814. }
  119815. }
  119816. declare module BABYLON {
  119817. /** @hidden */
  119818. export var outlinePixelShader: {
  119819. name: string;
  119820. shader: string;
  119821. };
  119822. }
  119823. declare module BABYLON {
  119824. /** @hidden */
  119825. export var outlineVertexShader: {
  119826. name: string;
  119827. shader: string;
  119828. };
  119829. }
  119830. declare module BABYLON {
  119831. interface Scene {
  119832. /** @hidden */
  119833. _outlineRenderer: OutlineRenderer;
  119834. /**
  119835. * Gets the outline renderer associated with the scene
  119836. * @returns a OutlineRenderer
  119837. */
  119838. getOutlineRenderer(): OutlineRenderer;
  119839. }
  119840. interface AbstractMesh {
  119841. /** @hidden (Backing field) */
  119842. _renderOutline: boolean;
  119843. /**
  119844. * Gets or sets a boolean indicating if the outline must be rendered as well
  119845. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  119846. */
  119847. renderOutline: boolean;
  119848. /** @hidden (Backing field) */
  119849. _renderOverlay: boolean;
  119850. /**
  119851. * Gets or sets a boolean indicating if the overlay must be rendered as well
  119852. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  119853. */
  119854. renderOverlay: boolean;
  119855. }
  119856. /**
  119857. * This class is responsible to draw bothe outline/overlay of meshes.
  119858. * It should not be used directly but through the available method on mesh.
  119859. */
  119860. export class OutlineRenderer implements ISceneComponent {
  119861. /**
  119862. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  119863. */
  119864. private static _StencilReference;
  119865. /**
  119866. * The name of the component. Each component must have a unique name.
  119867. */
  119868. name: string;
  119869. /**
  119870. * The scene the component belongs to.
  119871. */
  119872. scene: Scene;
  119873. /**
  119874. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  119875. */
  119876. zOffset: number;
  119877. private _engine;
  119878. private _effect;
  119879. private _cachedDefines;
  119880. private _savedDepthWrite;
  119881. /**
  119882. * Instantiates a new outline renderer. (There could be only one per scene).
  119883. * @param scene Defines the scene it belongs to
  119884. */
  119885. constructor(scene: Scene);
  119886. /**
  119887. * Register the component to one instance of a scene.
  119888. */
  119889. register(): void;
  119890. /**
  119891. * Rebuilds the elements related to this component in case of
  119892. * context lost for instance.
  119893. */
  119894. rebuild(): void;
  119895. /**
  119896. * Disposes the component and the associated ressources.
  119897. */
  119898. dispose(): void;
  119899. /**
  119900. * Renders the outline in the canvas.
  119901. * @param subMesh Defines the sumesh to render
  119902. * @param batch Defines the batch of meshes in case of instances
  119903. * @param useOverlay Defines if the rendering is for the overlay or the outline
  119904. */
  119905. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  119906. /**
  119907. * Returns whether or not the outline renderer is ready for a given submesh.
  119908. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  119909. * @param subMesh Defines the submesh to check readyness for
  119910. * @param useInstances Defines wheter wee are trying to render instances or not
  119911. * @returns true if ready otherwise false
  119912. */
  119913. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119914. private _beforeRenderingMesh;
  119915. private _afterRenderingMesh;
  119916. }
  119917. }
  119918. declare module BABYLON {
  119919. /**
  119920. * Defines the list of states available for a task inside a AssetsManager
  119921. */
  119922. export enum AssetTaskState {
  119923. /**
  119924. * Initialization
  119925. */
  119926. INIT = 0,
  119927. /**
  119928. * Running
  119929. */
  119930. RUNNING = 1,
  119931. /**
  119932. * Done
  119933. */
  119934. DONE = 2,
  119935. /**
  119936. * Error
  119937. */
  119938. ERROR = 3
  119939. }
  119940. /**
  119941. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  119942. */
  119943. export abstract class AbstractAssetTask {
  119944. /**
  119945. * Task name
  119946. */ name: string;
  119947. /**
  119948. * Callback called when the task is successful
  119949. */
  119950. onSuccess: (task: any) => void;
  119951. /**
  119952. * Callback called when the task is not successful
  119953. */
  119954. onError: (task: any, message?: string, exception?: any) => void;
  119955. /**
  119956. * Creates a new AssetsManager
  119957. * @param name defines the name of the task
  119958. */
  119959. constructor(
  119960. /**
  119961. * Task name
  119962. */ name: string);
  119963. private _isCompleted;
  119964. private _taskState;
  119965. private _errorObject;
  119966. /**
  119967. * Get if the task is completed
  119968. */
  119969. readonly isCompleted: boolean;
  119970. /**
  119971. * Gets the current state of the task
  119972. */
  119973. readonly taskState: AssetTaskState;
  119974. /**
  119975. * Gets the current error object (if task is in error)
  119976. */
  119977. readonly errorObject: {
  119978. message?: string;
  119979. exception?: any;
  119980. };
  119981. /**
  119982. * Internal only
  119983. * @hidden
  119984. */
  119985. _setErrorObject(message?: string, exception?: any): void;
  119986. /**
  119987. * Execute the current task
  119988. * @param scene defines the scene where you want your assets to be loaded
  119989. * @param onSuccess is a callback called when the task is successfully executed
  119990. * @param onError is a callback called if an error occurs
  119991. */
  119992. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119993. /**
  119994. * Execute the current task
  119995. * @param scene defines the scene where you want your assets to be loaded
  119996. * @param onSuccess is a callback called when the task is successfully executed
  119997. * @param onError is a callback called if an error occurs
  119998. */
  119999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120000. /**
  120001. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120002. * This can be used with failed tasks that have the reason for failure fixed.
  120003. */
  120004. reset(): void;
  120005. private onErrorCallback;
  120006. private onDoneCallback;
  120007. }
  120008. /**
  120009. * Define the interface used by progress events raised during assets loading
  120010. */
  120011. export interface IAssetsProgressEvent {
  120012. /**
  120013. * Defines the number of remaining tasks to process
  120014. */
  120015. remainingCount: number;
  120016. /**
  120017. * Defines the total number of tasks
  120018. */
  120019. totalCount: number;
  120020. /**
  120021. * Defines the task that was just processed
  120022. */
  120023. task: AbstractAssetTask;
  120024. }
  120025. /**
  120026. * Class used to share progress information about assets loading
  120027. */
  120028. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120029. /**
  120030. * Defines the number of remaining tasks to process
  120031. */
  120032. remainingCount: number;
  120033. /**
  120034. * Defines the total number of tasks
  120035. */
  120036. totalCount: number;
  120037. /**
  120038. * Defines the task that was just processed
  120039. */
  120040. task: AbstractAssetTask;
  120041. /**
  120042. * Creates a AssetsProgressEvent
  120043. * @param remainingCount defines the number of remaining tasks to process
  120044. * @param totalCount defines the total number of tasks
  120045. * @param task defines the task that was just processed
  120046. */
  120047. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120048. }
  120049. /**
  120050. * Define a task used by AssetsManager to load meshes
  120051. */
  120052. export class MeshAssetTask extends AbstractAssetTask {
  120053. /**
  120054. * Defines the name of the task
  120055. */
  120056. name: string;
  120057. /**
  120058. * Defines the list of mesh's names you want to load
  120059. */
  120060. meshesNames: any;
  120061. /**
  120062. * Defines the root url to use as a base to load your meshes and associated resources
  120063. */
  120064. rootUrl: string;
  120065. /**
  120066. * Defines the filename of the scene to load from
  120067. */
  120068. sceneFilename: string;
  120069. /**
  120070. * Gets the list of loaded meshes
  120071. */
  120072. loadedMeshes: Array<AbstractMesh>;
  120073. /**
  120074. * Gets the list of loaded particle systems
  120075. */
  120076. loadedParticleSystems: Array<IParticleSystem>;
  120077. /**
  120078. * Gets the list of loaded skeletons
  120079. */
  120080. loadedSkeletons: Array<Skeleton>;
  120081. /**
  120082. * Gets the list of loaded animation groups
  120083. */
  120084. loadedAnimationGroups: Array<AnimationGroup>;
  120085. /**
  120086. * Callback called when the task is successful
  120087. */
  120088. onSuccess: (task: MeshAssetTask) => void;
  120089. /**
  120090. * Callback called when the task is successful
  120091. */
  120092. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120093. /**
  120094. * Creates a new MeshAssetTask
  120095. * @param name defines the name of the task
  120096. * @param meshesNames defines the list of mesh's names you want to load
  120097. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120098. * @param sceneFilename defines the filename of the scene to load from
  120099. */
  120100. constructor(
  120101. /**
  120102. * Defines the name of the task
  120103. */
  120104. name: string,
  120105. /**
  120106. * Defines the list of mesh's names you want to load
  120107. */
  120108. meshesNames: any,
  120109. /**
  120110. * Defines the root url to use as a base to load your meshes and associated resources
  120111. */
  120112. rootUrl: string,
  120113. /**
  120114. * Defines the filename of the scene to load from
  120115. */
  120116. sceneFilename: string);
  120117. /**
  120118. * Execute the current task
  120119. * @param scene defines the scene where you want your assets to be loaded
  120120. * @param onSuccess is a callback called when the task is successfully executed
  120121. * @param onError is a callback called if an error occurs
  120122. */
  120123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120124. }
  120125. /**
  120126. * Define a task used by AssetsManager to load text content
  120127. */
  120128. export class TextFileAssetTask extends AbstractAssetTask {
  120129. /**
  120130. * Defines the name of the task
  120131. */
  120132. name: string;
  120133. /**
  120134. * Defines the location of the file to load
  120135. */
  120136. url: string;
  120137. /**
  120138. * Gets the loaded text string
  120139. */
  120140. text: string;
  120141. /**
  120142. * Callback called when the task is successful
  120143. */
  120144. onSuccess: (task: TextFileAssetTask) => void;
  120145. /**
  120146. * Callback called when the task is successful
  120147. */
  120148. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120149. /**
  120150. * Creates a new TextFileAssetTask object
  120151. * @param name defines the name of the task
  120152. * @param url defines the location of the file to load
  120153. */
  120154. constructor(
  120155. /**
  120156. * Defines the name of the task
  120157. */
  120158. name: string,
  120159. /**
  120160. * Defines the location of the file to load
  120161. */
  120162. url: string);
  120163. /**
  120164. * Execute the current task
  120165. * @param scene defines the scene where you want your assets to be loaded
  120166. * @param onSuccess is a callback called when the task is successfully executed
  120167. * @param onError is a callback called if an error occurs
  120168. */
  120169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120170. }
  120171. /**
  120172. * Define a task used by AssetsManager to load binary data
  120173. */
  120174. export class BinaryFileAssetTask extends AbstractAssetTask {
  120175. /**
  120176. * Defines the name of the task
  120177. */
  120178. name: string;
  120179. /**
  120180. * Defines the location of the file to load
  120181. */
  120182. url: string;
  120183. /**
  120184. * Gets the lodaded data (as an array buffer)
  120185. */
  120186. data: ArrayBuffer;
  120187. /**
  120188. * Callback called when the task is successful
  120189. */
  120190. onSuccess: (task: BinaryFileAssetTask) => void;
  120191. /**
  120192. * Callback called when the task is successful
  120193. */
  120194. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120195. /**
  120196. * Creates a new BinaryFileAssetTask object
  120197. * @param name defines the name of the new task
  120198. * @param url defines the location of the file to load
  120199. */
  120200. constructor(
  120201. /**
  120202. * Defines the name of the task
  120203. */
  120204. name: string,
  120205. /**
  120206. * Defines the location of the file to load
  120207. */
  120208. url: string);
  120209. /**
  120210. * Execute the current task
  120211. * @param scene defines the scene where you want your assets to be loaded
  120212. * @param onSuccess is a callback called when the task is successfully executed
  120213. * @param onError is a callback called if an error occurs
  120214. */
  120215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120216. }
  120217. /**
  120218. * Define a task used by AssetsManager to load images
  120219. */
  120220. export class ImageAssetTask extends AbstractAssetTask {
  120221. /**
  120222. * Defines the name of the task
  120223. */
  120224. name: string;
  120225. /**
  120226. * Defines the location of the image to load
  120227. */
  120228. url: string;
  120229. /**
  120230. * Gets the loaded images
  120231. */
  120232. image: HTMLImageElement;
  120233. /**
  120234. * Callback called when the task is successful
  120235. */
  120236. onSuccess: (task: ImageAssetTask) => void;
  120237. /**
  120238. * Callback called when the task is successful
  120239. */
  120240. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120241. /**
  120242. * Creates a new ImageAssetTask
  120243. * @param name defines the name of the task
  120244. * @param url defines the location of the image to load
  120245. */
  120246. constructor(
  120247. /**
  120248. * Defines the name of the task
  120249. */
  120250. name: string,
  120251. /**
  120252. * Defines the location of the image to load
  120253. */
  120254. url: string);
  120255. /**
  120256. * Execute the current task
  120257. * @param scene defines the scene where you want your assets to be loaded
  120258. * @param onSuccess is a callback called when the task is successfully executed
  120259. * @param onError is a callback called if an error occurs
  120260. */
  120261. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120262. }
  120263. /**
  120264. * Defines the interface used by texture loading tasks
  120265. */
  120266. export interface ITextureAssetTask<TEX extends BaseTexture> {
  120267. /**
  120268. * Gets the loaded texture
  120269. */
  120270. texture: TEX;
  120271. }
  120272. /**
  120273. * Define a task used by AssetsManager to load 2D textures
  120274. */
  120275. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  120276. /**
  120277. * Defines the name of the task
  120278. */
  120279. name: string;
  120280. /**
  120281. * Defines the location of the file to load
  120282. */
  120283. url: string;
  120284. /**
  120285. * Defines if mipmap should not be generated (default is false)
  120286. */
  120287. noMipmap?: boolean | undefined;
  120288. /**
  120289. * Defines if texture must be inverted on Y axis (default is false)
  120290. */
  120291. invertY?: boolean | undefined;
  120292. /**
  120293. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120294. */
  120295. samplingMode: number;
  120296. /**
  120297. * Gets the loaded texture
  120298. */
  120299. texture: Texture;
  120300. /**
  120301. * Callback called when the task is successful
  120302. */
  120303. onSuccess: (task: TextureAssetTask) => void;
  120304. /**
  120305. * Callback called when the task is successful
  120306. */
  120307. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  120308. /**
  120309. * Creates a new TextureAssetTask object
  120310. * @param name defines the name of the task
  120311. * @param url defines the location of the file to load
  120312. * @param noMipmap defines if mipmap should not be generated (default is false)
  120313. * @param invertY defines if texture must be inverted on Y axis (default is false)
  120314. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120315. */
  120316. constructor(
  120317. /**
  120318. * Defines the name of the task
  120319. */
  120320. name: string,
  120321. /**
  120322. * Defines the location of the file to load
  120323. */
  120324. url: string,
  120325. /**
  120326. * Defines if mipmap should not be generated (default is false)
  120327. */
  120328. noMipmap?: boolean | undefined,
  120329. /**
  120330. * Defines if texture must be inverted on Y axis (default is false)
  120331. */
  120332. invertY?: boolean | undefined,
  120333. /**
  120334. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120335. */
  120336. samplingMode?: number);
  120337. /**
  120338. * Execute the current task
  120339. * @param scene defines the scene where you want your assets to be loaded
  120340. * @param onSuccess is a callback called when the task is successfully executed
  120341. * @param onError is a callback called if an error occurs
  120342. */
  120343. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120344. }
  120345. /**
  120346. * Define a task used by AssetsManager to load cube textures
  120347. */
  120348. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  120349. /**
  120350. * Defines the name of the task
  120351. */
  120352. name: string;
  120353. /**
  120354. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120355. */
  120356. url: string;
  120357. /**
  120358. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120359. */
  120360. extensions?: string[] | undefined;
  120361. /**
  120362. * Defines if mipmaps should not be generated (default is false)
  120363. */
  120364. noMipmap?: boolean | undefined;
  120365. /**
  120366. * Defines the explicit list of files (undefined by default)
  120367. */
  120368. files?: string[] | undefined;
  120369. /**
  120370. * Gets the loaded texture
  120371. */
  120372. texture: CubeTexture;
  120373. /**
  120374. * Callback called when the task is successful
  120375. */
  120376. onSuccess: (task: CubeTextureAssetTask) => void;
  120377. /**
  120378. * Callback called when the task is successful
  120379. */
  120380. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  120381. /**
  120382. * Creates a new CubeTextureAssetTask
  120383. * @param name defines the name of the task
  120384. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120385. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120386. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120387. * @param files defines the explicit list of files (undefined by default)
  120388. */
  120389. constructor(
  120390. /**
  120391. * Defines the name of the task
  120392. */
  120393. name: string,
  120394. /**
  120395. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120396. */
  120397. url: string,
  120398. /**
  120399. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120400. */
  120401. extensions?: string[] | undefined,
  120402. /**
  120403. * Defines if mipmaps should not be generated (default is false)
  120404. */
  120405. noMipmap?: boolean | undefined,
  120406. /**
  120407. * Defines the explicit list of files (undefined by default)
  120408. */
  120409. files?: string[] | undefined);
  120410. /**
  120411. * Execute the current task
  120412. * @param scene defines the scene where you want your assets to be loaded
  120413. * @param onSuccess is a callback called when the task is successfully executed
  120414. * @param onError is a callback called if an error occurs
  120415. */
  120416. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120417. }
  120418. /**
  120419. * Define a task used by AssetsManager to load HDR cube textures
  120420. */
  120421. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  120422. /**
  120423. * Defines the name of the task
  120424. */
  120425. name: string;
  120426. /**
  120427. * Defines the location of the file to load
  120428. */
  120429. url: string;
  120430. /**
  120431. * Defines the desired size (the more it increases the longer the generation will be)
  120432. */
  120433. size: number;
  120434. /**
  120435. * Defines if mipmaps should not be generated (default is false)
  120436. */
  120437. noMipmap: boolean;
  120438. /**
  120439. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120440. */
  120441. generateHarmonics: boolean;
  120442. /**
  120443. * 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)
  120444. */
  120445. gammaSpace: boolean;
  120446. /**
  120447. * Internal Use Only
  120448. */
  120449. reserved: boolean;
  120450. /**
  120451. * Gets the loaded texture
  120452. */
  120453. texture: HDRCubeTexture;
  120454. /**
  120455. * Callback called when the task is successful
  120456. */
  120457. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  120458. /**
  120459. * Callback called when the task is successful
  120460. */
  120461. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  120462. /**
  120463. * Creates a new HDRCubeTextureAssetTask object
  120464. * @param name defines the name of the task
  120465. * @param url defines the location of the file to load
  120466. * @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.
  120467. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120468. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120469. * @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)
  120470. * @param reserved Internal use only
  120471. */
  120472. constructor(
  120473. /**
  120474. * Defines the name of the task
  120475. */
  120476. name: string,
  120477. /**
  120478. * Defines the location of the file to load
  120479. */
  120480. url: string,
  120481. /**
  120482. * Defines the desired size (the more it increases the longer the generation will be)
  120483. */
  120484. size: number,
  120485. /**
  120486. * Defines if mipmaps should not be generated (default is false)
  120487. */
  120488. noMipmap?: boolean,
  120489. /**
  120490. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120491. */
  120492. generateHarmonics?: boolean,
  120493. /**
  120494. * 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)
  120495. */
  120496. gammaSpace?: boolean,
  120497. /**
  120498. * Internal Use Only
  120499. */
  120500. reserved?: boolean);
  120501. /**
  120502. * Execute the current task
  120503. * @param scene defines the scene where you want your assets to be loaded
  120504. * @param onSuccess is a callback called when the task is successfully executed
  120505. * @param onError is a callback called if an error occurs
  120506. */
  120507. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120508. }
  120509. /**
  120510. * Define a task used by AssetsManager to load Equirectangular cube textures
  120511. */
  120512. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  120513. /**
  120514. * Defines the name of the task
  120515. */
  120516. name: string;
  120517. /**
  120518. * Defines the location of the file to load
  120519. */
  120520. url: string;
  120521. /**
  120522. * Defines the desired size (the more it increases the longer the generation will be)
  120523. */
  120524. size: number;
  120525. /**
  120526. * Defines if mipmaps should not be generated (default is false)
  120527. */
  120528. noMipmap: boolean;
  120529. /**
  120530. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120531. * but the standard material would require them in Gamma space) (default is true)
  120532. */
  120533. gammaSpace: boolean;
  120534. /**
  120535. * Gets the loaded texture
  120536. */
  120537. texture: EquiRectangularCubeTexture;
  120538. /**
  120539. * Callback called when the task is successful
  120540. */
  120541. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  120542. /**
  120543. * Callback called when the task is successful
  120544. */
  120545. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  120546. /**
  120547. * Creates a new EquiRectangularCubeTextureAssetTask object
  120548. * @param name defines the name of the task
  120549. * @param url defines the location of the file to load
  120550. * @param size defines the desired size (the more it increases the longer the generation will be)
  120551. * If the size is omitted this implies you are using a preprocessed cubemap.
  120552. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120553. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  120554. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  120555. * (default is true)
  120556. */
  120557. constructor(
  120558. /**
  120559. * Defines the name of the task
  120560. */
  120561. name: string,
  120562. /**
  120563. * Defines the location of the file to load
  120564. */
  120565. url: string,
  120566. /**
  120567. * Defines the desired size (the more it increases the longer the generation will be)
  120568. */
  120569. size: number,
  120570. /**
  120571. * Defines if mipmaps should not be generated (default is false)
  120572. */
  120573. noMipmap?: boolean,
  120574. /**
  120575. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120576. * but the standard material would require them in Gamma space) (default is true)
  120577. */
  120578. gammaSpace?: boolean);
  120579. /**
  120580. * Execute the current task
  120581. * @param scene defines the scene where you want your assets to be loaded
  120582. * @param onSuccess is a callback called when the task is successfully executed
  120583. * @param onError is a callback called if an error occurs
  120584. */
  120585. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120586. }
  120587. /**
  120588. * This class can be used to easily import assets into a scene
  120589. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  120590. */
  120591. export class AssetsManager {
  120592. private _scene;
  120593. private _isLoading;
  120594. protected _tasks: AbstractAssetTask[];
  120595. protected _waitingTasksCount: number;
  120596. protected _totalTasksCount: number;
  120597. /**
  120598. * Callback called when all tasks are processed
  120599. */
  120600. onFinish: (tasks: AbstractAssetTask[]) => void;
  120601. /**
  120602. * Callback called when a task is successful
  120603. */
  120604. onTaskSuccess: (task: AbstractAssetTask) => void;
  120605. /**
  120606. * Callback called when a task had an error
  120607. */
  120608. onTaskError: (task: AbstractAssetTask) => void;
  120609. /**
  120610. * Callback called when a task is done (whatever the result is)
  120611. */
  120612. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  120613. /**
  120614. * Observable called when all tasks are processed
  120615. */
  120616. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  120617. /**
  120618. * Observable called when a task had an error
  120619. */
  120620. onTaskErrorObservable: Observable<AbstractAssetTask>;
  120621. /**
  120622. * Observable called when all tasks were executed
  120623. */
  120624. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  120625. /**
  120626. * Observable called when a task is done (whatever the result is)
  120627. */
  120628. onProgressObservable: Observable<IAssetsProgressEvent>;
  120629. /**
  120630. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  120631. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120632. */
  120633. useDefaultLoadingScreen: boolean;
  120634. /**
  120635. * Creates a new AssetsManager
  120636. * @param scene defines the scene to work on
  120637. */
  120638. constructor(scene: Scene);
  120639. /**
  120640. * Add a MeshAssetTask to the list of active tasks
  120641. * @param taskName defines the name of the new task
  120642. * @param meshesNames defines the name of meshes to load
  120643. * @param rootUrl defines the root url to use to locate files
  120644. * @param sceneFilename defines the filename of the scene file
  120645. * @returns a new MeshAssetTask object
  120646. */
  120647. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  120648. /**
  120649. * Add a TextFileAssetTask to the list of active tasks
  120650. * @param taskName defines the name of the new task
  120651. * @param url defines the url of the file to load
  120652. * @returns a new TextFileAssetTask object
  120653. */
  120654. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  120655. /**
  120656. * Add a BinaryFileAssetTask to the list of active tasks
  120657. * @param taskName defines the name of the new task
  120658. * @param url defines the url of the file to load
  120659. * @returns a new BinaryFileAssetTask object
  120660. */
  120661. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  120662. /**
  120663. * Add a ImageAssetTask to the list of active tasks
  120664. * @param taskName defines the name of the new task
  120665. * @param url defines the url of the file to load
  120666. * @returns a new ImageAssetTask object
  120667. */
  120668. addImageTask(taskName: string, url: string): ImageAssetTask;
  120669. /**
  120670. * Add a TextureAssetTask to the list of active tasks
  120671. * @param taskName defines the name of the new task
  120672. * @param url defines the url of the file to load
  120673. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120674. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  120675. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120676. * @returns a new TextureAssetTask object
  120677. */
  120678. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  120679. /**
  120680. * Add a CubeTextureAssetTask to the list of active tasks
  120681. * @param taskName defines the name of the new task
  120682. * @param url defines the url of the file to load
  120683. * @param extensions defines the extension to use to load the cube map (can be null)
  120684. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120685. * @param files defines the list of files to load (can be null)
  120686. * @returns a new CubeTextureAssetTask object
  120687. */
  120688. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  120689. /**
  120690. *
  120691. * Add a HDRCubeTextureAssetTask to the list of active tasks
  120692. * @param taskName defines the name of the new task
  120693. * @param url defines the url of the file to load
  120694. * @param size defines the size you want for the cubemap (can be null)
  120695. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120696. * @param generateHarmonics defines if you want to automatically generate (true by default)
  120697. * @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)
  120698. * @param reserved Internal use only
  120699. * @returns a new HDRCubeTextureAssetTask object
  120700. */
  120701. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  120702. /**
  120703. *
  120704. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  120705. * @param taskName defines the name of the new task
  120706. * @param url defines the url of the file to load
  120707. * @param size defines the size you want for the cubemap (can be null)
  120708. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120709. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120710. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120711. * @returns a new EquiRectangularCubeTextureAssetTask object
  120712. */
  120713. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  120714. /**
  120715. * Remove a task from the assets manager.
  120716. * @param task the task to remove
  120717. */
  120718. removeTask(task: AbstractAssetTask): void;
  120719. private _decreaseWaitingTasksCount;
  120720. private _runTask;
  120721. /**
  120722. * Reset the AssetsManager and remove all tasks
  120723. * @return the current instance of the AssetsManager
  120724. */
  120725. reset(): AssetsManager;
  120726. /**
  120727. * Start the loading process
  120728. * @return the current instance of the AssetsManager
  120729. */
  120730. load(): AssetsManager;
  120731. /**
  120732. * Start the loading process as an async operation
  120733. * @return a promise returning the list of failed tasks
  120734. */
  120735. loadAsync(): Promise<void>;
  120736. }
  120737. }
  120738. declare module BABYLON {
  120739. /**
  120740. * Wrapper class for promise with external resolve and reject.
  120741. */
  120742. export class Deferred<T> {
  120743. /**
  120744. * The promise associated with this deferred object.
  120745. */
  120746. readonly promise: Promise<T>;
  120747. private _resolve;
  120748. private _reject;
  120749. /**
  120750. * The resolve method of the promise associated with this deferred object.
  120751. */
  120752. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  120753. /**
  120754. * The reject method of the promise associated with this deferred object.
  120755. */
  120756. readonly reject: (reason?: any) => void;
  120757. /**
  120758. * Constructor for this deferred object.
  120759. */
  120760. constructor();
  120761. }
  120762. }
  120763. declare module BABYLON {
  120764. /**
  120765. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  120766. */
  120767. export class MeshExploder {
  120768. private _centerMesh;
  120769. private _meshes;
  120770. private _meshesOrigins;
  120771. private _toCenterVectors;
  120772. private _scaledDirection;
  120773. private _newPosition;
  120774. private _centerPosition;
  120775. /**
  120776. * Explodes meshes from a center mesh.
  120777. * @param meshes The meshes to explode.
  120778. * @param centerMesh The mesh to be center of explosion.
  120779. */
  120780. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  120781. private _setCenterMesh;
  120782. /**
  120783. * Get class name
  120784. * @returns "MeshExploder"
  120785. */
  120786. getClassName(): string;
  120787. /**
  120788. * "Exploded meshes"
  120789. * @returns Array of meshes with the centerMesh at index 0.
  120790. */
  120791. getMeshes(): Array<Mesh>;
  120792. /**
  120793. * Explodes meshes giving a specific direction
  120794. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  120795. */
  120796. explode(direction?: number): void;
  120797. }
  120798. }
  120799. declare module BABYLON {
  120800. /**
  120801. * Class used to help managing file picking and drag'n'drop
  120802. */
  120803. export class FilesInput {
  120804. /**
  120805. * List of files ready to be loaded
  120806. */
  120807. static readonly FilesToLoad: {
  120808. [key: string]: File;
  120809. };
  120810. /**
  120811. * Callback called when a file is processed
  120812. */
  120813. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  120814. private _engine;
  120815. private _currentScene;
  120816. private _sceneLoadedCallback;
  120817. private _progressCallback;
  120818. private _additionalRenderLoopLogicCallback;
  120819. private _textureLoadingCallback;
  120820. private _startingProcessingFilesCallback;
  120821. private _onReloadCallback;
  120822. private _errorCallback;
  120823. private _elementToMonitor;
  120824. private _sceneFileToLoad;
  120825. private _filesToLoad;
  120826. /**
  120827. * Creates a new FilesInput
  120828. * @param engine defines the rendering engine
  120829. * @param scene defines the hosting scene
  120830. * @param sceneLoadedCallback callback called when scene is loaded
  120831. * @param progressCallback callback called to track progress
  120832. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  120833. * @param textureLoadingCallback callback called when a texture is loading
  120834. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  120835. * @param onReloadCallback callback called when a reload is requested
  120836. * @param errorCallback callback call if an error occurs
  120837. */
  120838. 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);
  120839. private _dragEnterHandler;
  120840. private _dragOverHandler;
  120841. private _dropHandler;
  120842. /**
  120843. * Calls this function to listen to drag'n'drop events on a specific DOM element
  120844. * @param elementToMonitor defines the DOM element to track
  120845. */
  120846. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  120847. /**
  120848. * Release all associated resources
  120849. */
  120850. dispose(): void;
  120851. private renderFunction;
  120852. private drag;
  120853. private drop;
  120854. private _traverseFolder;
  120855. private _processFiles;
  120856. /**
  120857. * Load files from a drop event
  120858. * @param event defines the drop event to use as source
  120859. */
  120860. loadFiles(event: any): void;
  120861. private _processReload;
  120862. /**
  120863. * Reload the current scene from the loaded files
  120864. */
  120865. reload(): void;
  120866. }
  120867. }
  120868. declare module BABYLON {
  120869. /**
  120870. * Defines the root class used to create scene optimization to use with SceneOptimizer
  120871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120872. */
  120873. export class SceneOptimization {
  120874. /**
  120875. * Defines the priority of this optimization (0 by default which means first in the list)
  120876. */
  120877. priority: number;
  120878. /**
  120879. * Gets a string describing the action executed by the current optimization
  120880. * @returns description string
  120881. */
  120882. getDescription(): string;
  120883. /**
  120884. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120885. * @param scene defines the current scene where to apply this optimization
  120886. * @param optimizer defines the current optimizer
  120887. * @returns true if everything that can be done was applied
  120888. */
  120889. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120890. /**
  120891. * Creates the SceneOptimization object
  120892. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120893. * @param desc defines the description associated with the optimization
  120894. */
  120895. constructor(
  120896. /**
  120897. * Defines the priority of this optimization (0 by default which means first in the list)
  120898. */
  120899. priority?: number);
  120900. }
  120901. /**
  120902. * Defines an optimization used to reduce the size of render target textures
  120903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120904. */
  120905. export class TextureOptimization extends SceneOptimization {
  120906. /**
  120907. * Defines the priority of this optimization (0 by default which means first in the list)
  120908. */
  120909. priority: number;
  120910. /**
  120911. * 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
  120912. */
  120913. maximumSize: number;
  120914. /**
  120915. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120916. */
  120917. step: number;
  120918. /**
  120919. * Gets a string describing the action executed by the current optimization
  120920. * @returns description string
  120921. */
  120922. getDescription(): string;
  120923. /**
  120924. * Creates the TextureOptimization object
  120925. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120926. * @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
  120927. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120928. */
  120929. constructor(
  120930. /**
  120931. * Defines the priority of this optimization (0 by default which means first in the list)
  120932. */
  120933. priority?: number,
  120934. /**
  120935. * 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
  120936. */
  120937. maximumSize?: number,
  120938. /**
  120939. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120940. */
  120941. step?: number);
  120942. /**
  120943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120944. * @param scene defines the current scene where to apply this optimization
  120945. * @param optimizer defines the current optimizer
  120946. * @returns true if everything that can be done was applied
  120947. */
  120948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120949. }
  120950. /**
  120951. * Defines an optimization used to increase or decrease the rendering resolution
  120952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120953. */
  120954. export class HardwareScalingOptimization extends SceneOptimization {
  120955. /**
  120956. * Defines the priority of this optimization (0 by default which means first in the list)
  120957. */
  120958. priority: number;
  120959. /**
  120960. * Defines the maximum scale to use (2 by default)
  120961. */
  120962. maximumScale: number;
  120963. /**
  120964. * Defines the step to use between two passes (0.5 by default)
  120965. */
  120966. step: number;
  120967. private _currentScale;
  120968. private _directionOffset;
  120969. /**
  120970. * Gets a string describing the action executed by the current optimization
  120971. * @return description string
  120972. */
  120973. getDescription(): string;
  120974. /**
  120975. * Creates the HardwareScalingOptimization object
  120976. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120977. * @param maximumScale defines the maximum scale to use (2 by default)
  120978. * @param step defines the step to use between two passes (0.5 by default)
  120979. */
  120980. constructor(
  120981. /**
  120982. * Defines the priority of this optimization (0 by default which means first in the list)
  120983. */
  120984. priority?: number,
  120985. /**
  120986. * Defines the maximum scale to use (2 by default)
  120987. */
  120988. maximumScale?: number,
  120989. /**
  120990. * Defines the step to use between two passes (0.5 by default)
  120991. */
  120992. step?: number);
  120993. /**
  120994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120995. * @param scene defines the current scene where to apply this optimization
  120996. * @param optimizer defines the current optimizer
  120997. * @returns true if everything that can be done was applied
  120998. */
  120999. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121000. }
  121001. /**
  121002. * Defines an optimization used to remove shadows
  121003. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121004. */
  121005. export class ShadowsOptimization extends SceneOptimization {
  121006. /**
  121007. * Gets a string describing the action executed by the current optimization
  121008. * @return description string
  121009. */
  121010. getDescription(): string;
  121011. /**
  121012. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121013. * @param scene defines the current scene where to apply this optimization
  121014. * @param optimizer defines the current optimizer
  121015. * @returns true if everything that can be done was applied
  121016. */
  121017. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121018. }
  121019. /**
  121020. * Defines an optimization used to turn post-processes off
  121021. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121022. */
  121023. export class PostProcessesOptimization extends SceneOptimization {
  121024. /**
  121025. * Gets a string describing the action executed by the current optimization
  121026. * @return description string
  121027. */
  121028. getDescription(): string;
  121029. /**
  121030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121031. * @param scene defines the current scene where to apply this optimization
  121032. * @param optimizer defines the current optimizer
  121033. * @returns true if everything that can be done was applied
  121034. */
  121035. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121036. }
  121037. /**
  121038. * Defines an optimization used to turn lens flares off
  121039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121040. */
  121041. export class LensFlaresOptimization extends SceneOptimization {
  121042. /**
  121043. * Gets a string describing the action executed by the current optimization
  121044. * @return description string
  121045. */
  121046. getDescription(): string;
  121047. /**
  121048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121049. * @param scene defines the current scene where to apply this optimization
  121050. * @param optimizer defines the current optimizer
  121051. * @returns true if everything that can be done was applied
  121052. */
  121053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121054. }
  121055. /**
  121056. * Defines an optimization based on user defined callback.
  121057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121058. */
  121059. export class CustomOptimization extends SceneOptimization {
  121060. /**
  121061. * Callback called to apply the custom optimization.
  121062. */
  121063. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121064. /**
  121065. * Callback called to get custom description
  121066. */
  121067. onGetDescription: () => string;
  121068. /**
  121069. * Gets a string describing the action executed by the current optimization
  121070. * @returns description string
  121071. */
  121072. getDescription(): string;
  121073. /**
  121074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121075. * @param scene defines the current scene where to apply this optimization
  121076. * @param optimizer defines the current optimizer
  121077. * @returns true if everything that can be done was applied
  121078. */
  121079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121080. }
  121081. /**
  121082. * Defines an optimization used to turn particles off
  121083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121084. */
  121085. export class ParticlesOptimization extends SceneOptimization {
  121086. /**
  121087. * Gets a string describing the action executed by the current optimization
  121088. * @return description string
  121089. */
  121090. getDescription(): string;
  121091. /**
  121092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121093. * @param scene defines the current scene where to apply this optimization
  121094. * @param optimizer defines the current optimizer
  121095. * @returns true if everything that can be done was applied
  121096. */
  121097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121098. }
  121099. /**
  121100. * Defines an optimization used to turn render targets off
  121101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121102. */
  121103. export class RenderTargetsOptimization extends SceneOptimization {
  121104. /**
  121105. * Gets a string describing the action executed by the current optimization
  121106. * @return description string
  121107. */
  121108. getDescription(): string;
  121109. /**
  121110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121111. * @param scene defines the current scene where to apply this optimization
  121112. * @param optimizer defines the current optimizer
  121113. * @returns true if everything that can be done was applied
  121114. */
  121115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121116. }
  121117. /**
  121118. * Defines an optimization used to merge meshes with compatible materials
  121119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121120. */
  121121. export class MergeMeshesOptimization extends SceneOptimization {
  121122. private static _UpdateSelectionTree;
  121123. /**
  121124. * Gets or sets a boolean which defines if optimization octree has to be updated
  121125. */
  121126. /**
  121127. * Gets or sets a boolean which defines if optimization octree has to be updated
  121128. */
  121129. static UpdateSelectionTree: boolean;
  121130. /**
  121131. * Gets a string describing the action executed by the current optimization
  121132. * @return description string
  121133. */
  121134. getDescription(): string;
  121135. private _canBeMerged;
  121136. /**
  121137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121138. * @param scene defines the current scene where to apply this optimization
  121139. * @param optimizer defines the current optimizer
  121140. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121141. * @returns true if everything that can be done was applied
  121142. */
  121143. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121144. }
  121145. /**
  121146. * Defines a list of options used by SceneOptimizer
  121147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121148. */
  121149. export class SceneOptimizerOptions {
  121150. /**
  121151. * Defines the target frame rate to reach (60 by default)
  121152. */
  121153. targetFrameRate: number;
  121154. /**
  121155. * Defines the interval between two checkes (2000ms by default)
  121156. */
  121157. trackerDuration: number;
  121158. /**
  121159. * Gets the list of optimizations to apply
  121160. */
  121161. optimizations: SceneOptimization[];
  121162. /**
  121163. * Creates a new list of options used by SceneOptimizer
  121164. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121165. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121166. */
  121167. constructor(
  121168. /**
  121169. * Defines the target frame rate to reach (60 by default)
  121170. */
  121171. targetFrameRate?: number,
  121172. /**
  121173. * Defines the interval between two checkes (2000ms by default)
  121174. */
  121175. trackerDuration?: number);
  121176. /**
  121177. * Add a new optimization
  121178. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121179. * @returns the current SceneOptimizerOptions
  121180. */
  121181. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121182. /**
  121183. * Add a new custom optimization
  121184. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121185. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121186. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121187. * @returns the current SceneOptimizerOptions
  121188. */
  121189. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121190. /**
  121191. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121192. * @param targetFrameRate defines the target frame rate (60 by default)
  121193. * @returns a SceneOptimizerOptions object
  121194. */
  121195. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121196. /**
  121197. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121198. * @param targetFrameRate defines the target frame rate (60 by default)
  121199. * @returns a SceneOptimizerOptions object
  121200. */
  121201. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121202. /**
  121203. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121204. * @param targetFrameRate defines the target frame rate (60 by default)
  121205. * @returns a SceneOptimizerOptions object
  121206. */
  121207. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121208. }
  121209. /**
  121210. * Class used to run optimizations in order to reach a target frame rate
  121211. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121212. */
  121213. export class SceneOptimizer implements IDisposable {
  121214. private _isRunning;
  121215. private _options;
  121216. private _scene;
  121217. private _currentPriorityLevel;
  121218. private _targetFrameRate;
  121219. private _trackerDuration;
  121220. private _currentFrameRate;
  121221. private _sceneDisposeObserver;
  121222. private _improvementMode;
  121223. /**
  121224. * Defines an observable called when the optimizer reaches the target frame rate
  121225. */
  121226. onSuccessObservable: Observable<SceneOptimizer>;
  121227. /**
  121228. * Defines an observable called when the optimizer enables an optimization
  121229. */
  121230. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121231. /**
  121232. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121233. */
  121234. onFailureObservable: Observable<SceneOptimizer>;
  121235. /**
  121236. * Gets a boolean indicating if the optimizer is in improvement mode
  121237. */
  121238. readonly isInImprovementMode: boolean;
  121239. /**
  121240. * Gets the current priority level (0 at start)
  121241. */
  121242. readonly currentPriorityLevel: number;
  121243. /**
  121244. * Gets the current frame rate checked by the SceneOptimizer
  121245. */
  121246. readonly currentFrameRate: number;
  121247. /**
  121248. * Gets or sets the current target frame rate (60 by default)
  121249. */
  121250. /**
  121251. * Gets or sets the current target frame rate (60 by default)
  121252. */
  121253. targetFrameRate: number;
  121254. /**
  121255. * Gets or sets the current interval between two checks (every 2000ms by default)
  121256. */
  121257. /**
  121258. * Gets or sets the current interval between two checks (every 2000ms by default)
  121259. */
  121260. trackerDuration: number;
  121261. /**
  121262. * Gets the list of active optimizations
  121263. */
  121264. readonly optimizations: SceneOptimization[];
  121265. /**
  121266. * Creates a new SceneOptimizer
  121267. * @param scene defines the scene to work on
  121268. * @param options defines the options to use with the SceneOptimizer
  121269. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  121270. * @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)
  121271. */
  121272. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  121273. /**
  121274. * Stops the current optimizer
  121275. */
  121276. stop(): void;
  121277. /**
  121278. * Reset the optimizer to initial step (current priority level = 0)
  121279. */
  121280. reset(): void;
  121281. /**
  121282. * Start the optimizer. By default it will try to reach a specific framerate
  121283. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  121284. */
  121285. start(): void;
  121286. private _checkCurrentState;
  121287. /**
  121288. * Release all resources
  121289. */
  121290. dispose(): void;
  121291. /**
  121292. * Helper function to create a SceneOptimizer with one single line of code
  121293. * @param scene defines the scene to work on
  121294. * @param options defines the options to use with the SceneOptimizer
  121295. * @param onSuccess defines a callback to call on success
  121296. * @param onFailure defines a callback to call on failure
  121297. * @returns the new SceneOptimizer object
  121298. */
  121299. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  121300. }
  121301. }
  121302. declare module BABYLON {
  121303. /**
  121304. * Class used to serialize a scene into a string
  121305. */
  121306. export class SceneSerializer {
  121307. /**
  121308. * Clear cache used by a previous serialization
  121309. */
  121310. static ClearCache(): void;
  121311. /**
  121312. * Serialize a scene into a JSON compatible object
  121313. * @param scene defines the scene to serialize
  121314. * @returns a JSON compatible object
  121315. */
  121316. static Serialize(scene: Scene): any;
  121317. /**
  121318. * Serialize a mesh into a JSON compatible object
  121319. * @param toSerialize defines the mesh to serialize
  121320. * @param withParents defines if parents must be serialized as well
  121321. * @param withChildren defines if children must be serialized as well
  121322. * @returns a JSON compatible object
  121323. */
  121324. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  121325. }
  121326. }
  121327. declare module BABYLON {
  121328. /**
  121329. * Class used to host texture specific utilities
  121330. */
  121331. export class TextureTools {
  121332. /**
  121333. * Uses the GPU to create a copy texture rescaled at a given size
  121334. * @param texture Texture to copy from
  121335. * @param width defines the desired width
  121336. * @param height defines the desired height
  121337. * @param useBilinearMode defines if bilinear mode has to be used
  121338. * @return the generated texture
  121339. */
  121340. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  121341. }
  121342. }
  121343. declare module BABYLON {
  121344. /**
  121345. * This represents the different options avilable for the video capture.
  121346. */
  121347. export interface VideoRecorderOptions {
  121348. /** Defines the mime type of the video */
  121349. mimeType: string;
  121350. /** Defines the video the video should be recorded at */
  121351. fps: number;
  121352. /** Defines the chunk size for the recording data */
  121353. recordChunckSize: number;
  121354. /** The audio tracks to attach to the record */
  121355. audioTracks?: MediaStreamTrack[];
  121356. }
  121357. /**
  121358. * This can helps recording videos from BabylonJS.
  121359. * This is based on the available WebRTC functionalities of the browser.
  121360. *
  121361. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  121362. */
  121363. export class VideoRecorder {
  121364. private static readonly _defaultOptions;
  121365. /**
  121366. * Returns wehther or not the VideoRecorder is available in your browser.
  121367. * @param engine Defines the Babylon Engine to check the support for
  121368. * @returns true if supported otherwise false
  121369. */
  121370. static IsSupported(engine: Engine): boolean;
  121371. private readonly _options;
  121372. private _canvas;
  121373. private _mediaRecorder;
  121374. private _recordedChunks;
  121375. private _fileName;
  121376. private _resolve;
  121377. private _reject;
  121378. /**
  121379. * True wether a recording is already in progress.
  121380. */
  121381. readonly isRecording: boolean;
  121382. /**
  121383. * Create a new VideoCapture object which can help converting what you see in Babylon to
  121384. * a video file.
  121385. * @param engine Defines the BabylonJS Engine you wish to record
  121386. * @param options Defines options that can be used to customized the capture
  121387. */
  121388. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  121389. /**
  121390. * Stops the current recording before the default capture timeout passed in the startRecording
  121391. * functions.
  121392. */
  121393. stopRecording(): void;
  121394. /**
  121395. * Starts recording the canvas for a max duration specified in parameters.
  121396. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  121397. * @param maxDuration Defines the maximum recording time in seconds.
  121398. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  121399. * @return a promise callback at the end of the recording with the video data in Blob.
  121400. */
  121401. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  121402. /**
  121403. * Releases internal resources used during the recording.
  121404. */
  121405. dispose(): void;
  121406. private _handleDataAvailable;
  121407. private _handleError;
  121408. private _handleStop;
  121409. }
  121410. }
  121411. declare module BABYLON {
  121412. /**
  121413. * Class containing a set of static utilities functions for screenshots
  121414. */
  121415. export class ScreenshotTools {
  121416. /**
  121417. * Captures a screenshot of the current rendering
  121418. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121419. * @param engine defines the rendering engine
  121420. * @param camera defines the source camera
  121421. * @param size This parameter can be set to a single number or to an object with the
  121422. * following (optional) properties: precision, width, height. If a single number is passed,
  121423. * it will be used for both width and height. If an object is passed, the screenshot size
  121424. * will be derived from the parameters. The precision property is a multiplier allowing
  121425. * rendering at a higher or lower resolution
  121426. * @param successCallback defines the callback receives a single parameter which contains the
  121427. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121428. * src parameter of an <img> to display it
  121429. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  121430. * Check your browser for supported MIME types
  121431. */
  121432. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  121433. /**
  121434. * Generates an image screenshot from the specified camera.
  121435. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121436. * @param engine The engine to use for rendering
  121437. * @param camera The camera to use for rendering
  121438. * @param size This parameter can be set to a single number or to an object with the
  121439. * following (optional) properties: precision, width, height. If a single number is passed,
  121440. * it will be used for both width and height. If an object is passed, the screenshot size
  121441. * will be derived from the parameters. The precision property is a multiplier allowing
  121442. * rendering at a higher or lower resolution
  121443. * @param successCallback The callback receives a single parameter which contains the
  121444. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121445. * src parameter of an <img> to display it
  121446. * @param mimeType The MIME type of the screenshot image (default: image/png).
  121447. * Check your browser for supported MIME types
  121448. * @param samples Texture samples (default: 1)
  121449. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  121450. * @param fileName A name for for the downloaded file.
  121451. */
  121452. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  121453. }
  121454. }
  121455. declare module BABYLON {
  121456. /**
  121457. * A cursor which tracks a point on a path
  121458. */
  121459. export class PathCursor {
  121460. private path;
  121461. /**
  121462. * Stores path cursor callbacks for when an onchange event is triggered
  121463. */
  121464. private _onchange;
  121465. /**
  121466. * The value of the path cursor
  121467. */
  121468. value: number;
  121469. /**
  121470. * The animation array of the path cursor
  121471. */
  121472. animations: Animation[];
  121473. /**
  121474. * Initializes the path cursor
  121475. * @param path The path to track
  121476. */
  121477. constructor(path: Path2);
  121478. /**
  121479. * Gets the cursor point on the path
  121480. * @returns A point on the path cursor at the cursor location
  121481. */
  121482. getPoint(): Vector3;
  121483. /**
  121484. * Moves the cursor ahead by the step amount
  121485. * @param step The amount to move the cursor forward
  121486. * @returns This path cursor
  121487. */
  121488. moveAhead(step?: number): PathCursor;
  121489. /**
  121490. * Moves the cursor behind by the step amount
  121491. * @param step The amount to move the cursor back
  121492. * @returns This path cursor
  121493. */
  121494. moveBack(step?: number): PathCursor;
  121495. /**
  121496. * Moves the cursor by the step amount
  121497. * If the step amount is greater than one, an exception is thrown
  121498. * @param step The amount to move the cursor
  121499. * @returns This path cursor
  121500. */
  121501. move(step: number): PathCursor;
  121502. /**
  121503. * Ensures that the value is limited between zero and one
  121504. * @returns This path cursor
  121505. */
  121506. private ensureLimits;
  121507. /**
  121508. * Runs onchange callbacks on change (used by the animation engine)
  121509. * @returns This path cursor
  121510. */
  121511. private raiseOnChange;
  121512. /**
  121513. * Executes a function on change
  121514. * @param f A path cursor onchange callback
  121515. * @returns This path cursor
  121516. */
  121517. onchange(f: (cursor: PathCursor) => void): PathCursor;
  121518. }
  121519. }
  121520. declare module BABYLON {
  121521. /** @hidden */
  121522. export var blurPixelShader: {
  121523. name: string;
  121524. shader: string;
  121525. };
  121526. }
  121527. declare module BABYLON {
  121528. /** @hidden */
  121529. export var bones300Declaration: {
  121530. name: string;
  121531. shader: string;
  121532. };
  121533. }
  121534. declare module BABYLON {
  121535. /** @hidden */
  121536. export var instances300Declaration: {
  121537. name: string;
  121538. shader: string;
  121539. };
  121540. }
  121541. declare module BABYLON {
  121542. /** @hidden */
  121543. export var pointCloudVertexDeclaration: {
  121544. name: string;
  121545. shader: string;
  121546. };
  121547. }
  121548. // Mixins
  121549. interface Window {
  121550. mozIndexedDB: IDBFactory;
  121551. webkitIndexedDB: IDBFactory;
  121552. msIndexedDB: IDBFactory;
  121553. webkitURL: typeof URL;
  121554. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  121555. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  121556. WebGLRenderingContext: WebGLRenderingContext;
  121557. MSGesture: MSGesture;
  121558. CANNON: any;
  121559. AudioContext: AudioContext;
  121560. webkitAudioContext: AudioContext;
  121561. PointerEvent: any;
  121562. Math: Math;
  121563. Uint8Array: Uint8ArrayConstructor;
  121564. Float32Array: Float32ArrayConstructor;
  121565. mozURL: typeof URL;
  121566. msURL: typeof URL;
  121567. VRFrameData: any; // WebVR, from specs 1.1
  121568. DracoDecoderModule: any;
  121569. setImmediate(handler: (...args: any[]) => void): number;
  121570. }
  121571. interface HTMLCanvasElement {
  121572. requestPointerLock(): void;
  121573. msRequestPointerLock?(): void;
  121574. mozRequestPointerLock?(): void;
  121575. webkitRequestPointerLock?(): void;
  121576. /** Track wether a record is in progress */
  121577. isRecording: boolean;
  121578. /** Capture Stream method defined by some browsers */
  121579. captureStream(fps?: number): MediaStream;
  121580. }
  121581. interface CanvasRenderingContext2D {
  121582. msImageSmoothingEnabled: boolean;
  121583. }
  121584. interface MouseEvent {
  121585. mozMovementX: number;
  121586. mozMovementY: number;
  121587. webkitMovementX: number;
  121588. webkitMovementY: number;
  121589. msMovementX: number;
  121590. msMovementY: number;
  121591. }
  121592. interface Navigator {
  121593. mozGetVRDevices: (any: any) => any;
  121594. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121595. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121596. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121597. webkitGetGamepads(): Gamepad[];
  121598. msGetGamepads(): Gamepad[];
  121599. webkitGamepads(): Gamepad[];
  121600. }
  121601. interface HTMLVideoElement {
  121602. mozSrcObject: any;
  121603. }
  121604. interface Math {
  121605. fround(x: number): number;
  121606. imul(a: number, b: number): number;
  121607. }
  121608. interface WebGLRenderingContext {
  121609. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  121610. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  121611. vertexAttribDivisor(index: number, divisor: number): void;
  121612. createVertexArray(): any;
  121613. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  121614. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  121615. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  121616. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  121617. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  121618. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  121619. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  121620. // Queries
  121621. createQuery(): WebGLQuery;
  121622. deleteQuery(query: WebGLQuery): void;
  121623. beginQuery(target: number, query: WebGLQuery): void;
  121624. endQuery(target: number): void;
  121625. getQueryParameter(query: WebGLQuery, pname: number): any;
  121626. getQuery(target: number, pname: number): any;
  121627. MAX_SAMPLES: number;
  121628. RGBA8: number;
  121629. READ_FRAMEBUFFER: number;
  121630. DRAW_FRAMEBUFFER: number;
  121631. UNIFORM_BUFFER: number;
  121632. HALF_FLOAT_OES: number;
  121633. RGBA16F: number;
  121634. RGBA32F: number;
  121635. R32F: number;
  121636. RG32F: number;
  121637. RGB32F: number;
  121638. R16F: number;
  121639. RG16F: number;
  121640. RGB16F: number;
  121641. RED: number;
  121642. RG: number;
  121643. R8: number;
  121644. RG8: number;
  121645. UNSIGNED_INT_24_8: number;
  121646. DEPTH24_STENCIL8: number;
  121647. /* Multiple Render Targets */
  121648. drawBuffers(buffers: number[]): void;
  121649. readBuffer(src: number): void;
  121650. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  121651. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  121652. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  121653. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  121654. // Occlusion Query
  121655. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  121656. ANY_SAMPLES_PASSED: number;
  121657. QUERY_RESULT_AVAILABLE: number;
  121658. QUERY_RESULT: number;
  121659. }
  121660. interface WebGLProgram {
  121661. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  121662. }
  121663. interface EXT_disjoint_timer_query {
  121664. QUERY_COUNTER_BITS_EXT: number;
  121665. TIME_ELAPSED_EXT: number;
  121666. TIMESTAMP_EXT: number;
  121667. GPU_DISJOINT_EXT: number;
  121668. QUERY_RESULT_EXT: number;
  121669. QUERY_RESULT_AVAILABLE_EXT: number;
  121670. queryCounterEXT(query: WebGLQuery, target: number): void;
  121671. createQueryEXT(): WebGLQuery;
  121672. beginQueryEXT(target: number, query: WebGLQuery): void;
  121673. endQueryEXT(target: number): void;
  121674. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  121675. deleteQueryEXT(query: WebGLQuery): void;
  121676. }
  121677. interface WebGLUniformLocation {
  121678. _currentState: any;
  121679. }
  121680. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  121681. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  121682. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  121683. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121684. interface WebGLRenderingContext {
  121685. readonly RASTERIZER_DISCARD: number;
  121686. readonly DEPTH_COMPONENT24: number;
  121687. readonly TEXTURE_3D: number;
  121688. readonly TEXTURE_2D_ARRAY: number;
  121689. readonly TEXTURE_COMPARE_FUNC: number;
  121690. readonly TEXTURE_COMPARE_MODE: number;
  121691. readonly COMPARE_REF_TO_TEXTURE: number;
  121692. readonly TEXTURE_WRAP_R: number;
  121693. readonly HALF_FLOAT: number;
  121694. readonly RGB8: number;
  121695. readonly RED_INTEGER: number;
  121696. readonly RG_INTEGER: number;
  121697. readonly RGB_INTEGER: number;
  121698. readonly RGBA_INTEGER: number;
  121699. readonly R8_SNORM: number;
  121700. readonly RG8_SNORM: number;
  121701. readonly RGB8_SNORM: number;
  121702. readonly RGBA8_SNORM: number;
  121703. readonly R8I: number;
  121704. readonly RG8I: number;
  121705. readonly RGB8I: number;
  121706. readonly RGBA8I: number;
  121707. readonly R8UI: number;
  121708. readonly RG8UI: number;
  121709. readonly RGB8UI: number;
  121710. readonly RGBA8UI: number;
  121711. readonly R16I: number;
  121712. readonly RG16I: number;
  121713. readonly RGB16I: number;
  121714. readonly RGBA16I: number;
  121715. readonly R16UI: number;
  121716. readonly RG16UI: number;
  121717. readonly RGB16UI: number;
  121718. readonly RGBA16UI: number;
  121719. readonly R32I: number;
  121720. readonly RG32I: number;
  121721. readonly RGB32I: number;
  121722. readonly RGBA32I: number;
  121723. readonly R32UI: number;
  121724. readonly RG32UI: number;
  121725. readonly RGB32UI: number;
  121726. readonly RGBA32UI: number;
  121727. readonly RGB10_A2UI: number;
  121728. readonly R11F_G11F_B10F: number;
  121729. readonly RGB9_E5: number;
  121730. readonly RGB10_A2: number;
  121731. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  121732. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  121733. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  121734. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121735. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  121736. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  121737. 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;
  121738. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  121739. readonly TRANSFORM_FEEDBACK: number;
  121740. readonly INTERLEAVED_ATTRIBS: number;
  121741. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  121742. createTransformFeedback(): WebGLTransformFeedback;
  121743. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  121744. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  121745. beginTransformFeedback(primitiveMode: number): void;
  121746. endTransformFeedback(): void;
  121747. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  121748. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121749. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121750. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121751. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  121752. }
  121753. interface ImageBitmap {
  121754. readonly width: number;
  121755. readonly height: number;
  121756. close(): void;
  121757. }
  121758. interface WebGLQuery extends WebGLObject {
  121759. }
  121760. declare var WebGLQuery: {
  121761. prototype: WebGLQuery;
  121762. new(): WebGLQuery;
  121763. };
  121764. interface WebGLSampler extends WebGLObject {
  121765. }
  121766. declare var WebGLSampler: {
  121767. prototype: WebGLSampler;
  121768. new(): WebGLSampler;
  121769. };
  121770. interface WebGLSync extends WebGLObject {
  121771. }
  121772. declare var WebGLSync: {
  121773. prototype: WebGLSync;
  121774. new(): WebGLSync;
  121775. };
  121776. interface WebGLTransformFeedback extends WebGLObject {
  121777. }
  121778. declare var WebGLTransformFeedback: {
  121779. prototype: WebGLTransformFeedback;
  121780. new(): WebGLTransformFeedback;
  121781. };
  121782. interface WebGLVertexArrayObject extends WebGLObject {
  121783. }
  121784. declare var WebGLVertexArrayObject: {
  121785. prototype: WebGLVertexArrayObject;
  121786. new(): WebGLVertexArrayObject;
  121787. };
  121788. // Type definitions for WebVR API
  121789. // Project: https://w3c.github.io/webvr/
  121790. // Definitions by: six a <https://github.com/lostfictions>
  121791. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121792. interface VRDisplay extends EventTarget {
  121793. /**
  121794. * Dictionary of capabilities describing the VRDisplay.
  121795. */
  121796. readonly capabilities: VRDisplayCapabilities;
  121797. /**
  121798. * z-depth defining the far plane of the eye view frustum
  121799. * enables mapping of values in the render target depth
  121800. * attachment to scene coordinates. Initially set to 10000.0.
  121801. */
  121802. depthFar: number;
  121803. /**
  121804. * z-depth defining the near plane of the eye view frustum
  121805. * enables mapping of values in the render target depth
  121806. * attachment to scene coordinates. Initially set to 0.01.
  121807. */
  121808. depthNear: number;
  121809. /**
  121810. * An identifier for this distinct VRDisplay. Used as an
  121811. * association point in the Gamepad API.
  121812. */
  121813. readonly displayId: number;
  121814. /**
  121815. * A display name, a user-readable name identifying it.
  121816. */
  121817. readonly displayName: string;
  121818. readonly isConnected: boolean;
  121819. readonly isPresenting: boolean;
  121820. /**
  121821. * If this VRDisplay supports room-scale experiences, the optional
  121822. * stage attribute contains details on the room-scale parameters.
  121823. */
  121824. readonly stageParameters: VRStageParameters | null;
  121825. /**
  121826. * Passing the value returned by `requestAnimationFrame` to
  121827. * `cancelAnimationFrame` will unregister the callback.
  121828. * @param handle Define the hanle of the request to cancel
  121829. */
  121830. cancelAnimationFrame(handle: number): void;
  121831. /**
  121832. * Stops presenting to the VRDisplay.
  121833. * @returns a promise to know when it stopped
  121834. */
  121835. exitPresent(): Promise<void>;
  121836. /**
  121837. * Return the current VREyeParameters for the given eye.
  121838. * @param whichEye Define the eye we want the parameter for
  121839. * @returns the eye parameters
  121840. */
  121841. getEyeParameters(whichEye: string): VREyeParameters;
  121842. /**
  121843. * Populates the passed VRFrameData with the information required to render
  121844. * the current frame.
  121845. * @param frameData Define the data structure to populate
  121846. * @returns true if ok otherwise false
  121847. */
  121848. getFrameData(frameData: VRFrameData): boolean;
  121849. /**
  121850. * Get the layers currently being presented.
  121851. * @returns the list of VR layers
  121852. */
  121853. getLayers(): VRLayer[];
  121854. /**
  121855. * Return a VRPose containing the future predicted pose of the VRDisplay
  121856. * when the current frame will be presented. The value returned will not
  121857. * change until JavaScript has returned control to the browser.
  121858. *
  121859. * The VRPose will contain the position, orientation, velocity,
  121860. * and acceleration of each of these properties.
  121861. * @returns the pose object
  121862. */
  121863. getPose(): VRPose;
  121864. /**
  121865. * Return the current instantaneous pose of the VRDisplay, with no
  121866. * prediction applied.
  121867. * @returns the current instantaneous pose
  121868. */
  121869. getImmediatePose(): VRPose;
  121870. /**
  121871. * The callback passed to `requestAnimationFrame` will be called
  121872. * any time a new frame should be rendered. When the VRDisplay is
  121873. * presenting the callback will be called at the native refresh
  121874. * rate of the HMD. When not presenting this function acts
  121875. * identically to how window.requestAnimationFrame acts. Content should
  121876. * make no assumptions of frame rate or vsync behavior as the HMD runs
  121877. * asynchronously from other displays and at differing refresh rates.
  121878. * @param callback Define the eaction to run next frame
  121879. * @returns the request handle it
  121880. */
  121881. requestAnimationFrame(callback: FrameRequestCallback): number;
  121882. /**
  121883. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  121884. * Repeat calls while already presenting will update the VRLayers being displayed.
  121885. * @param layers Define the list of layer to present
  121886. * @returns a promise to know when the request has been fulfilled
  121887. */
  121888. requestPresent(layers: VRLayer[]): Promise<void>;
  121889. /**
  121890. * Reset the pose for this display, treating its current position and
  121891. * orientation as the "origin/zero" values. VRPose.position,
  121892. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  121893. * updated when calling resetPose(). This should be called in only
  121894. * sitting-space experiences.
  121895. */
  121896. resetPose(): void;
  121897. /**
  121898. * The VRLayer provided to the VRDisplay will be captured and presented
  121899. * in the HMD. Calling this function has the same effect on the source
  121900. * canvas as any other operation that uses its source image, and canvases
  121901. * created without preserveDrawingBuffer set to true will be cleared.
  121902. * @param pose Define the pose to submit
  121903. */
  121904. submitFrame(pose?: VRPose): void;
  121905. }
  121906. declare var VRDisplay: {
  121907. prototype: VRDisplay;
  121908. new(): VRDisplay;
  121909. };
  121910. interface VRLayer {
  121911. leftBounds?: number[] | Float32Array | null;
  121912. rightBounds?: number[] | Float32Array | null;
  121913. source?: HTMLCanvasElement | null;
  121914. }
  121915. interface VRDisplayCapabilities {
  121916. readonly canPresent: boolean;
  121917. readonly hasExternalDisplay: boolean;
  121918. readonly hasOrientation: boolean;
  121919. readonly hasPosition: boolean;
  121920. readonly maxLayers: number;
  121921. }
  121922. interface VREyeParameters {
  121923. /** @deprecated */
  121924. readonly fieldOfView: VRFieldOfView;
  121925. readonly offset: Float32Array;
  121926. readonly renderHeight: number;
  121927. readonly renderWidth: number;
  121928. }
  121929. interface VRFieldOfView {
  121930. readonly downDegrees: number;
  121931. readonly leftDegrees: number;
  121932. readonly rightDegrees: number;
  121933. readonly upDegrees: number;
  121934. }
  121935. interface VRFrameData {
  121936. readonly leftProjectionMatrix: Float32Array;
  121937. readonly leftViewMatrix: Float32Array;
  121938. readonly pose: VRPose;
  121939. readonly rightProjectionMatrix: Float32Array;
  121940. readonly rightViewMatrix: Float32Array;
  121941. readonly timestamp: number;
  121942. }
  121943. interface VRPose {
  121944. readonly angularAcceleration: Float32Array | null;
  121945. readonly angularVelocity: Float32Array | null;
  121946. readonly linearAcceleration: Float32Array | null;
  121947. readonly linearVelocity: Float32Array | null;
  121948. readonly orientation: Float32Array | null;
  121949. readonly position: Float32Array | null;
  121950. readonly timestamp: number;
  121951. }
  121952. interface VRStageParameters {
  121953. sittingToStandingTransform?: Float32Array;
  121954. sizeX?: number;
  121955. sizeY?: number;
  121956. }
  121957. interface Navigator {
  121958. getVRDisplays(): Promise<VRDisplay[]>;
  121959. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  121960. }
  121961. interface Window {
  121962. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  121963. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  121964. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  121965. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  121966. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  121967. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  121968. }
  121969. interface Gamepad {
  121970. readonly displayId: number;
  121971. }
  121972. interface XRDevice {
  121973. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  121974. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  121975. }
  121976. interface XRSession {
  121977. getInputSources(): Array<any>;
  121978. baseLayer: XRWebGLLayer;
  121979. requestFrameOfReference(type: string): Promise<void>;
  121980. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  121981. end(): Promise<void>;
  121982. requestAnimationFrame: Function;
  121983. addEventListener: Function;
  121984. }
  121985. interface XRSessionCreationOptions {
  121986. outputContext?: WebGLRenderingContext | null;
  121987. immersive?: boolean;
  121988. environmentIntegration?: boolean;
  121989. }
  121990. interface XRLayer {
  121991. getViewport: Function;
  121992. framebufferWidth: number;
  121993. framebufferHeight: number;
  121994. }
  121995. interface XRView {
  121996. projectionMatrix: Float32Array;
  121997. }
  121998. interface XRFrame {
  121999. getDevicePose: Function;
  122000. getInputPose: Function;
  122001. views: Array<XRView>;
  122002. baseLayer: XRLayer;
  122003. }
  122004. interface XRFrameOfReference {
  122005. }
  122006. interface XRWebGLLayer extends XRLayer {
  122007. framebuffer: WebGLFramebuffer;
  122008. }
  122009. declare var XRWebGLLayer: {
  122010. prototype: XRWebGLLayer;
  122011. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  122012. };